summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-03-01 12:08:40 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-01 12:08:40 +0000
commit52522f10237f685c2535e6511d632bacdc7f6a78 (patch)
tree9a41894e03547bda99116c0789004ef1e1c11e6c /db
parent301f94cc9b9de6ea11e4c1e515aa772c3e468a67 (diff)
downloadgitlab-ce-52522f10237f685c2535e6511d632bacdc7f6a78.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20230227153231_validate_fk_on_ci_job_variables_partition_id_and_job_id.rb15
-rw-r--r--db/post_migrate/20230227153232_remove_fk_to_ci_builds_ci_job_variables_on_job_id.rb35
-rw-r--r--db/schema_migrations/202302271532311
-rw-r--r--db/schema_migrations/202302271532321
-rw-r--r--db/structure.sql5
5 files changed, 53 insertions, 4 deletions
diff --git a/db/post_migrate/20230227153231_validate_fk_on_ci_job_variables_partition_id_and_job_id.rb b/db/post_migrate/20230227153231_validate_fk_on_ci_job_variables_partition_id_and_job_id.rb
new file mode 100644
index 00000000000..035d26dbe94
--- /dev/null
+++ b/db/post_migrate/20230227153231_validate_fk_on_ci_job_variables_partition_id_and_job_id.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class ValidateFkOnCiJobVariablesPartitionIdAndJobId < Gitlab::Database::Migration[2.1]
+ TABLE_NAME = :ci_job_variables
+ FK_NAME = :fk_rails_fbf3b34792_p
+ COLUMNS = [:partition_id, :job_id]
+
+ def up
+ validate_foreign_key(TABLE_NAME, COLUMNS, name: FK_NAME)
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20230227153232_remove_fk_to_ci_builds_ci_job_variables_on_job_id.rb b/db/post_migrate/20230227153232_remove_fk_to_ci_builds_ci_job_variables_on_job_id.rb
new file mode 100644
index 00000000000..f5dae8b57e0
--- /dev/null
+++ b/db/post_migrate/20230227153232_remove_fk_to_ci_builds_ci_job_variables_on_job_id.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+class RemoveFkToCiBuildsCiJobVariablesOnJobId < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ SOURCE_TABLE_NAME = :ci_job_variables
+ TARGET_TABLE_NAME = :ci_builds
+ COLUMN = :job_id
+ TARGET_COLUMN = :id
+ FK_NAME = :fk_rails_fbf3b34792
+
+ def up
+ with_lock_retries do
+ remove_foreign_key_if_exists(
+ SOURCE_TABLE_NAME,
+ TARGET_TABLE_NAME,
+ name: FK_NAME,
+ reverse_lock_order: true
+ )
+ end
+ end
+
+ def down
+ add_concurrent_foreign_key(
+ SOURCE_TABLE_NAME,
+ TARGET_TABLE_NAME,
+ column: COLUMN,
+ target_column: TARGET_COLUMN,
+ validate: true,
+ reverse_lock_order: true,
+ on_delete: :cascade,
+ name: FK_NAME
+ )
+ end
+end
diff --git a/db/schema_migrations/20230227153231 b/db/schema_migrations/20230227153231
new file mode 100644
index 00000000000..18e685b52b0
--- /dev/null
+++ b/db/schema_migrations/20230227153231
@@ -0,0 +1 @@
+a4ae1dd4a14b977302c61d0731e9d350fbdc089a909ca3151fb4b9699b0efbb8 \ No newline at end of file
diff --git a/db/schema_migrations/20230227153232 b/db/schema_migrations/20230227153232
new file mode 100644
index 00000000000..c605a0f5754
--- /dev/null
+++ b/db/schema_migrations/20230227153232
@@ -0,0 +1 @@
+a9082aa6b8cb86be9534fe41db5790b6cca876e6fcc284daf8e5b3163b92bd06 \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index 78adedc12eb..3521a31e04d 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -36626,10 +36626,7 @@ ALTER TABLE ONLY serverless_domain_cluster
ADD CONSTRAINT fk_rails_fbdba67eb1 FOREIGN KEY (creator_id) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE ONLY ci_job_variables
- ADD CONSTRAINT fk_rails_fbf3b34792 FOREIGN KEY (job_id) REFERENCES ci_builds(id) ON DELETE CASCADE;
-
-ALTER TABLE ONLY ci_job_variables
- ADD CONSTRAINT fk_rails_fbf3b34792_p FOREIGN KEY (partition_id, job_id) REFERENCES ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID;
+ ADD CONSTRAINT fk_rails_fbf3b34792_p FOREIGN KEY (partition_id, job_id) REFERENCES ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY packages_nuget_metadata
ADD CONSTRAINT fk_rails_fc0c19f5b4 FOREIGN KEY (package_id) REFERENCES packages_packages(id) ON DELETE CASCADE;