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

Migration methods - Ruby on Rails Tutorial

From the course: Ruby on Rails 5 Essential Training

Start my 1-month free trial

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…

Contents