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 - Ruby on Rails Tutorial
From the course: Ruby on Rails 5 Essential Training
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…
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
-
-
-
-
-
-
Introduction to databases7m 53s
-
(Locked)
Create a database2m 27s
-
(Locked)
Migrations3m 4s
-
(Locked)
Generate migrations4m 3s
-
(Locked)
Generate models7m 58s
-
(Locked)
Run migrations8m 22s
-
(Locked)
Migration methods7m 47s
-
(Locked)
Solve migration problems5m 41s
-
(Locked)
Challenge: Migrations for the CMS4m
-
(Locked)
Solution: Migrations for the CMS4m 20s
-
-
-
-
-
-
-
-
-
-
-
-
-