From the course: Ruby on Rails 6 Essential Training

Unlock the full course today

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

Use the command line to generate migrations

Use the command line to generate migrations - Ruby on Rails Tutorial

From the course: Ruby on Rails 6 Essential Training

Start my 1-month free trial

Use the command line to generate migrations

- [Instructor] In this movie, we're going to learn how to generate migrations. There are two main ways that we can generate migrations. The first is the general all-purpose way. You go to the command line, navigate to the root of your rails project, and type rails generate migration and then the name of the migration. You can see here I've got the migration name in what's called camel case, that is there's no spaces or underscores, the words are all smashed together with capital letters to indicate where each word starts. This'll give me a migration that I can use for any purpose I want. I can put any kind of ruby code in it and when I run my migrations, that code will be executed. There's another more special purpose case, which we're also going to use very often, which is to generate models. We know that our database and our models are going to be tied closely together. So you can also use rails generate model and then…

Contents