rename on_remove, on_drop

This commit is contained in:
Sam 2017-05-04 13:41:05 -04:00
parent 81326f85e5
commit 7a15b44ac3
6 changed files with 8 additions and 8 deletions

View File

@ -30,7 +30,7 @@ ColumnDropper.drop(
table: 'categories',
after_migration: 'AddUploadsToCategories',
columns: ['logo_url', 'background_url'],
on_remove: ->(){
on_drop: ->(){
STDERR.puts 'Removing superflous categories columns!'
}
)

View File

@ -49,7 +49,7 @@ ColumnDropper.drop(
last_redirected_to_top_at
auth_token
auth_token_updated_at ],
on_remove: ->(){
on_drop: ->(){
STDERR.puts 'Removing superflous users columns!'
}
)

View File

@ -22,7 +22,7 @@ ColumnDropper.drop(
table: 'theme_fields',
after_migration: 'AddUploadIdToThemeFields',
columns: ['target'],
on_remove: ->(){
on_drop: ->(){
STDERR.puts 'Removing superflous theme_fields target column!'
}
)

View File

@ -78,7 +78,7 @@ ColumnDropper.drop(
illegal_count
notify_user_count
},
on_remove: ->(){
on_drop: ->(){
STDERR.puts "Removing superflous topic columns!"
}
)

View File

@ -1,5 +1,5 @@
class ColumnDropper
def self.drop(table:, after_migration:, columns:, delay: nil, on_remove: nil)
def self.drop(table:, after_migration:, columns:, delay: nil, on_drop: nil)
raise ArgumentError.new("Invalid table name passed to drop #{table}") if table =~ /[^a-z0-9_]/i
columns.each do |column|
@ -27,7 +27,7 @@ SQL
columns: columns,
delay: "#{delay.to_i || 0} seconds",
after_migration: after_migration).to_a.length > 0
on_remove&.call
on_drop&.call
columns.each do |column|
# safe cause it is protected on method entry, can not be passed in params

View File

@ -30,7 +30,7 @@ describe ColumnDropper do
after_migration: name,
columns: ['junk'],
delay: 20.minutes,
on_remove: ->(){dropped_proc_called = true}
on_drop: ->(){dropped_proc_called = true}
)
expect(has_column?('topics', 'junk')).to eq(true)
@ -41,7 +41,7 @@ describe ColumnDropper do
after_migration: name,
columns: ['junk'],
delay: 10.minutes,
on_remove: ->(){dropped_proc_called = true}
on_drop: ->(){dropped_proc_called = true}
)
expect(has_column?('topics', 'junk')).to eq(false)