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.
Migration methods - Ruby on Rails Tutorial
From the course: Ruby on Rails 5 Essential Training
Migration methods
- [Instructor] Migrations allow us to perform mini-database operations. Let's look at some of the options that are available to us, and then try them out. There are table migration methods. We've already seen create_table and drop_table. There's one more which is rename_table, where you provide the old table name as the first argument, and the new table name as the second one. There are also column migration methods, such as add_column, remove_column, rename-column and change_column. All four of these methods take the table name and the column name as their first two arguments. When we're working with create_table, we didn't have to specify table name each and every time we wanted to create a column. But here, because it's a stand alone method call, we do need to tell it which table we're referring to. With add_column, we are adding a column with a type definition the same way we did when we created table, but we can't use that short format that we had with create_table, we have to…
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
-
-
-
-
-
-
-
-
-
-
-
-
-