- Read Tutorial
- Watch Guide Video
For demonstration purposes I created a new column in the database projects
and named it division
.
To delete this column, go to your console and type,
rails g migration remove_division_from_projects division:string
Now, go to the file 201510300010018_remove_division_from_projects.rb
This is what the file looks like:
The code is pretty basic and you're probably getting used to seeing the syntax. Inside the change
method, there is a call to remove_column
and the parameters are the name of the table, name of the column and the data type of the column.
Next, go to the console again and type rake db:migrate
and you'll see that the schema
file has reflected the change. You'll see that the column division
does not exist anymore.