Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-04-05 12:19:15 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-04-05 12:19:15 +0300
commit508f0c4ee719abb1294684eea4a63aa44cd23597 (patch)
tree1af8199669fe0e9086bc57ba91510e80da093ffa /db
parent9a0dd27b634dde1f947beafcf822efef1cd2dcfc (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20230403023828_swap_note_diff_files_note_id_to_bigint_for_gitlab_dot_com.rb68
-rw-r--r--db/post_migrate/20230404044338_drop_async_index_ci_job_artifacts_on_expire_at_for_removal.rb14
-rw-r--r--db/schema_migrations/202304030238281
-rw-r--r--db/schema_migrations/202304040443381
-rw-r--r--db/structure.sql9
5 files changed, 86 insertions, 7 deletions
diff --git a/db/post_migrate/20230403023828_swap_note_diff_files_note_id_to_bigint_for_gitlab_dot_com.rb b/db/post_migrate/20230403023828_swap_note_diff_files_note_id_to_bigint_for_gitlab_dot_com.rb
new file mode 100644
index 00000000000..6a453722de9
--- /dev/null
+++ b/db/post_migrate/20230403023828_swap_note_diff_files_note_id_to_bigint_for_gitlab_dot_com.rb
@@ -0,0 +1,68 @@
+# frozen_string_literal: true
+
+class SwapNoteDiffFilesNoteIdToBigintForGitlabDotCom < Gitlab::Database::Migration[2.1]
+ include Gitlab::Database::MigrationHelpers::ConvertToBigint
+
+ disable_ddl_transaction!
+
+ TABLE_NAME = 'note_diff_files'
+
+ def up
+ return unless should_run?
+
+ swap
+ end
+
+ def down
+ return unless should_run?
+
+ swap
+
+ add_concurrent_index TABLE_NAME, :diff_note_id_convert_to_bigint, unique: true,
+ name: 'index_note_diff_files_on_diff_note_id_convert_to_bigint'
+
+ add_concurrent_foreign_key TABLE_NAME, :notes, column: :diff_note_id_convert_to_bigint,
+ name: 'fk_note_diff_files_diff_note_id_convert_to_bigint',
+ on_delete: :cascade,
+ validate: false
+ end
+
+ def swap
+ # This will replace the existing index_note_diff_files_on_diff_note_id
+ add_concurrent_index TABLE_NAME, :diff_note_id_convert_to_bigint, unique: true,
+ name: 'index_note_diff_files_on_diff_note_id_convert_to_bigint'
+
+ # This will replace the existing fk_rails_3d66047aeb
+ add_concurrent_foreign_key TABLE_NAME, :notes, column: :diff_note_id_convert_to_bigint,
+ name: 'fk_note_diff_files_diff_note_id_convert_to_bigint',
+ on_delete: :cascade
+
+ with_lock_retries(raise_on_exhaustion: true) do
+ execute "LOCK TABLE notes, #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE"
+
+ execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN diff_note_id TO diff_note_id_tmp"
+ execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN diff_note_id_convert_to_bigint TO diff_note_id"
+ execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN diff_note_id_tmp TO diff_note_id_convert_to_bigint"
+
+ function_name = Gitlab::Database::UnidirectionalCopyTrigger
+ .on_table(TABLE_NAME, connection: connection)
+ .name(:diff_note_id, :diff_note_id_convert_to_bigint)
+ execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL"
+
+ # Swap defaults
+ change_column_default TABLE_NAME, :diff_note_id, nil
+ change_column_default TABLE_NAME, :diff_note_id_convert_to_bigint, 0
+
+ execute 'DROP INDEX IF EXISTS index_note_diff_files_on_diff_note_id'
+ rename_index TABLE_NAME, 'index_note_diff_files_on_diff_note_id_convert_to_bigint',
+ 'index_note_diff_files_on_diff_note_id'
+
+ execute "ALTER TABLE #{TABLE_NAME} DROP CONSTRAINT IF EXISTS fk_rails_3d66047aeb"
+ rename_constraint(TABLE_NAME, 'fk_note_diff_files_diff_note_id_convert_to_bigint', 'fk_rails_3d66047aeb')
+ end
+ end
+
+ def should_run?
+ com_or_dev_or_test_but_not_jh?
+ end
+end
diff --git a/db/post_migrate/20230404044338_drop_async_index_ci_job_artifacts_on_expire_at_for_removal.rb b/db/post_migrate/20230404044338_drop_async_index_ci_job_artifacts_on_expire_at_for_removal.rb
new file mode 100644
index 00000000000..7c3cb65c884
--- /dev/null
+++ b/db/post_migrate/20230404044338_drop_async_index_ci_job_artifacts_on_expire_at_for_removal.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class DropAsyncIndexCiJobArtifactsOnExpireAtForRemoval < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'index_ci_job_artifacts_on_expire_at_for_removal'
+
+ # TODO: Index to be destroyed synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/393913
+ def up
+ prepare_async_index_removal :ci_job_artifacts, :expire_at, name: INDEX_NAME
+ end
+
+ def down
+ unprepare_async_index :ci_job_artifacts, :expire_at, name: INDEX_NAME
+ end
+end
diff --git a/db/schema_migrations/20230403023828 b/db/schema_migrations/20230403023828
new file mode 100644
index 00000000000..60cc18c8eec
--- /dev/null
+++ b/db/schema_migrations/20230403023828
@@ -0,0 +1 @@
+1056fb290b3f5acf11dca0848258494d42c075dc7dc18ca89873d6237fc7104b \ No newline at end of file
diff --git a/db/schema_migrations/20230404044338 b/db/schema_migrations/20230404044338
new file mode 100644
index 00000000000..caa04406a17
--- /dev/null
+++ b/db/schema_migrations/20230404044338
@@ -0,0 +1 @@
+42d91918d6669bb02501657aeac062114ce6ce907baf690ab346e788c57a3324 \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index 89de87610b7..d26046b2788 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -18777,7 +18777,7 @@ ALTER SEQUENCE namespaces_sync_events_id_seq OWNED BY namespaces_sync_events.id;
CREATE TABLE note_diff_files (
id integer NOT NULL,
- diff_note_id integer NOT NULL,
+ diff_note_id_convert_to_bigint integer DEFAULT 0 NOT NULL,
diff text NOT NULL,
new_file boolean NOT NULL,
renamed_file boolean NOT NULL,
@@ -18786,7 +18786,7 @@ CREATE TABLE note_diff_files (
b_mode character varying NOT NULL,
new_path text NOT NULL,
old_path text NOT NULL,
- diff_note_id_convert_to_bigint bigint DEFAULT 0 NOT NULL
+ diff_note_id bigint NOT NULL
);
CREATE SEQUENCE note_diff_files_id_seq
@@ -31240,8 +31240,6 @@ CREATE INDEX index_non_requested_project_members_on_source_id_and_type ON member
CREATE UNIQUE INDEX index_note_diff_files_on_diff_note_id ON note_diff_files USING btree (diff_note_id);
-CREATE UNIQUE INDEX index_note_diff_files_on_diff_note_id_convert_to_bigint ON note_diff_files USING btree (diff_note_id_convert_to_bigint);
-
CREATE INDEX index_notes_for_cherry_picked_merge_requests ON notes USING btree (project_id, commit_id) WHERE ((noteable_type)::text = 'MergeRequest'::text);
CREATE INDEX index_notes_on_author_id_and_created_at_and_id ON notes USING btree (author_id, created_at, id);
@@ -35238,9 +35236,6 @@ ALTER TABLE ONLY ml_candidate_metrics
ALTER TABLE ONLY ml_candidate_params
ADD CONSTRAINT fk_ml_candidate_params_on_candidate_id FOREIGN KEY (candidate_id) REFERENCES ml_candidates(id) ON DELETE CASCADE;
-ALTER TABLE ONLY note_diff_files
- ADD CONSTRAINT fk_note_diff_files_diff_note_id_convert_to_bigint FOREIGN KEY (diff_note_id_convert_to_bigint) REFERENCES notes(id) ON DELETE CASCADE NOT VALID;
-
ALTER TABLE ONLY path_locks
ADD CONSTRAINT fk_path_locks_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;