diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-14 03:08:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-14 03:08:10 +0300 |
commit | c77ea1f6860ba657eefd5a06e46db8d212b21f08 (patch) | |
tree | 9330894c4c318e04a71f38ce85c82d3a23192fcb /db | |
parent | 04cc87ee46c1c0b6b4eb7df964b3115dd2578877 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
10 files changed, 61 insertions, 97 deletions
diff --git a/db/fixtures/development/002_default_organization.rb b/db/fixtures/development/002_default_organization.rb new file mode 100644 index 00000000000..774e3742c8b --- /dev/null +++ b/db/fixtures/development/002_default_organization.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +Gitlab::Seeder.quiet do + Gitlab::DatabaseImporters::DefaultOrganizationImporter.create_default_organization +end diff --git a/db/fixtures/production/030_default_organization.rb b/db/fixtures/production/030_default_organization.rb new file mode 100644 index 00000000000..774e3742c8b --- /dev/null +++ b/db/fixtures/production/030_default_organization.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +Gitlab::Seeder.quiet do + Gitlab::DatabaseImporters::DefaultOrganizationImporter.create_default_organization +end diff --git a/db/migrate/20230605095810_ensure_default_organization.rb b/db/migrate/20230605095810_ensure_default_organization.rb new file mode 100644 index 00000000000..526e12077df --- /dev/null +++ b/db/migrate/20230605095810_ensure_default_organization.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +class EnsureDefaultOrganization < Gitlab::Database::Migration[2.1] + restrict_gitlab_migration gitlab_schema: :gitlab_main + + disable_ddl_transaction! + + class Organization < MigrationRecord + end + + def up + return if Organization.exists?(id: 1) + + path = 'default' + + retries = 0 + + begin + Organization.create(id: 1, name: 'Default', path: path) + rescue ActiveRecord::RecordNotUnique + retries += 1 + path = "default-#{SecureRandom.hex(3)}" + retry if retries < 10_000 + end + end + + def down + Organization.where(id: 1).delete_all + end +end diff --git a/db/post_migrate/20230524135750_replace_ci_job_artifacts_foreign_key.rb b/db/post_migrate/20230524135750_replace_ci_job_artifacts_foreign_key.rb index 8bd4dadc891..48c07bceb6a 100644 --- a/db/post_migrate/20230524135750_replace_ci_job_artifacts_foreign_key.rb +++ b/db/post_migrate/20230524135750_replace_ci_job_artifacts_foreign_key.rb @@ -1,24 +1,13 @@ # frozen_string_literal: true class ReplaceCiJobArtifactsForeignKey < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - def up - 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' + # This migration was skipped in the ci database on gitlab.com as part of + # https://gitlab.com/gitlab-com/gl-infra/production/-/issues/14888 end def down - unprepare_async_foreign_key_validation :ci_job_artifacts, name: 'temp_fk_rails_c5137cb2c1_p' - remove_foreign_key :ci_job_artifacts, name: 'temp_fk_rails_c5137cb2c1_p' + # This migration was skipped in the ci database on gitlab.com as part of + # https://gitlab.com/gitlab-com/gl-infra/production/-/issues/14888 end end diff --git a/db/post_migrate/20230524135803_replace_ci_running_builds_foreign_key.rb b/db/post_migrate/20230524135803_replace_ci_running_builds_foreign_key.rb index 0e2d2bd34d0..5d3807242ef 100644 --- a/db/post_migrate/20230524135803_replace_ci_running_builds_foreign_key.rb +++ b/db/post_migrate/20230524135803_replace_ci_running_builds_foreign_key.rb @@ -1,24 +1,13 @@ # frozen_string_literal: true class ReplaceCiRunningBuildsForeignKey < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - def up - 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' + # This migration was skipped in the ci database on gitlab.com as part of + # https://gitlab.com/gitlab-com/gl-infra/production/-/issues/14888 end def down - unprepare_async_foreign_key_validation :ci_running_builds, name: 'temp_fk_rails_da45cfa165_p' - remove_foreign_key :ci_running_builds, name: 'temp_fk_rails_da45cfa165_p' + # This migration was skipped in the ci database on gitlab.com as part of + # https://gitlab.com/gitlab-com/gl-infra/production/-/issues/14888 end end diff --git a/db/post_migrate/20230524135815_replace_ci_job_variables_foreign_key.rb b/db/post_migrate/20230524135815_replace_ci_job_variables_foreign_key.rb index c846c7f437c..baac0d495a7 100644 --- a/db/post_migrate/20230524135815_replace_ci_job_variables_foreign_key.rb +++ b/db/post_migrate/20230524135815_replace_ci_job_variables_foreign_key.rb @@ -1,24 +1,13 @@ # frozen_string_literal: true class ReplaceCiJobVariablesForeignKey < Gitlab::Database::Migration[2.1] - disable_ddl_transaction! - def up - 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' + # This migration was skipped in the ci database on gitlab.com as part of + # https://gitlab.com/gitlab-com/gl-infra/production/-/issues/14888 end def down - unprepare_async_foreign_key_validation :ci_job_variables, name: 'temp_fk_rails_fbf3b34792_p' - remove_foreign_key :ci_job_variables, name: 'temp_fk_rails_fbf3b34792_p' + # This migration was skipped in the ci database on gitlab.com as part of + # https://gitlab.com/gitlab-com/gl-infra/production/-/issues/14888 end end diff --git a/db/post_migrate/20230524135828_replace_p_ci_builds_metadata_foreign_key.rb b/db/post_migrate/20230524135828_replace_p_ci_builds_metadata_foreign_key.rb index 6ad2a932a3a..c398b457978 100644 --- a/db/post_migrate/20230524135828_replace_p_ci_builds_metadata_foreign_key.rb +++ b/db/post_migrate/20230524135828_replace_p_ci_builds_metadata_foreign_key.rb @@ -1,29 +1,13 @@ # frozen_string_literal: true class ReplacePCiBuildsMetadataForeignKey < Gitlab::Database::Migration[2.1] - include Gitlab::Database::PartitioningMigrationHelpers - - disable_ddl_transaction! - def up - 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' + # This migration was skipped in the ci database on gitlab.com as part of + # https://gitlab.com/gitlab-com/gl-infra/production/-/issues/14888 end def down - 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 + # This migration was skipped in the ci database on gitlab.com as part of + # https://gitlab.com/gitlab-com/gl-infra/production/-/issues/14888 end end diff --git a/db/post_migrate/20230524135840_replace_p_ci_runner_machine_builds_foreign_key.rb b/db/post_migrate/20230524135840_replace_p_ci_runner_machine_builds_foreign_key.rb index 7ac4b79d0db..bc9d534ec1f 100644 --- a/db/post_migrate/20230524135840_replace_p_ci_runner_machine_builds_foreign_key.rb +++ b/db/post_migrate/20230524135840_replace_p_ci_runner_machine_builds_foreign_key.rb @@ -1,29 +1,13 @@ # frozen_string_literal: true class ReplacePCiRunnerMachineBuildsForeignKey < Gitlab::Database::Migration[2.1] - include Gitlab::Database::PartitioningMigrationHelpers - - disable_ddl_transaction! - def up - 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' + # This migration was skipped in the ci database on gitlab.com as part of + # https://gitlab.com/gitlab-com/gl-infra/production/-/issues/14888 end def down - 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 + # This migration was skipped in the ci database on gitlab.com as part of + # https://gitlab.com/gitlab-com/gl-infra/production/-/issues/14888 end end diff --git a/db/schema_migrations/20230605095810 b/db/schema_migrations/20230605095810 new file mode 100644 index 00000000000..7d8d7bb7fd5 --- /dev/null +++ b/db/schema_migrations/20230605095810 @@ -0,0 +1 @@ +8703eac92c20c68dc7ff20a94b788e1c5115c2e5b6b665ada428cfa24a5958db
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index a4bbe2033d0..49f27281036 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -37975,9 +37975,6 @@ 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; @@ -37993,15 +37990,6 @@ 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; |