Rails Migration: How to increase column data type size by using ROR migration

Sravan Kumar picture Sravan Kumar · Mar 12, 2014 · Viewed 27k times · Source

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

Answer

beesasoh picture beesasoh · Jun 27, 2015
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