Call on_drop only when tables/columns are dropped

This commit is contained in:
Gerhard Schlager
2018-03-26 17:05:18 +02:00
committed by Sam
parent 4ad401bac5
commit b945a2dc39
3 changed files with 42 additions and 3 deletions

View File

@@ -65,6 +65,19 @@ RSpec.describe Migration::ColumnDropper do
expect(has_column?('topics', 'junk')).to eq(false)
expect(dropped_proc_called).to eq(true)
dropped_proc_called = false
Migration::ColumnDropper.drop(
table: 'topics',
after_migration: migration_name,
columns: ['junk'],
delay: 10.minutes,
on_drop: ->() { dropped_proc_called = true }
)
# it should call "on_drop" only when there are columns to drop
expect(dropped_proc_called).to eq(false)
end
it "drops the columns immediately if the first migration was less than 10 minutes ago" do