Fix migration when running on MySQL databases

parent 6e6c4c55
......@@ -6,14 +6,19 @@ class AddMissingIndexesToGeoEventLog < ActiveRecord::Migration
disable_ddl_transaction!
def up
add_concurrent_index :geo_event_log, :repositories_changed_event_id
add_concurrent_index :geo_event_log, :repository_deleted_event_id
add_concurrent_index :geo_event_log, :repository_renamed_event_id
# MySQL automatically creates an index on a foreign-key constraint; PostgreSQL does not
if Gitlab::Database.postgresql?
add_concurrent_index :geo_event_log, :repositories_changed_event_id
add_concurrent_index :geo_event_log, :repository_deleted_event_id
add_concurrent_index :geo_event_log, :repository_renamed_event_id
end
end
def down
remove_concurrent_index :geo_event_log, :repositories_changed_event_id if index_exists? :geo_event_log, :repositories_changed_event_id
remove_concurrent_index :geo_event_log, :repository_deleted_event_id if index_exists? :geo_event_log, :repository_deleted_event_id
remove_concurrent_index :geo_event_log, :repository_renamed_event_id if index_exists? :geo_event_log, :repository_renamed_event_id
if Gitlab::Database.postgresql?
remove_concurrent_index :geo_event_log, :repositories_changed_event_id if index_exists? :geo_event_log, :repositories_changed_event_id
remove_concurrent_index :geo_event_log, :repository_deleted_event_id if index_exists? :geo_event_log, :repository_deleted_event_id
remove_concurrent_index :geo_event_log, :repository_renamed_event_id if index_exists? :geo_event_log, :repository_renamed_event_id
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment