Skip to content

Instantly share code, notes, and snippets.

@katoy
Created May 28, 2017 16:42
Show Gist options
  • Save katoy/17ff45a6cd9a7268067f966621bed6fc to your computer and use it in GitHub Desktop.
Save katoy/17ff45a6cd9a7268067f966621bed6fc to your computer and use it in GitHub Desktop.
rail migations
class ChangeColumnToUser < ActiveRecord::Migration[5.0]
def change
# 追加
add_column :users, :piyo, :string
add_column :users, :piyo2, :string
# 削除
remove_column :users, :piyo2, :string
# rename
rename_column :users, :name_x, :name
end
end
class CreateUsers2 < ActiveRecord::Migration[5.0]
def change
create_table :users do |t|
t.string :uuid
t.string :name_x
t.timestamps
end
end
end
class CreateUsers < ActiveRecord::Migration[5.0]
def change
create_table :users do |t|
t.string :uuid
t.string :name
t.timestamps
end
end
end
class DropUser < ActiveRecord::Migration[5.0]
def change
drop_table :users
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment