diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-14 21:08:38 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-14 21:08:38 +0300 |
commit | 14160fad80415337f8c08755af53ee994b4a7518 (patch) | |
tree | bfe1bf6bad8cda3e3bbf905c9d8ac742420dd8a3 /db | |
parent | 7a33080fff9a735cbe77968d67b13ffa92c0ffae (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
13 files changed, 221 insertions, 0 deletions
diff --git a/db/migrate/20230608195429_redo_remove_create_learn_gitlab_worker_job_instances.rb b/db/migrate/20230608195429_redo_remove_create_learn_gitlab_worker_job_instances.rb new file mode 100644 index 00000000000..925af31398d --- /dev/null +++ b/db/migrate/20230608195429_redo_remove_create_learn_gitlab_worker_job_instances.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class RedoRemoveCreateLearnGitlabWorkerJobInstances < Gitlab::Database::Migration[2.1] + DEPRECATED_JOB_CLASSES = %w[Onboarding::CreateLearnGitlabWorker] + + disable_ddl_transaction! + + def up + sidekiq_remove_jobs(job_klasses: DEPRECATED_JOB_CLASSES) + end + + def down + # This migration removes any instances of deprecated workers and cannot be undone. + end +end diff --git a/db/post_migrate/20230612075608_replace_ci_job_artifacts_foreign_key_v2.rb b/db/post_migrate/20230612075608_replace_ci_job_artifacts_foreign_key_v2.rb new file mode 100644 index 00000000000..34a77316f6b --- /dev/null +++ b/db/post_migrate/20230612075608_replace_ci_job_artifacts_foreign_key_v2.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +class ReplaceCiJobArtifactsForeignKeyV2 < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum + + disable_ddl_transaction! + + def up + return unless should_run? + + add_concurrent_foreign_key :ci_job_artifacts, :p_ci_builds, + name: 'temp_fk_rails_c5137cb2c1_p', + column: [:partition_id, :job_id], + target_column: [:partition_id, :id], + on_update: :cascade, + on_delete: :cascade, + validate: false, + reverse_lock_order: true + + prepare_async_foreign_key_validation :ci_job_artifacts, + name: 'temp_fk_rails_c5137cb2c1_p' + end + + def down + return unless should_run? + + unprepare_async_foreign_key_validation :ci_job_artifacts, name: 'temp_fk_rails_c5137cb2c1_p' + remove_foreign_key_if_exists :ci_job_artifacts, name: 'temp_fk_rails_c5137cb2c1_p' + end + + private + + def should_run? + can_execute_on?(:ci_job_artifacts, :ci_builds) + end +end diff --git a/db/post_migrate/20230612083337_replace_ci_running_builds_foreign_key_v2.rb b/db/post_migrate/20230612083337_replace_ci_running_builds_foreign_key_v2.rb new file mode 100644 index 00000000000..f8abe274610 --- /dev/null +++ b/db/post_migrate/20230612083337_replace_ci_running_builds_foreign_key_v2.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +class ReplaceCiRunningBuildsForeignKeyV2 < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum + + disable_ddl_transaction! + + def up + return unless should_run? + + add_concurrent_foreign_key :ci_running_builds, :p_ci_builds, + name: 'temp_fk_rails_da45cfa165_p', + column: [:partition_id, :build_id], + target_column: [:partition_id, :id], + on_update: :cascade, + on_delete: :cascade, + validate: false, + reverse_lock_order: true + + prepare_async_foreign_key_validation :ci_running_builds, + name: 'temp_fk_rails_da45cfa165_p' + end + + def down + return unless should_run? + + unprepare_async_foreign_key_validation :ci_running_builds, name: 'temp_fk_rails_da45cfa165_p' + remove_foreign_key_if_exists :ci_running_builds, name: 'temp_fk_rails_da45cfa165_p' + end + + private + + def should_run? + can_execute_on?(:ci_running_builds, :ci_builds) + end +end diff --git a/db/post_migrate/20230612083655_replace_ci_job_variables_foreign_key_v2.rb b/db/post_migrate/20230612083655_replace_ci_job_variables_foreign_key_v2.rb new file mode 100644 index 00000000000..df3593c5304 --- /dev/null +++ b/db/post_migrate/20230612083655_replace_ci_job_variables_foreign_key_v2.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +class ReplaceCiJobVariablesForeignKeyV2 < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum + + disable_ddl_transaction! + + def up + return unless should_run? + + add_concurrent_foreign_key :ci_job_variables, :p_ci_builds, + name: 'temp_fk_rails_fbf3b34792_p', + column: [:partition_id, :job_id], + target_column: [:partition_id, :id], + on_update: :cascade, + on_delete: :cascade, + validate: false, + reverse_lock_order: true + + prepare_async_foreign_key_validation :ci_job_variables, + name: 'temp_fk_rails_fbf3b34792_p' + end + + def down + return unless should_run? + + unprepare_async_foreign_key_validation :ci_job_variables, name: 'temp_fk_rails_fbf3b34792_p' + remove_foreign_key_if_exists :ci_job_variables, name: 'temp_fk_rails_fbf3b34792_p' + end + + private + + def should_run? + can_execute_on?(:ci_job_variables, :ci_builds) + end +end diff --git a/db/post_migrate/20230612083810_replace_p_ci_builds_metadata_foreign_key_v2.rb b/db/post_migrate/20230612083810_replace_p_ci_builds_metadata_foreign_key_v2.rb new file mode 100644 index 00000000000..c97dd22eee1 --- /dev/null +++ b/db/post_migrate/20230612083810_replace_p_ci_builds_metadata_foreign_key_v2.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +class ReplacePCiBuildsMetadataForeignKeyV2 < Gitlab::Database::Migration[2.1] + include Gitlab::Database::PartitioningMigrationHelpers + include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum + + disable_ddl_transaction! + + def up + return unless should_run? + + add_concurrent_partitioned_foreign_key :p_ci_builds_metadata, :p_ci_builds, + name: 'temp_fk_e20479742e_p', + column: [:partition_id, :build_id], + target_column: [:partition_id, :id], + on_update: :cascade, + on_delete: :cascade, + validate: false, + reverse_lock_order: true + + prepare_partitioned_async_foreign_key_validation :p_ci_builds_metadata, + name: 'temp_fk_e20479742e_p' + end + + def down + return unless should_run? + + unprepare_partitioned_async_foreign_key_validation :p_ci_builds_metadata, name: 'temp_fk_e20479742e_p' + + Gitlab::Database::PostgresPartitionedTable.each_partition(:p_ci_builds_metadata) do |partition| + execute "ALTER TABLE #{partition.identifier} DROP CONSTRAINT IF EXISTS temp_fk_e20479742e_p" + end + end + + private + + def should_run? + can_execute_on?(:ci_builds_metadata, :ci_builds) + end +end diff --git a/db/post_migrate/20230612084013_replace_p_ci_runner_machine_builds_foreign_key_v2.rb b/db/post_migrate/20230612084013_replace_p_ci_runner_machine_builds_foreign_key_v2.rb new file mode 100644 index 00000000000..dbbf7263d87 --- /dev/null +++ b/db/post_migrate/20230612084013_replace_p_ci_runner_machine_builds_foreign_key_v2.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +class ReplacePCiRunnerMachineBuildsForeignKeyV2 < Gitlab::Database::Migration[2.1] + include Gitlab::Database::PartitioningMigrationHelpers + include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum + + disable_ddl_transaction! + + def up + return unless should_run? + + add_concurrent_partitioned_foreign_key :p_ci_runner_machine_builds, :p_ci_builds, + name: 'temp_fk_bb490f12fe_p', + column: [:partition_id, :build_id], + target_column: [:partition_id, :id], + on_update: :cascade, + on_delete: :cascade, + validate: false, + reverse_lock_order: true + + prepare_partitioned_async_foreign_key_validation :p_ci_runner_machine_builds, + name: 'temp_fk_bb490f12fe_p' + end + + def down + return unless should_run? + + unprepare_partitioned_async_foreign_key_validation :p_ci_runner_machine_builds, name: 'temp_fk_bb490f12fe_p' + + Gitlab::Database::PostgresPartitionedTable.each_partition(:p_ci_runner_machine_builds) do |partition| + execute "ALTER TABLE #{partition.identifier} DROP CONSTRAINT IF EXISTS temp_fk_bb490f12fe_p" + end + end + + private + + def should_run? + can_execute_on?(:ci_builds) + end +end diff --git a/db/schema_migrations/20230608195429 b/db/schema_migrations/20230608195429 new file mode 100644 index 00000000000..98160bb833a --- /dev/null +++ b/db/schema_migrations/20230608195429 @@ -0,0 +1 @@ +d197bce429eac614d825a6e4a21d302b426dd17221e5fb0eb09a7bb39f140679
\ No newline at end of file diff --git a/db/schema_migrations/20230612075608 b/db/schema_migrations/20230612075608 new file mode 100644 index 00000000000..ec86690f7c9 --- /dev/null +++ b/db/schema_migrations/20230612075608 @@ -0,0 +1 @@ +c1bd88e757c7c08d340066201e3cba4fe23c1d0e78b7a4fbca0e7c9d87df802e
\ No newline at end of file diff --git a/db/schema_migrations/20230612083337 b/db/schema_migrations/20230612083337 new file mode 100644 index 00000000000..928a485a27c --- /dev/null +++ b/db/schema_migrations/20230612083337 @@ -0,0 +1 @@ +21ad4cb522f5a7bb8f4d5883be0d195968206af01051bc4288d287dc15e87572
\ No newline at end of file diff --git a/db/schema_migrations/20230612083655 b/db/schema_migrations/20230612083655 new file mode 100644 index 00000000000..2e9f6e55c2a --- /dev/null +++ b/db/schema_migrations/20230612083655 @@ -0,0 +1 @@ +dbe7656846b46a8e4e7c4b4d04ae034d08eb35b7bad1b530e428c2725542fe43
\ No newline at end of file diff --git a/db/schema_migrations/20230612083810 b/db/schema_migrations/20230612083810 new file mode 100644 index 00000000000..c5bffbc4d26 --- /dev/null +++ b/db/schema_migrations/20230612083810 @@ -0,0 +1 @@ +fe353050a5b4e9650e5ba4985668958032ac105c9cff86d75c974e567bfe9074
\ No newline at end of file diff --git a/db/schema_migrations/20230612084013 b/db/schema_migrations/20230612084013 new file mode 100644 index 00000000000..078054b88a3 --- /dev/null +++ b/db/schema_migrations/20230612084013 @@ -0,0 +1 @@ +3c03bbb4082c8b0e42197a4bc9ad80aa3dcfa09d8e183fdaa503278ec5db79be
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 13f9521fd6f..af7b399cfeb 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -37973,6 +37973,9 @@ ALTER TABLE ONLY ci_sources_pipelines ALTER TABLE ONLY ci_resources ADD CONSTRAINT temp_fk_e169a8e3d5_p FOREIGN KEY (partition_id, build_id) REFERENCES p_ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE SET NULL; +ALTER TABLE ONLY ci_builds_metadata + ADD CONSTRAINT temp_fk_e20479742e_p FOREIGN KEY (partition_id, build_id) REFERENCES p_ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID; + ALTER TABLE ONLY ci_build_report_results ADD CONSTRAINT temp_fk_rails_16cb1ff064_p FOREIGN KEY (partition_id, build_id) REFERENCES p_ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE; @@ -37988,6 +37991,15 @@ ALTER TABLE ONLY ci_pending_builds ALTER TABLE ONLY ci_build_trace_metadata ADD CONSTRAINT temp_fk_rails_aebc78111f_p FOREIGN KEY (partition_id, build_id) REFERENCES p_ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY ci_job_artifacts + ADD CONSTRAINT temp_fk_rails_c5137cb2c1_p FOREIGN KEY (partition_id, job_id) REFERENCES p_ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID; + +ALTER TABLE ONLY ci_running_builds + ADD CONSTRAINT temp_fk_rails_da45cfa165_p FOREIGN KEY (partition_id, build_id) REFERENCES p_ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID; + +ALTER TABLE ONLY ci_job_variables + ADD CONSTRAINT temp_fk_rails_fbf3b34792_p FOREIGN KEY (partition_id, job_id) REFERENCES p_ci_builds(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID; + ALTER TABLE ONLY user_follow_users ADD CONSTRAINT user_follow_users_followee_id_fkey FOREIGN KEY (followee_id) REFERENCES users(id) ON DELETE CASCADE; |