From the course: Ruby on Rails 5 Essential Training

Unlock the full course today

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

Generate migrations

Generate migrations - Ruby on Rails Tutorial

From the course: Ruby on Rails 5 Essential Training

Start my 1-month free trial

Generate migrations

- [Instructor] Now that we understand what migrations are and why they're helpful, let's create our first migration. The way that we generate a migration is by using the rails generate command, which we saw earlier when we generated a controller. But this time we're going to do rails generate and then migration, followed by the name of the migration that we want to create, written in camelCase. That's where all the letters are smashed together but we use uppercase letters to indicate the division between words. You want to do this from the root of your Rails application so we'll type rails generate migration. And let's call this first migration DoNothingYet. We'll hit return and it will create a migration file for us. Notice that migrations reside in the db directory. That's because that's the place to keep everything related to the database. It also creates a directory called migrate for us, if it doesn't already exist. And then inside, it added a new file. It converted our…

Contents