mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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
This commit is contained in:
9
spec/fixtures/migrate/drop_table/20990309014014_drop_table.rb
vendored
Normal file
9
spec/fixtures/migrate/drop_table/20990309014014_drop_table.rb
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
class DropTable < ActiveRecord::Migration[5.1]
|
||||
def up
|
||||
drop_table :users
|
||||
end
|
||||
|
||||
def down
|
||||
raise "not tested"
|
||||
end
|
||||
end
|
||||
9
spec/fixtures/migrate/remove_column/20990309014014_remove_column.rb
vendored
Normal file
9
spec/fixtures/migrate/remove_column/20990309014014_remove_column.rb
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
class RemoveColumn < ActiveRecord::Migration[5.1]
|
||||
def up
|
||||
remove_column :users, :username
|
||||
end
|
||||
|
||||
def down
|
||||
raise "not tested"
|
||||
end
|
||||
end
|
||||
9
spec/fixtures/migrate/rename_column/20990309014014_rename_column.rb
vendored
Normal file
9
spec/fixtures/migrate/rename_column/20990309014014_rename_column.rb
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
class RenameColumn < ActiveRecord::Migration[5.1]
|
||||
def up
|
||||
rename_column :users, :username, :username1
|
||||
end
|
||||
|
||||
def down
|
||||
raise "not tested"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user