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:
Sam
2018-03-21 15:43:32 +11:00
parent 9f216ac182
commit 6a3c8fe69c
21 changed files with 462 additions and 166 deletions
@@ -1,4 +1,4 @@
require 'table_migration_helper'
require 'migration/table_dropper'
class CreateTopicStatusUpdatesAgain < ActiveRecord::Migration[4.2]
def up
@@ -14,7 +14,7 @@ class CreateTopicStatusUpdatesAgain < ActiveRecord::Migration[4.2]
t.integer :category_id
end
TableMigrationHelper.read_only_table('topic_status_updates')
Migration::TableDropper.read_only_table('topic_status_updates')
end
def down