Ruby-on-rails Rails 迁移:如何使用 ROR 迁移增加列数据类型大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22351712/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 23:26:26 来源:igfitidea点击:
Rails Migration: How to increase column data type size by using ROR migration
提问by Sravan Kumar
My users table login column is String type with limit of 40 characters. Now I am planning to increase the limit to 55 characters.
我的用户表登录列是字符串类型,限制为 40 个字符。现在我计划将限制增加到 55 个字符。
Any one please let me know how can we increase this limit by using ROR migration.
任何人请让我知道我们如何通过使用 ROR 迁移来增加此限制。
Thanks, Sravan
谢谢,斯拉文
回答by beesasoh
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
回答by tirdadc
class YourMigration < ActiveRecord::Migration
def change
change_column :users, :login, :string, :limit => 55
end
end

