diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-28 12:11:31 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-28 12:11:31 +0000 |
commit | 2ebd699ede8f213f6e8f21ba7d1d9904197b2984 (patch) | |
tree | ea8a020f8bc1ffce42e95f76629c72c59e94a7be /db | |
parent | 25788905108838d95a62d7e3ad3ca16e6f6d0fda (diff) | |
download | gitlab-ce-2ebd699ede8f213f6e8f21ba7d1d9904197b2984.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
17 files changed, 54 insertions, 25 deletions
diff --git a/db/migrate/20210305031822_create_dast_site_profile_variables.rb b/db/migrate/20210305031822_create_dast_site_profile_variables.rb index f55755aa731..4b8fc982d86 100644 --- a/db/migrate/20210305031822_create_dast_site_profile_variables.rb +++ b/db/migrate/20210305031822_create_dast_site_profile_variables.rb @@ -13,7 +13,7 @@ class CreateDastSiteProfileVariables < ActiveRecord::Migration[6.0] encrypted_value_constraint_name = check_constraint_name(:dast_site_profile_secret_variables, 'encrypted_value', 'max_length') encrypted_value_iv_constraint_name = check_constraint_name(:dast_site_profile_secret_variables, 'encrypted_value_iv', 'max_length') - create_table_with_constraints :dast_site_profile_secret_variables, comment: table_comment.to_json do |t| + create_table_with_constraints :dast_site_profile_secret_variables, comment: Gitlab::Json.dump(table_comment) do |t| t.references :dast_site_profile, null: false, foreign_key: { on_delete: :cascade }, index: false t.timestamps_with_timezone diff --git a/db/migrate/20210317035357_create_dast_profiles_pipelines.rb b/db/migrate/20210317035357_create_dast_profiles_pipelines.rb index f7a29958f12..f84e1237643 100644 --- a/db/migrate/20210317035357_create_dast_profiles_pipelines.rb +++ b/db/migrate/20210317035357_create_dast_profiles_pipelines.rb @@ -6,7 +6,7 @@ class CreateDastProfilesPipelines < ActiveRecord::Migration[6.0] def up table_comment = { owner: 'group::dynamic analysis', description: 'Join table between DAST Profiles and CI Pipelines' } - create_table :dast_profiles_pipelines, primary_key: [:dast_profile_id, :ci_pipeline_id], comment: table_comment.to_json do |t| + create_table :dast_profiles_pipelines, primary_key: [:dast_profile_id, :ci_pipeline_id], comment: Gitlab::Json.dump(table_comment) do |t| t.bigint :dast_profile_id, null: false t.bigint :ci_pipeline_id, null: false diff --git a/db/migrate/20210412111213_create_security_orchestration_policy_rule_schedule.rb b/db/migrate/20210412111213_create_security_orchestration_policy_rule_schedule.rb index c7035400cba..365fa36f11b 100644 --- a/db/migrate/20210412111213_create_security_orchestration_policy_rule_schedule.rb +++ b/db/migrate/20210412111213_create_security_orchestration_policy_rule_schedule.rb @@ -11,7 +11,7 @@ class CreateSecurityOrchestrationPolicyRuleSchedule < ActiveRecord::Migration[6. def up table_comment = { owner: 'group::container security', description: 'Schedules used to store relationship between project and security policy repository' } - create_table_with_constraints :security_orchestration_policy_rule_schedules, comment: table_comment.to_json do |t| + create_table_with_constraints :security_orchestration_policy_rule_schedules, comment: Gitlab::Json.dump(table_comment) do |t| t.timestamps_with_timezone t.datetime_with_timezone :next_run_at, null: true diff --git a/db/migrate/20210423054022_create_dast_site_profiles_pipelines.rb b/db/migrate/20210423054022_create_dast_site_profiles_pipelines.rb index bbdb4f02ab4..80b97ff5afe 100644 --- a/db/migrate/20210423054022_create_dast_site_profiles_pipelines.rb +++ b/db/migrate/20210423054022_create_dast_site_profiles_pipelines.rb @@ -4,7 +4,7 @@ class CreateDastSiteProfilesPipelines < ActiveRecord::Migration[6.0] def up table_comment = { owner: 'group::dynamic analysis', description: 'Join table between DAST Site Profiles and CI Pipelines' } - create_table :dast_site_profiles_pipelines, primary_key: [:dast_site_profile_id, :ci_pipeline_id], comment: table_comment.to_json do |t| + create_table :dast_site_profiles_pipelines, primary_key: [:dast_site_profile_id, :ci_pipeline_id], comment: Gitlab::Json.dump(table_comment) do |t| t.bigint :dast_site_profile_id, null: false t.bigint :ci_pipeline_id, null: false diff --git a/db/migrate/20210604032738_create_dast_site_profiles_builds.rb b/db/migrate/20210604032738_create_dast_site_profiles_builds.rb index 2e9eb2c7cb7..6e653b36787 100644 --- a/db/migrate/20210604032738_create_dast_site_profiles_builds.rb +++ b/db/migrate/20210604032738_create_dast_site_profiles_builds.rb @@ -4,7 +4,7 @@ class CreateDastSiteProfilesBuilds < ActiveRecord::Migration[6.1] def up table_comment = { owner: 'group::dynamic analysis', description: 'Join table between DAST Site Profiles and CI Builds' } - create_table :dast_site_profiles_builds, primary_key: [:dast_site_profile_id, :ci_build_id], comment: table_comment.to_json do |t| + create_table :dast_site_profiles_builds, primary_key: [:dast_site_profile_id, :ci_build_id], comment: Gitlab::Json.dump(table_comment) do |t| t.bigint :dast_site_profile_id, null: false t.bigint :ci_build_id, null: false diff --git a/db/migrate/20210604051330_create_dast_scanner_profiles_builds.rb b/db/migrate/20210604051330_create_dast_scanner_profiles_builds.rb index f8a5f735f0d..0fe3ada4c0d 100644 --- a/db/migrate/20210604051330_create_dast_scanner_profiles_builds.rb +++ b/db/migrate/20210604051330_create_dast_scanner_profiles_builds.rb @@ -4,7 +4,7 @@ class CreateDastScannerProfilesBuilds < ActiveRecord::Migration[6.1] def up table_comment = { owner: 'group::dynamic analysis', description: 'Join table between DAST Scanner Profiles and CI Builds' } - create_table :dast_scanner_profiles_builds, primary_key: [:dast_scanner_profile_id, :ci_build_id], comment: table_comment.to_json do |t| + create_table :dast_scanner_profiles_builds, primary_key: [:dast_scanner_profile_id, :ci_build_id], comment: Gitlab::Json.dump(table_comment) do |t| t.bigint :dast_scanner_profile_id, null: false t.bigint :ci_build_id, null: false diff --git a/db/migrate/20210713123345_create_dast_profile_schedule.rb b/db/migrate/20210713123345_create_dast_profile_schedule.rb index 951aab63579..ea660de572a 100644 --- a/db/migrate/20210713123345_create_dast_profile_schedule.rb +++ b/db/migrate/20210713123345_create_dast_profile_schedule.rb @@ -10,7 +10,7 @@ class CreateDastProfileSchedule < ActiveRecord::Migration[6.1] owner: 'group::dynamic analysis', description: 'Scheduling for scans using DAST Profiles' } - create_table_with_constraints :dast_profile_schedules, comment: table_comment.to_json do |t| + create_table_with_constraints :dast_profile_schedules, comment: Gitlab::Json.dump(table_comment) do |t| t.bigint :project_id, null: false t.bigint :dast_profile_id, null: false t.bigint :user_id diff --git a/db/post_migrate/20210311120155_backfill_events_id_for_bigint_conversion.rb b/db/post_migrate/20210311120155_backfill_events_id_for_bigint_conversion.rb index b9427f7cc93..5d31cdb05e6 100644 --- a/db/post_migrate/20210311120155_backfill_events_id_for_bigint_conversion.rb +++ b/db/post_migrate/20210311120155_backfill_events_id_for_bigint_conversion.rb @@ -19,7 +19,7 @@ class BackfillEventsIdForBigintConversion < ActiveRecord::Migration[6.0] Gitlab::Database::BackgroundMigration::BatchedMigration .where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob') .where(table_name: 'events', column_name: 'id') - .where(job_arguments: %w[id id_convert_to_bigint].to_json) + .where(job_arguments: Gitlab::Json.dump(%w[id id_convert_to_bigint])) .delete_all end diff --git a/db/post_migrate/20210311120156_backfill_push_event_payload_event_id_for_bigint_conversion.rb b/db/post_migrate/20210311120156_backfill_push_event_payload_event_id_for_bigint_conversion.rb index 0d610f1dde1..b64282fe0d3 100644 --- a/db/post_migrate/20210311120156_backfill_push_event_payload_event_id_for_bigint_conversion.rb +++ b/db/post_migrate/20210311120156_backfill_push_event_payload_event_id_for_bigint_conversion.rb @@ -20,7 +20,7 @@ class BackfillPushEventPayloadEventIdForBigintConversion < ActiveRecord::Migrati Gitlab::Database::BackgroundMigration::BatchedMigration .where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob') .where(table_name: 'push_event_payloads', column_name: 'event_id') - .where(job_arguments: %w[event_id event_id_convert_to_bigint].to_json) + .where(job_arguments: Gitlab::Json.dump(%w[event_id event_id_convert_to_bigint])) .delete_all end diff --git a/db/post_migrate/20210415101228_backfill_ci_build_needs_for_bigint_conversion.rb b/db/post_migrate/20210415101228_backfill_ci_build_needs_for_bigint_conversion.rb index 1ee67cd9dda..8fcaeb3fb04 100644 --- a/db/post_migrate/20210415101228_backfill_ci_build_needs_for_bigint_conversion.rb +++ b/db/post_migrate/20210415101228_backfill_ci_build_needs_for_bigint_conversion.rb @@ -20,7 +20,7 @@ class BackfillCiBuildNeedsForBigintConversion < ActiveRecord::Migration[6.0] Gitlab::Database::BackgroundMigration::BatchedMigration .where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob') .where(table_name: 'ci_build_needs', column_name: 'build_id') - .where(job_arguments: %w[build_id build_id_convert_to_bigint].to_json) + .where(job_arguments: Gitlab::Json.dump(%w[build_id build_id_convert_to_bigint])) .delete_all end diff --git a/db/post_migrate/20210420121149_backfill_conversion_of_ci_job_artifacts.rb b/db/post_migrate/20210420121149_backfill_conversion_of_ci_job_artifacts.rb index 67076cc647a..0c68834f723 100644 --- a/db/post_migrate/20210420121149_backfill_conversion_of_ci_job_artifacts.rb +++ b/db/post_migrate/20210420121149_backfill_conversion_of_ci_job_artifacts.rb @@ -19,7 +19,7 @@ class BackfillConversionOfCiJobArtifacts < ActiveRecord::Migration[6.0] Gitlab::Database::BackgroundMigration::BatchedMigration .where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob') .where(table_name: 'ci_job_artifacts', column_name: 'id') - .where(job_arguments: [%w[id job_id], %w[id_convert_to_bigint job_id_convert_to_bigint]].to_json) + .where(job_arguments: Gitlab::Json.dump([%w[id job_id], %w[id_convert_to_bigint job_id_convert_to_bigint]])) .delete_all end diff --git a/db/post_migrate/20210422023046_backfill_ci_sources_pipelines_source_job_id_for_bigint_conversion.rb b/db/post_migrate/20210422023046_backfill_ci_sources_pipelines_source_job_id_for_bigint_conversion.rb index bde91473ee3..3c6f2385f1d 100644 --- a/db/post_migrate/20210422023046_backfill_ci_sources_pipelines_source_job_id_for_bigint_conversion.rb +++ b/db/post_migrate/20210422023046_backfill_ci_sources_pipelines_source_job_id_for_bigint_conversion.rb @@ -18,7 +18,7 @@ class BackfillCiSourcesPipelinesSourceJobIdForBigintConversion < ActiveRecord::M Gitlab::Database::BackgroundMigration::BatchedMigration .where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob') .where(table_name: 'ci_sources_pipelines', column_name: 'id') - .where(job_arguments: [%w[source_job_id], %w[source_job_id_convert_to_bigint]].to_json) + .where(job_arguments: Gitlab::Json.dump([%w[source_job_id], %w[source_job_id_convert_to_bigint]])) .delete_all end diff --git a/db/post_migrate/20210615234935_fix_batched_migrations_old_format_job_arguments.rb b/db/post_migrate/20210615234935_fix_batched_migrations_old_format_job_arguments.rb index 535f7426938..818aea39762 100644 --- a/db/post_migrate/20210615234935_fix_batched_migrations_old_format_job_arguments.rb +++ b/db/post_migrate/20210615234935_fix_batched_migrations_old_format_job_arguments.rb @@ -17,8 +17,8 @@ class FixBatchedMigrationsOldFormatJobArguments < ActiveRecord::Migration[6.1] # rubocop:disable Rails/WhereEquals base_scope - .where('job_arguments = ?', legacy_job_arguments.to_json) - .where('NOT EXISTS (?)', base_scope.select('1').where('job_arguments = ?', current_job_arguments.to_json)) + .where('job_arguments = ?', Gitlab::Json.dump(legacy_job_arguments)) + .where('NOT EXISTS (?)', base_scope.select('1').where('job_arguments = ?', Gitlab::Json.dump(current_job_arguments))) .update_all(job_arguments: current_job_arguments) # rubocop:enable Rails/WhereEquals end diff --git a/db/post_migrate/20221006172302_adjust_task_note_rename_background_migration_values.rb b/db/post_migrate/20221006172302_adjust_task_note_rename_background_migration_values.rb index 2af16fb6d3c..b582b163e2d 100644 --- a/db/post_migrate/20221006172302_adjust_task_note_rename_background_migration_values.rb +++ b/db/post_migrate/20221006172302_adjust_task_note_rename_background_migration_values.rb @@ -20,7 +20,7 @@ class AdjustTaskNoteRenameBackgroundMigrationValues < Gitlab::Database::Migratio scope :for_configuration, ->(job_class_name, table_name, column_name, job_arguments) do where(job_class_name: job_class_name, table_name: table_name, column_name: column_name) - .where("job_arguments = ?", job_arguments.to_json) # rubocop:disable Rails/WhereEquals + .where("job_arguments = ?", Gitlab::Json.dump(job_arguments)) # rubocop:disable Rails/WhereEquals end end diff --git a/db/post_migrate/20221024034228_remove_sprints_project_id_column.rb b/db/post_migrate/20221024034228_remove_sprints_project_id_column.rb new file mode 100644 index 00000000000..e30d6dce497 --- /dev/null +++ b/db/post_migrate/20221024034228_remove_sprints_project_id_column.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +class RemoveSprintsProjectIdColumn < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + DATERANGE_CONSTRAINT_NAME = 'iteration_start_and_due_daterange_project_id_constraint' + + def up + with_lock_retries do + remove_column :sprints, :project_id, :bigint if column_exists?(:sprints, :project_id) + end + end + + def down + with_lock_retries do + add_column :sprints, :project_id, :bigint unless column_exists?(:sprints, :project_id) + end + + with_lock_retries do + next if check_constraint_exists?(:sprints, DATERANGE_CONSTRAINT_NAME) + + execute(<<~SQL) + ALTER TABLE sprints + ADD CONSTRAINT #{DATERANGE_CONSTRAINT_NAME} + EXCLUDE USING gist (project_id WITH =, daterange(start_date, due_date, '[]'::text) WITH &&) + WHERE (project_id IS NOT NULL) + SQL + end + + add_check_constraint(:sprints, + 'project_id <> NULL::bigint AND group_id IS NULL OR group_id <> NULL::bigint AND project_id IS NULL', + 'sprints_must_belong_to_project_or_group') + + add_concurrent_index :sprints, [:project_id, :iid], unique: true, name: 'index_sprints_on_project_id_and_iid' + + add_concurrent_foreign_key :sprints, :projects, column: :project_id, on_delete: :cascade + end +end diff --git a/db/schema_migrations/20221024034228 b/db/schema_migrations/20221024034228 new file mode 100644 index 00000000000..3df637a8198 --- /dev/null +++ b/db/schema_migrations/20221024034228 @@ -0,0 +1 @@ +7f83a1d04357f4f2e1e4ed92e0d9b0041f79d1850b28f41cee45d243e25741f0
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 9d295fb6cb0..bfb0c9b0a24 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -21594,7 +21594,6 @@ CREATE TABLE sprints ( updated_at timestamp with time zone NOT NULL, start_date date, due_date date, - project_id bigint, group_id bigint, iid integer NOT NULL, cached_markdown_version integer, @@ -21605,7 +21604,6 @@ CREATE TABLE sprints ( state_enum smallint DEFAULT 1 NOT NULL, iterations_cadence_id integer, sequence integer, - CONSTRAINT sprints_must_belong_to_project_or_group CHECK ((((project_id <> NULL::bigint) AND (group_id IS NULL)) OR ((group_id <> NULL::bigint) AND (project_id IS NULL)))), CONSTRAINT sprints_title CHECK ((char_length(title) <= 255)) ); @@ -25863,9 +25861,6 @@ ALTER TABLE ONLY issues_self_managed_prometheus_alert_events ALTER TABLE ONLY sprints ADD CONSTRAINT iteration_start_and_due_date_iterations_cadence_id_constraint EXCLUDE USING gist (iterations_cadence_id WITH =, daterange(start_date, due_date, '[]'::text) WITH &&) WHERE ((group_id IS NOT NULL)) DEFERRABLE INITIALLY DEFERRED; -ALTER TABLE ONLY sprints - ADD CONSTRAINT iteration_start_and_due_daterange_project_id_constraint EXCLUDE USING gist (project_id WITH =, daterange(start_date, due_date, '[]'::text) WITH &&) WHERE ((project_id IS NOT NULL)); - ALTER TABLE ONLY iterations_cadences ADD CONSTRAINT iterations_cadences_pkey PRIMARY KEY (id); @@ -30569,8 +30564,6 @@ CREATE INDEX index_sprints_on_due_date ON sprints USING btree (due_date); CREATE INDEX index_sprints_on_group_id ON sprints USING btree (group_id); -CREATE UNIQUE INDEX index_sprints_on_project_id_and_iid ON sprints USING btree (project_id, iid); - CREATE INDEX index_sprints_on_title ON sprints USING btree (title); CREATE INDEX index_sprints_on_title_trigram ON sprints USING gin (title gin_trgm_ops); @@ -33405,9 +33398,6 @@ ALTER TABLE ONLY namespaces ALTER TABLE ONLY fork_networks ADD CONSTRAINT fk_e7b436b2b5 FOREIGN KEY (root_project_id) REFERENCES projects(id) ON DELETE SET NULL; -ALTER TABLE ONLY sprints - ADD CONSTRAINT fk_e8206c9686 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY application_settings ADD CONSTRAINT fk_e8a145f3a7 FOREIGN KEY (instance_administrators_group_id) REFERENCES namespaces(id) ON DELETE SET NULL; |