1

こんにちはimnewruby onrails3.0移行したファイルに新しい列を作成する方法を知りたい

を使用して移行を作成しました

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

テーブルが新しく作成され、いくつかの列が追加されました。ターミナルplzを使用してどのように行うことができますか。

4

2 に答える 2

2

次に、rails g migration add_column_name_to_table_name column_name:type1つの移行を実行 または作成しますrails g migration add_columns_to_tables

def change
    add_column :table_name, :column_name, :type
end

http://guides.rubyonrails.org/migrations.html、http://api.rubyonrails.org/classes/ActiveRecord/Migration.htmlを 参照してください

于 2012-09-03T06:55:48.590 に答える
0

ターミナルで

rails g migration add_column_name_to_table_name column_name:type

rails g migration add_columns_to_tables
于 2012-09-05T07:41:46.107 に答える