summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-03-03 00:12:53 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-03 00:12:53 +0000
commita77c9fccd057514a8b78a10642779f54a22f3f76 (patch)
tree5746326ff4e1e25f01af2062454f90bdc3f57d35 /db
parenta88ffaad9f9f321a71657ac0aca4d947f5bc6a5b (diff)
downloadgitlab-ce-a77c9fccd057514a8b78a10642779f54a22f3f76.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20230221214519_remove_incorrectly_onboarded_namespaces_from_onboarding_progress.rb29
-rw-r--r--db/schema_migrations/202302212145191
2 files changed, 30 insertions, 0 deletions
diff --git a/db/post_migrate/20230221214519_remove_incorrectly_onboarded_namespaces_from_onboarding_progress.rb b/db/post_migrate/20230221214519_remove_incorrectly_onboarded_namespaces_from_onboarding_progress.rb
new file mode 100644
index 00000000000..5672fc42851
--- /dev/null
+++ b/db/post_migrate/20230221214519_remove_incorrectly_onboarded_namespaces_from_onboarding_progress.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class RemoveIncorrectlyOnboardedNamespacesFromOnboardingProgress < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ class OnboardingProgress < MigrationRecord
+ include EachBatch
+
+ self.table_name = 'onboarding_progresses'
+ end
+
+ class Project < MigrationRecord
+ self.table_name = 'projects'
+ end
+
+ def up
+ names = ['Learn GitLab', 'Learn GitLab - Ultimate trial']
+
+ OnboardingProgress.each_batch(of: 500) do |batch|
+ namespaces_to_keep = Project.where(name: names, namespace_id: batch.select(:namespace_id)).select(:namespace_id)
+ batch.where.not(namespace_id: namespaces_to_keep).delete_all
+ end
+ end
+
+ def down
+ # no op
+ end
+end
diff --git a/db/schema_migrations/20230221214519 b/db/schema_migrations/20230221214519
new file mode 100644
index 00000000000..aa630e64644
--- /dev/null
+++ b/db/schema_migrations/20230221214519
@@ -0,0 +1 @@
+b8eccb700af0593b94e26e0fbe8b4c680b9bae47ced111422dc400159a3f6b12 \ No newline at end of file