Ruby on rails 完成rake db:migrate后,如何在ror3.0中添加新列?
您好,我是新的RubyonRails3.0,我想知道如何创建新的ColumnOne迁移文件 我使用Ruby on rails 完成rake db:migrate后,如何在ror3.0中添加新列?,ruby-on-rails,database,ruby-on-rails-3,rails-migrations,Ruby On Rails,Database,Ruby On Rails 3,Rails Migrations,您好,我是新的RubyonRails3.0,我想知道如何创建新的ColumnOne迁移文件 我使用 rake db:migrate class CreateCheckings < ActiveRecord::Migration def change create_table :checkings do |t| t.string :phone, :limit => 20 t.string :email t.i
rake db:migrate
class CreateCheckings < ActiveRecord::Migration
def change
create_table :checkings do |t|
t.string :phone, :limit => 20
t.string :email
t.integer "country_id"
t.string "registration_via"
t.string "industry_type", :limit => 2
t.boolean "is_admin", :default => false
t.boolean "is_account_blocked", :default => false
t.timestamps
end
end
end
rake数据库:迁移
类CreateCheckings20
t、 字符串:电子邮件
t、 整数“国家/地区id”
t、 字符串“注册通过”
t、 字符串“行业类型”,:限制=>2
t、 布尔值“is_admin”,默认值=>false
t、 布尔值“是否已阻止帐户”:默认值=>false
t、 时间戳
结束
结束
结束
现在创建新的表来添加一些列如何使用终端plz帮助我 运行
rails g迁移将列名称添加到表中列名称:键入
或
创建一个迁移rails g迁移将列添加到表中
def change
add_column :table_name, :column_name, :type
end
参考,
在终端中
rails g migration add_column_name_to_table_name column_name:type
rails g migration add_columns_to_tables