Commit b24ef9ce authored by Felipe Artur's avatar Felipe Artur

Make wrong migrations idempotent

parent 4e07305b
......@@ -2,6 +2,8 @@ class AddGroupIdToMilestones < ActiveRecord::Migration
DOWNTIME = false
def up
return if column_exists? :milestones, :group_id
change_column_null :milestones, :project_id, true
add_column :milestones, :group_id, :integer
......
......@@ -6,6 +6,8 @@ class AddGroupMilestoneIdIndexes < ActiveRecord::Migration
DOWNTIME = false
def up
return if index_exists?(:milestones, :group_id)
add_concurrent_foreign_key :milestones, :namespaces, column: :group_id, on_delete: :cascade
add_concurrent_index :milestones, :group_id
......
class RemoveWrongVersionsFromSchemaVersions < ActiveRecord::Migration
def change
execute "UPDATE schema_migrations SET version = '20170707183807' WHERE version = '20170723183807'"
execute "UPDATE schema_migrations SET version = '20170707184243' WHERE version = '20170724184243'"
DOWNTIME = false
def up
execute("DELETE FROM schema_migrations WHERE version IN ('20170723183807', '20170724184243')")
end
def down
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