migrations: fix old migration not removing posts.uploader_ip_addr index.
Bug: running migrations on a fresh database failed when we got to a migration adding a posts.uploader_ip_addr index on 2019-11-11. It failed because the index already existed. The index already existed because we used to have it at one point, until it was removed by another migration on 2015-01-20. This migration didn't correctly remove the index though, because it tried to remove a posts.source index first, which failed because this index didn't exist (it probably existed only in production). This error was swallowed, causing the migration to silently skip removing the posts.uploader_ip_addr index, which eventually blew up when we tried to add the index again later on.
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
class RemoveUnusedIndexes < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
execute "set statement_timeout = 0"
|
||||
begin
|
||||
remove_index :posts, :source
|
||||
remove_index :posts, :uploader_ip_addr
|
||||
rescue ArgumentError
|
||||
end
|
||||
#remove_index :posts, :source
|
||||
remove_index :posts, :uploader_ip_addr
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user