Is the following correct?
change_column :tablename, :fieldname, :limit => null
If you have already run the migration then you cannot just edit the migration and run the migration again: Rails thinks it has already run the migration and so will do nothing when you run rake db:migrate.
A Rails migration is a tool for changing an application's database schema. Instead of managing SQL scripts, you define database changes in a domain-specific language (DSL). The code is database-independent, so you can easily move your app to a new platform.
If you previously specified a limit in a migration and want to just remove the limit, you can just do this:
change_column :users, :column, :string, :limit => 255
255 is the standard length for a string column, and rails will just wipe out the limit that you previously specified.
Updated:
While this works in a number of Rails versions, you would probably be better suited to use nil
like in Giuseppe's answer.
change_column :users, :column, :string, :limit => nil
That means the only thing you were doing wrong was using null
instead of nil
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With