summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-10 03:09:12 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-10 03:09:12 +0000
commit3591ecba91126089ebf916f9bd95fe497609920c (patch)
tree139e2f7ebdc0e11b62ad1b0e5bfbdf18a6f2ddf2 /db
parent38c1da5195bdcaab0b20bf6303a675b9283ac476 (diff)
downloadgitlab-ce-3591ecba91126089ebf916f9bd95fe497609920c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20230503100753_add_version_format_and_data_type_to_checkpoints.rb19
-rw-r--r--db/post_migrate/20230502102832_schedule_index_to_members_on_source_and_type_and_access_level.rb13
-rw-r--r--db/post_migrate/20230502120021_schedule_index_to_project_authorizations_on_project_user_access_level.rb15
-rw-r--r--db/post_migrate/20230504010535_ensure_notes_bigint_backfill_is_finished_for_gitlab_dot_com.rb29
-rw-r--r--db/post_migrate/20230508034422_notes_bigint_create_indexes_async_for_gitlab_dot_com.rb64
-rw-r--r--db/schema_migrations/202305021028321
-rw-r--r--db/schema_migrations/202305021200211
-rw-r--r--db/schema_migrations/202305031007531
-rw-r--r--db/schema_migrations/202305040105351
-rw-r--r--db/schema_migrations/202305080344221
-rw-r--r--db/structure.sql6
11 files changed, 149 insertions, 2 deletions
diff --git a/db/migrate/20230503100753_add_version_format_and_data_type_to_checkpoints.rb b/db/migrate/20230503100753_add_version_format_and_data_type_to_checkpoints.rb
new file mode 100644
index 00000000000..97a0541cdb5
--- /dev/null
+++ b/db/migrate/20230503100753_add_version_format_and_data_type_to_checkpoints.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddVersionFormatAndDataTypeToCheckpoints < Gitlab::Database::Migration[2.1]
+ enable_lock_retries!
+
+ def up
+ add_column(:pm_checkpoints, :data_type, :integer, limit: 2, default: 1, null: false)
+ add_column(:pm_checkpoints, :version_format, :integer, limit: 2, default: 1, null: false)
+ add_index(:pm_checkpoints, [:purl_type, :data_type, :version_format], unique: true, name: :pm_checkpoints_unique_index) # rubocop:disable Migration/AddIndex
+ swap_primary_key(:pm_checkpoints, :pm_checkpoints_pkey, :pm_checkpoints_unique_index)
+ end
+
+ def down
+ add_index(:pm_checkpoints, [:purl_type], unique: true, name: :pm_checkpoints_unique_index) # rubocop:disable Migration/AddIndex
+ unswap_primary_key(:pm_checkpoints, :pm_checkpoints_pkey, :pm_checkpoints_unique_index)
+ remove_column(:pm_checkpoints, :version_format)
+ remove_column(:pm_checkpoints, :data_type)
+ end
+end
diff --git a/db/post_migrate/20230502102832_schedule_index_to_members_on_source_and_type_and_access_level.rb b/db/post_migrate/20230502102832_schedule_index_to_members_on_source_and_type_and_access_level.rb
new file mode 100644
index 00000000000..ce3f0fb8c76
--- /dev/null
+++ b/db/post_migrate/20230502102832_schedule_index_to_members_on_source_and_type_and_access_level.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class ScheduleIndexToMembersOnSourceAndTypeAndAccessLevel < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'index_members_on_source_and_type_and_access_level'
+
+ def up
+ prepare_async_index :members, %i[source_id source_type type access_level], name: INDEX_NAME
+ end
+
+ def down
+ unprepare_async_index :members, %i[source_id source_type type access_level], name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230502120021_schedule_index_to_project_authorizations_on_project_user_access_level.rb b/db/post_migrate/20230502120021_schedule_index_to_project_authorizations_on_project_user_access_level.rb
new file mode 100644
index 00000000000..06ff40cddde
--- /dev/null
+++ b/db/post_migrate/20230502120021_schedule_index_to_project_authorizations_on_project_user_access_level.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class ScheduleIndexToProjectAuthorizationsOnProjectUserAccessLevel < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'index_project_authorizations_on_project_user_access_level'
+
+ disable_ddl_transaction!
+
+ def up
+ prepare_async_index :project_authorizations, %i[project_id user_id access_level], unique: true, name: INDEX_NAME
+ end
+
+ def down
+ unprepare_async_index :project_authorizations, %i[project_id user_id access_level], name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230504010535_ensure_notes_bigint_backfill_is_finished_for_gitlab_dot_com.rb b/db/post_migrate/20230504010535_ensure_notes_bigint_backfill_is_finished_for_gitlab_dot_com.rb
new file mode 100644
index 00000000000..b9d3dc55661
--- /dev/null
+++ b/db/post_migrate/20230504010535_ensure_notes_bigint_backfill_is_finished_for_gitlab_dot_com.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class EnsureNotesBigintBackfillIsFinishedForGitlabDotCom < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::ConvertToBigint
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+ disable_ddl_transaction!
+
+ def up
+ return unless should_run?
+
+ ensure_batched_background_migration_is_finished(
+ job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
+ table_name: 'notes',
+ column_name: 'id',
+ job_arguments: [['id'], ['id_convert_to_bigint']]
+ )
+ end
+
+ def down
+ # no-op
+ end
+
+ private
+
+ def should_run?
+ com_or_dev_or_test_but_not_jh?
+ end
+end
diff --git a/db/post_migrate/20230508034422_notes_bigint_create_indexes_async_for_gitlab_dot_com.rb b/db/post_migrate/20230508034422_notes_bigint_create_indexes_async_for_gitlab_dot_com.rb
new file mode 100644
index 00000000000..b8e8c995713
--- /dev/null
+++ b/db/post_migrate/20230508034422_notes_bigint_create_indexes_async_for_gitlab_dot_com.rb
@@ -0,0 +1,64 @@
+# frozen_string_literal: true
+
+class NotesBigintCreateIndexesAsyncForGitlabDotCom < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::ConvertToBigint
+
+ TABLE_NAME = 'notes'
+ PK_INDEX_NAME = 'index_notes_on_id_convert_to_bigint'
+
+ SECONDARY_INDEXES = [
+ {
+ name: :index_notes_on_author_id_created_at_id_convert_to_bigint,
+ columns: [:author_id, :created_at, :id_convert_to_bigint],
+ options: {}
+ },
+ {
+ name: :index_notes_on_id_convert_to_bigint_where_confidential,
+ columns: [:id_convert_to_bigint],
+ options: { where: 'confidential = true' }
+ },
+ {
+ name: :index_notes_on_id_convert_to_bigint_where_internal,
+ columns: [:id_convert_to_bigint],
+ options: { where: 'internal = true' }
+ },
+ {
+ name: :index_notes_on_project_id_id_convert_to_bigint_system_false,
+ columns: [:project_id, :id_convert_to_bigint],
+ options: { where: 'NOT system' }
+ },
+ {
+ name: :note_mentions_temp_index_convert_to_bigint,
+ columns: [:id_convert_to_bigint, :noteable_type],
+ options: { where: "note ~~ '%@%'::text" }
+ }
+ ]
+
+ # Indexes will be created synchronously in
+ # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/119705
+ def up
+ return unless should_run?
+
+ prepare_async_index TABLE_NAME, :id_convert_to_bigint, unique: true, name: PK_INDEX_NAME
+
+ SECONDARY_INDEXES.each do |index|
+ prepare_async_index TABLE_NAME, index[:columns], **index[:options].merge(name: index[:name])
+ end
+ end
+
+ def down
+ return unless should_run?
+
+ SECONDARY_INDEXES.each do |index|
+ unprepare_async_index TABLE_NAME, index[:columns], name: index[:name]
+ end
+
+ unprepare_async_index TABLE_NAME, :id_convert_to_bigint, name: PK_INDEX_NAME
+ end
+
+ private
+
+ def should_run?
+ com_or_dev_or_test_but_not_jh?
+ end
+end
diff --git a/db/schema_migrations/20230502102832 b/db/schema_migrations/20230502102832
new file mode 100644
index 00000000000..f82a528e5e3
--- /dev/null
+++ b/db/schema_migrations/20230502102832
@@ -0,0 +1 @@
+7543d5128ef49f1c169e30db24015cd1deae271ed20be29d34e67e6cc4ece372 \ No newline at end of file
diff --git a/db/schema_migrations/20230502120021 b/db/schema_migrations/20230502120021
new file mode 100644
index 00000000000..13d84b077b1
--- /dev/null
+++ b/db/schema_migrations/20230502120021
@@ -0,0 +1 @@
+9602256dc3cea8f0fce716ba341e364ac51e592ff6f71e51c230be2896bcfd49 \ No newline at end of file
diff --git a/db/schema_migrations/20230503100753 b/db/schema_migrations/20230503100753
new file mode 100644
index 00000000000..9dfc04b52ae
--- /dev/null
+++ b/db/schema_migrations/20230503100753
@@ -0,0 +1 @@
+2db1e083151334d1f53d3da97c66a5f9995997a1e9556bb7acd54122b6f765f6 \ No newline at end of file
diff --git a/db/schema_migrations/20230504010535 b/db/schema_migrations/20230504010535
new file mode 100644
index 00000000000..77617d38e85
--- /dev/null
+++ b/db/schema_migrations/20230504010535
@@ -0,0 +1 @@
+68d1cbddace4f53fe437d234f9a9eac2264c88ef4a34353abc11bbbbdccc63c3 \ No newline at end of file
diff --git a/db/schema_migrations/20230508034422 b/db/schema_migrations/20230508034422
new file mode 100644
index 00000000000..e4bce1f0681
--- /dev/null
+++ b/db/schema_migrations/20230508034422
@@ -0,0 +1 @@
+22359f0d7c7f08f2293a0302c36854e78cd6fdf51a555ed36303f56bfc6ee914 \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index db1260e527c..512e27adb6a 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -20122,7 +20122,9 @@ CREATE TABLE pm_checkpoints (
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
purl_type smallint NOT NULL,
- chunk smallint NOT NULL
+ chunk smallint NOT NULL,
+ data_type smallint DEFAULT 1 NOT NULL,
+ version_format smallint DEFAULT 1 NOT NULL
);
CREATE TABLE pm_licenses (
@@ -27699,7 +27701,7 @@ ALTER TABLE ONLY pm_affected_packages
ADD CONSTRAINT pm_affected_packages_pkey PRIMARY KEY (id);
ALTER TABLE ONLY pm_checkpoints
- ADD CONSTRAINT pm_checkpoints_pkey PRIMARY KEY (purl_type);
+ ADD CONSTRAINT pm_checkpoints_pkey PRIMARY KEY (purl_type, data_type, version_format);
ALTER TABLE ONLY pm_licenses
ADD CONSTRAINT pm_licenses_pkey PRIMARY KEY (id);