LoginSignup
0
0

More than 5 years have passed since last update.

マイグレーション

Last updated at Posted at 2017-02-27
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
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0