summaryrefslogtreecommitdiff
path: root/db/migrate/20161117114805_remove_undeleted_groups.rb
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-11-17 17:21:17 +0530
committerTimothy Andrew <mail@timothyandrew.net>2016-11-18 14:27:13 +0530
commitbf28506f673e728bfaf0f8fb29d07d3e1cf517a2 (patch)
tree7c1ba5f9a78c97ec6d47183016094ee41198cad6 /db/migrate/20161117114805_remove_undeleted_groups.rb
parent492ead3f715d2bfefad25190d98803f41307021f (diff)
downloadgitlab-ce-bf28506f673e728bfaf0f8fb29d07d3e1cf517a2.tar.gz
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.
Diffstat (limited to 'db/migrate/20161117114805_remove_undeleted_groups.rb')
-rw-r--r--db/migrate/20161117114805_remove_undeleted_groups.rb16
1 files changed, 16 insertions, 0 deletions
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