My users table login column is String type with limit of 40 characters. Now I am planning to increase the limit to 55 characters.
Any one please let me know how can we increase this limit by using ROR migration.
Thanks, Sravan
Migrations are a convenient way to alter your database schema over time in a consistent way. They use a Ruby DSL so that you don't have to write SQL by hand, allowing your schema and changes to be database independent. You can think of each migration as being a new 'version' of the database.
add_index(table_name, column_name, options = {}) public. Adds a new index to the table. column_name can be a single Symbol, or an Array of Symbols. The index will be named after the table and the column name(s), unless you pass :name as an option.
class YourMigration < ActiveRecord::Migration def up change_column :users, :login, :string, :limit => 55 end def down change_column :users, :login, :string, :limit => 40 end end
class YourMigration < ActiveRecord::Migration def change change_column :users, :login, :string, :limit => 55 end end
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