discourse/spec/fixtures/migrate/rename_column/20990309014014_rename_column.rb
Sam 6a3c8fe69c FEATURE: protect against accidental column or table drops
Often we need to amend our schema, it is tempting to use
drop_table, rename_column and drop_column to amned schema
trouble though is that existing code that is running in production
can depend on the existance of previous schema leading to application
breaking until new code base is deployed.

The commit enforces new rules to ensure we can never drop tables or
columns in migrations and instead use Migration::ColumnDropper and
Migration::TableDropper to defer drop the db objects
2018-03-21 15:43:32 +11:00

10 lines
158 B
Ruby

class RenameColumn < ActiveRecord::Migration[5.1]
def up
rename_column :users, :username, :username1
end
def down
raise "not tested"
end
end