From the course: Ruby on Rails 5 Essential Training

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Migrations

Migrations - Ruby on Rails Tutorial

From the course: Ruby on Rails 5 Essential Training

Start my 1-month free trial

Migrations

- [Instructor] We have created a database and configured our Rails project to connect to it. Next we need to add tables to that database and we're going to do that by writing Rails migrations. A migration is a set of database instructions. Those instructions are Ruby code, which migrates our database from one state into another. Essentially, they describe database changes. In our migrations we can create a table, add a column, change the name of a column, drop a table, and much more. A migration will contain both the instructions for moving to a new state and also instructions for moving back down to the previous state. If a migration has instructions to create a table when moving forward or up, it will also include instructions to allow it to move back down by dropping the table. If you move up by adding three columns to a table, then you'll have instructions to move back down by removing those three columns. Being able to move in both directions allows us to migrate in both…

Contents