Created
May 28, 2017 16:42
-
-
Save katoy/17ff45a6cd9a7268067f966621bed6fc to your computer and use it in GitHub Desktop.
rail migations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateUsers < ActiveRecord::Migration[5.0] | |
def change | |
create_table :users do |t| | |
t.string :uuid | |
t.string :name | |
t.timestamps | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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