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 - Ruby on Rails Tutorial
From the course: Ruby on Rails 6 Essential Training
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Create a database for a Ruby on Rails project2m 17s
-
(Locked)
Write migrations to define database changes3m 16s
-
(Locked)
Use the command line to generate migrations7m 6s
-
(Locked)
Run migrations to change the database schema6m 2s
-
(Locked)
Challenge: Migrations for the CMS3m 50s
-
(Locked)
Solution: Migrations for the CMS2m 50s
-
(Locked)
-
-
-
-