Edited at

マイグレーション

More than 1 year has passed since last update.

class CreatePublications < ActiveRecord::Migration

def change
create_table :publications do |t|
t.string :title
t.text :description
t.references :publication_type
t.integer :publisher_id
t.string :publisher_type
t.boolean :single_issue

t.timestamps
end
add_index :publications, :publication_type_id
end
end

bin/rails db:migrate

bin/rails db:rollback

create_table(table_name,options)

drop_table(table_name)

add_column(table_name,column_name,type,options)

change_column(table_name,colum_name,type,options)

remove_column(table_name,*column_names)

add_index(table_name,*column_names)

remove_index(table_name,index_name)

既存のテーブル

追加 add_column

変更 change_column


entriesテーブル

published_on

def changeadd_column :entries, :published_on :date
end