summaryrefslogtreecommitdiff
path: root/db/post_migrate/20200511220023_validate_projects_foreign_key_to_namespaces.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/post_migrate/20200511220023_validate_projects_foreign_key_to_namespaces.rb')
-rw-r--r--db/post_migrate/20200511220023_validate_projects_foreign_key_to_namespaces.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/db/post_migrate/20200511220023_validate_projects_foreign_key_to_namespaces.rb b/db/post_migrate/20200511220023_validate_projects_foreign_key_to_namespaces.rb
new file mode 100644
index 00000000000..37a761507fc
--- /dev/null
+++ b/db/post_migrate/20200511220023_validate_projects_foreign_key_to_namespaces.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class ValidateProjectsForeignKeyToNamespaces < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ FK_NAME = 'fk_projects_namespace_id'
+
+ def up
+ # Validate the FK added with 20200511080113_add_projects_foreign_key_to_namespaces.rb
+ validate_foreign_key :projects, :namespace_id, name: FK_NAME
+ end
+
+ def down
+ # no-op: No need to invalidate the foreign key
+ # The inconsistent data are permanently fixed with the data migration
+ # `20200511083541_cleanup_projects_with_missing_namespace.rb`
+ # even if it is rolled back.
+ # If there is an issue with the FK, we'll roll back the migration that adds the FK
+ end
+end