Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'db/post_migrate/20230302123259_ensure_ci_runner_machines_is_empty.rb')
-rw-r--r--db/post_migrate/20230302123259_ensure_ci_runner_machines_is_empty.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/db/post_migrate/20230302123259_ensure_ci_runner_machines_is_empty.rb b/db/post_migrate/20230302123259_ensure_ci_runner_machines_is_empty.rb
new file mode 100644
index 00000000000..9f7233f43f5
--- /dev/null
+++ b/db/post_migrate/20230302123259_ensure_ci_runner_machines_is_empty.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class EnsureCiRunnerMachinesIsEmpty < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ return unless Gitlab::Database.gitlab_schemas_for_connection(connection).include?(:gitlab_ci)
+
+ # Ensure that the ci_runner_machines table is empty to ensure that new builds
+ # don't try to create new join records until we add the missing FK.
+ execute('TRUNCATE TABLE ci_runner_machines, p_ci_runner_machine_builds')
+ end
+
+ def down
+ # no-op
+ end
+end