From bf28506f673e728bfaf0f8fb29d07d3e1cf517a2 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Thu, 17 Nov 2016 17:21:17 +0530 Subject: Add a migration to remove soft-deleted groups. The database should not have any soft-deleted groups. Due to a race condition (soft-delete completes after the hard-delete), soft-deleted groups were (incorrectly) left in the database, causing issues while trying to create a new group with the same name. --- db/migrate/20161117114805_remove_undeleted_groups.rb | 16 ++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20161117114805_remove_undeleted_groups.rb (limited to 'db') diff --git a/db/migrate/20161117114805_remove_undeleted_groups.rb b/db/migrate/20161117114805_remove_undeleted_groups.rb new file mode 100644 index 00000000000..ebc2d974ae0 --- /dev/null +++ b/db/migrate/20161117114805_remove_undeleted_groups.rb @@ -0,0 +1,16 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class RemoveUndeletedGroups < ActiveRecord::Migration + DOWNTIME = false + + def up + execute "DELETE FROM namespaces WHERE deleted_at IS NOT NULL;" + end + + def down + # This is an irreversible migration; + # If someone is trying to rollback for other reasons, we should not throw an Exception. + # raise ActiveRecord::IrreversibleMigration + end +end diff --git a/db/schema.rb b/db/schema.rb index 8f8a03e1534..9382f8adc4d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20161113184239) do +ActiveRecord::Schema.define(version: 20161117114805) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.1