Saturday, April 2, 2011

Rails -migrations with column default changes

So wanted to add a default value for a column, but also wanted to do a proper rollback method on the migration. My problem may have been more with SQLite than rails, something about it not liking alter column commands.

Anyway:
change_column :table, :column, :type, default = 'value' did update the schema.

But also needed to add the date
Table.update_all( "column = 'value'", "column IS NULL") to fix unset values.


Didn't find a good syntax to remove the default setting from the schema.

No comments:

Post a Comment