summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-04-28 00:12:20 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-04-28 00:12:20 +0000
commite74c47fb1bd1c137145e19143b0f77cf420990f4 (patch)
tree1ea75375e2d46a0fcc107c336759454c24a332e4 /db
parente49c47d3bc5603e8e9d6ad40fc7fccae9f885843 (diff)
downloadgitlab-ce-e74c47fb1bd1c137145e19143b0f77cf420990f4.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/docs/batched_background_migrations/backfill_work_item_type_id_for_issues.yml6
-rw-r--r--db/migrate/20230314094210_drop_index_from_webauthn_registrations_on_u2f_registration_id.rb16
-rw-r--r--db/migrate/20230425101542_remove_create_cross_project_pipeline_worker_job_instances.rb7
-rw-r--r--db/post_migrate/20230414150202_add_issues_incident_type_temp_index.rb16
-rw-r--r--db/post_migrate/20230414200202_reschedule_incident_work_item_type_id_backfill.rb48
-rw-r--r--db/schema_migrations/202303140942101
-rw-r--r--db/schema_migrations/202304141502021
-rw-r--r--db/schema_migrations/202304142002021
-rw-r--r--db/structure.sql5
9 files changed, 93 insertions, 8 deletions
diff --git a/db/docs/batched_background_migrations/backfill_work_item_type_id_for_issues.yml b/db/docs/batched_background_migrations/backfill_work_item_type_id_for_issues.yml
new file mode 100644
index 00000000000..01e9fd7528e
--- /dev/null
+++ b/db/docs/batched_background_migrations/backfill_work_item_type_id_for_issues.yml
@@ -0,0 +1,6 @@
+---
+migration_job_name: BackfillWorkItemTypeIdForIssues
+description: Backfills every record in the issues table with the appropriate work_item_type_id
+feature_category: team_planning
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/96591
+milestone: 15.4
diff --git a/db/migrate/20230314094210_drop_index_from_webauthn_registrations_on_u2f_registration_id.rb b/db/migrate/20230314094210_drop_index_from_webauthn_registrations_on_u2f_registration_id.rb
new file mode 100644
index 00000000000..52c661a5f1d
--- /dev/null
+++ b/db/migrate/20230314094210_drop_index_from_webauthn_registrations_on_u2f_registration_id.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class DropIndexFromWebauthnRegistrationsOnU2fRegistrationId < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ remove_foreign_key_if_exists :webauthn_registrations, column: :u2f_registration_id
+ end
+ end
+
+ def down
+ add_concurrent_foreign_key(
+ :webauthn_registrations, :u2f_registrations, column: :u2f_registration_id, on_delete: :cascade)
+ end
+end
diff --git a/db/migrate/20230425101542_remove_create_cross_project_pipeline_worker_job_instances.rb b/db/migrate/20230425101542_remove_create_cross_project_pipeline_worker_job_instances.rb
index 1c45cd88892..cf91b2a52d4 100644
--- a/db/migrate/20230425101542_remove_create_cross_project_pipeline_worker_job_instances.rb
+++ b/db/migrate/20230425101542_remove_create_cross_project_pipeline_worker_job_instances.rb
@@ -1,14 +1,11 @@
# frozen_string_literal: true
class RemoveCreateCrossProjectPipelineWorkerJobInstances < Gitlab::Database::Migration[2.1]
- DEPRECATED_JOB_CLASSES = %w[
- CreateCrossProjectPipelineWorker
- ]
def up
- sidekiq_remove_jobs(job_klasses: DEPRECATED_JOB_CLASSES)
+ # no-op to mitigate https://gitlab.com/gitlab-com/gl-infra/production/-/issues/9566
end
def down
- # This migration removes any instances of deprecated workers and cannot be undone.
+ # no-op to mitigate https://gitlab.com/gitlab-com/gl-infra/production/-/issues/9566
end
end
diff --git a/db/post_migrate/20230414150202_add_issues_incident_type_temp_index.rb b/db/post_migrate/20230414150202_add_issues_incident_type_temp_index.rb
new file mode 100644
index 00000000000..7c89e454c0c
--- /dev/null
+++ b/db/post_migrate/20230414150202_add_issues_incident_type_temp_index.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddIssuesIncidentTypeTempIndex < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'tmp_index_issues_on_issue_type_and_id_only_incidents'
+ INCIDENT_ENUM_VALUE = 1
+
+ def up
+ add_concurrent_index :issues, [:issue_type, :id], name: INDEX_NAME, where: "issue_type = #{INCIDENT_ENUM_VALUE}"
+ end
+
+ def down
+ remove_concurrent_index_by_name :issues, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230414200202_reschedule_incident_work_item_type_id_backfill.rb b/db/post_migrate/20230414200202_reschedule_incident_work_item_type_id_backfill.rb
new file mode 100644
index 00000000000..0563ed93d15
--- /dev/null
+++ b/db/post_migrate/20230414200202_reschedule_incident_work_item_type_id_backfill.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+class RescheduleIncidentWorkItemTypeIdBackfill < Gitlab::Database::Migration[2.1]
+ MIGRATION = 'BackfillWorkItemTypeIdForIssues'
+ BATCH_SIZE = 10_000
+ MAX_BATCH_SIZE = 30_000
+ SUB_BATCH_SIZE = 50
+ INTERVAL = 2.minutes
+ INCIDENT_ENUM_TYPE = 1
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ class MigrationWorkItemType < MigrationRecord
+ self.table_name = 'work_item_types'
+ end
+
+ def up
+ incident_work_item_type = MigrationWorkItemType.find_by(namespace_id: nil, base_type: INCIDENT_ENUM_TYPE)
+
+ if incident_work_item_type.blank?
+ say(
+ 'Incident work item type not found. Make sure the work_item_types table is populated' \
+ 'before running this migration'
+ )
+ return
+ end
+
+ delete_batched_background_migration(MIGRATION, :issues, :id, [INCIDENT_ENUM_TYPE, incident_work_item_type.id])
+
+ queue_batched_background_migration(
+ MIGRATION,
+ :issues,
+ :id,
+ INCIDENT_ENUM_TYPE,
+ incident_work_item_type.id,
+ job_interval: INTERVAL,
+ batch_size: BATCH_SIZE,
+ max_batch_size: MAX_BATCH_SIZE,
+ sub_batch_size: SUB_BATCH_SIZE
+ )
+ end
+
+ def down
+ # no-op
+ # no point on reverting this migration since UP is destructive
+ # (it will delete the originally scheduled job)
+ end
+end
diff --git a/db/schema_migrations/20230314094210 b/db/schema_migrations/20230314094210
new file mode 100644
index 00000000000..ee40a11c6f0
--- /dev/null
+++ b/db/schema_migrations/20230314094210
@@ -0,0 +1 @@
+533c4aec923bdc54c3f3a0656ae47d77e2224be2329a547c5a569e3ff5cedd54 \ No newline at end of file
diff --git a/db/schema_migrations/20230414150202 b/db/schema_migrations/20230414150202
new file mode 100644
index 00000000000..43065106a98
--- /dev/null
+++ b/db/schema_migrations/20230414150202
@@ -0,0 +1 @@
+827358117f7eb0d16f99350186bff641ecf88f37b1cd46551173e3eef76cb474 \ No newline at end of file
diff --git a/db/schema_migrations/20230414200202 b/db/schema_migrations/20230414200202
new file mode 100644
index 00000000000..7a68c986f94
--- /dev/null
+++ b/db/schema_migrations/20230414200202
@@ -0,0 +1 @@
+1e7e465343930dd14d3fa98aeababa836db03e70de81f0bc97bbab46409d2712 \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index 6c51d90b0bc..7b98c9ceebc 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -33067,6 +33067,8 @@ CREATE INDEX tmp_index_for_null_member_namespace_id ON members USING btree (memb
CREATE INDEX tmp_index_for_project_namespace_id_migration_on_routes ON routes USING btree (id) WHERE ((namespace_id IS NULL) AND ((source_type)::text = 'Project'::text));
+CREATE INDEX tmp_index_issues_on_issue_type_and_id_only_incidents ON issues USING btree (issue_type, id) WHERE (issue_type = 1);
+
CREATE INDEX tmp_index_members_on_state ON members USING btree (state) WHERE (state = 2);
CREATE INDEX tmp_index_migrated_container_registries ON container_repositories USING btree (project_id) WHERE ((migration_state = 'import_done'::text) OR (created_at >= '2022-01-23 00:00:00'::timestamp without time zone));
@@ -34592,9 +34594,6 @@ ALTER TABLE ONLY vulnerabilities
ALTER TABLE ONLY vulnerabilities
ADD CONSTRAINT fk_131d289c65 FOREIGN KEY (milestone_id) REFERENCES milestones(id) ON DELETE SET NULL;
-ALTER TABLE ONLY webauthn_registrations
- ADD CONSTRAINT fk_13e04d719a FOREIGN KEY (u2f_registration_id) REFERENCES u2f_registrations(id) ON DELETE CASCADE;
-
ALTER TABLE ONLY sbom_occurrences
ADD CONSTRAINT fk_157506c0e2 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;