How to Implement Migration in Rails Application

Cryptex Technologies
2 min readApr 20, 2021

By:Category: Ruby on Rails Technologies: Ruby on Rails

A technique used to create changes in the database, the Rails migration is a tool for modifying an application’s database schema. While creating a database, use migration to add, remove, rename, change the data type, adding a reference, adding a foreign key, etc.

To alter/change the existing table in the database.

It is a useful tool to make changes to the application’s database whenever required.

Let’s understand the step-by-step approach to applying Migration in Rails application.

Create a new Rails application and database.

Create model and controller in the application and draft code to create records.

Create a migration file to add an extra column to the table.

The application schema.rb file with all the migration will look as mentioned above.

After drafting the code to add the fields in the table, run the below command and start the server.

rails db:migrate

The migration file for adding a column will look as mentioned above.

Click Here for more ruby on rails blog

Originally published at https://www.cryptextechnologies.com.

--

--

Cryptex Technologies

Cryptex specializes in developing open source web applications and software solutions across all domains and verticals using Ruby on Rails (ROR) technology