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-12-22 00:07:34 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-12-22 00:07:34 +0300
commit909dcab6e1f82095408cf4adfe099b463f094301 (patch)
treed8b4ee0cf1a5313b75c7b039ae52b74d03c6bfd6 /db
parentd2f2219fd58e572c10d77183e2f65de8fcc8df96 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/docs/deleted_tables/ci_editor_ai_conversation_messages.yml (renamed from db/docs/ci_editor_ai_conversation_messages.yml)2
-rw-r--r--db/migrate/20231205165049_add_slug_to_topics.rb21
-rw-r--r--db/migrate/20231213065249_deprecate_ci_editor_ai_conversation_related_workers.rb20
-rw-r--r--db/migrate/20231216190018_add_index_topics_on_slug.rb17
-rw-r--r--db/post_migrate/20231207145335_cleanup_group_level_work_items.rb71
-rw-r--r--db/post_migrate/20231207155340_prepare_iid_namespace_unique_index_in_issues.rb16
-rw-r--r--db/post_migrate/20231213064314_remove_ci_editor_ai_conversation_messages_table.rb33
-rw-r--r--db/schema_migrations/202312051650491
-rw-r--r--db/schema_migrations/202312071453351
-rw-r--r--db/schema_migrations/202312071553401
-rw-r--r--db/schema_migrations/202312130643141
-rw-r--r--db/schema_migrations/202312130652491
-rw-r--r--db/schema_migrations/202312161900181
-rw-r--r--db/structure.sql37
14 files changed, 190 insertions, 33 deletions
diff --git a/db/docs/ci_editor_ai_conversation_messages.yml b/db/docs/deleted_tables/ci_editor_ai_conversation_messages.yml
index de4ca6490a6..e37b9bfc75c 100644
--- a/db/docs/ci_editor_ai_conversation_messages.yml
+++ b/db/docs/deleted_tables/ci_editor_ai_conversation_messages.yml
@@ -9,3 +9,5 @@ description: Represents an ai message for a user and project for the pipeline ed
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/119840
milestone: '16.0'
gitlab_schema: gitlab_ci
+removed_in_milestone: '16.8'
+removed_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/139626
diff --git a/db/migrate/20231205165049_add_slug_to_topics.rb b/db/migrate/20231205165049_add_slug_to_topics.rb
new file mode 100644
index 00000000000..dedd871473d
--- /dev/null
+++ b/db/migrate/20231205165049_add_slug_to_topics.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddSlugToTopics < Gitlab::Database::Migration[2.2]
+ disable_ddl_transaction!
+
+ milestone '16.8'
+
+ def up
+ with_lock_retries do
+ add_column :topics, :slug, :text, if_not_exists: true
+ end
+
+ add_text_limit :topics, :slug, 255
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :topics, :slug, if_exists: true
+ end
+ end
+end
diff --git a/db/migrate/20231213065249_deprecate_ci_editor_ai_conversation_related_workers.rb b/db/migrate/20231213065249_deprecate_ci_editor_ai_conversation_related_workers.rb
new file mode 100644
index 00000000000..f0dd4775eb1
--- /dev/null
+++ b/db/migrate/20231213065249_deprecate_ci_editor_ai_conversation_related_workers.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class DeprecateCiEditorAiConversationRelatedWorkers < Gitlab::Database::Migration[2.2]
+ DEPRECATED_JOB_CLASSES = %w[
+ Ci::LLM::GenerateConfigWorker
+ OpenAi::ClearConversationsWorker
+ ]
+
+ disable_ddl_transaction!
+
+ milestone '16.8'
+
+ def up
+ sidekiq_remove_jobs(job_klasses: DEPRECATED_JOB_CLASSES)
+ end
+
+ def down
+ # This migration removes any instances of deprecated workers and cannot be undone.
+ end
+end
diff --git a/db/migrate/20231216190018_add_index_topics_on_slug.rb b/db/migrate/20231216190018_add_index_topics_on_slug.rb
new file mode 100644
index 00000000000..f83d733c008
--- /dev/null
+++ b/db/migrate/20231216190018_add_index_topics_on_slug.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexTopicsOnSlug < Gitlab::Database::Migration[2.2]
+ disable_ddl_transaction!
+
+ milestone '16.8'
+
+ INDEX_NAME = 'index_topics_on_slug'
+
+ def up
+ add_concurrent_index :topics, :slug, unique: true, where: 'slug IS NOT NULL', name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :topics, name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20231207145335_cleanup_group_level_work_items.rb b/db/post_migrate/20231207145335_cleanup_group_level_work_items.rb
new file mode 100644
index 00000000000..d52f0518f44
--- /dev/null
+++ b/db/post_migrate/20231207145335_cleanup_group_level_work_items.rb
@@ -0,0 +1,71 @@
+# frozen_string_literal: true
+
+class CleanupGroupLevelWorkItems < Gitlab::Database::Migration[2.2]
+ milestone '16.8'
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+ disable_ddl_transaction!
+
+ BATCH_SIZE = 100
+
+ class MigrationIssue < MigrationRecord
+ self.table_name = :issues
+
+ include EachBatch
+ end
+
+ class MigrationNote < MigrationRecord
+ self.table_name = :notes
+
+ include EachBatch
+ end
+
+ class MigrationLabelLink < MigrationRecord
+ self.table_name = :label_links
+
+ include EachBatch
+ end
+
+ class MigrationTodo < MigrationRecord
+ self.table_name = :todos
+
+ include EachBatch
+ end
+
+ def up
+ MigrationIssue.where(project_id: nil).each_batch(of: BATCH_SIZE) do |batch|
+ logger.info("deleting #{batch.size} issues at group level: #{batch.pluck(:id)}")
+
+ # cleaning up notes for the batch of issues
+ MigrationNote.where(noteable_type: 'Issue', noteable_id: batch).each_batch(of: BATCH_SIZE) do |note_batch|
+ logger.info("deleting #{note_batch.size} notes for issues at group level: #{note_batch.pluck(:id)}")
+ note_batch.delete_all
+ end
+
+ # cleaning up label links for the batch of issues
+ MigrationLabelLink.where(target_type: 'Issue', target_id: batch).each_batch(of: BATCH_SIZE) do |label_link_batch|
+ logger.info(
+ "deleting #{label_link_batch.size} label links for issues at group level: #{label_link_batch.pluck(:id)}"
+ )
+ label_link_batch.delete_all
+ end
+
+ # cleaning up todos for the batch of issues
+ MigrationTodo.where(target_type: 'Issue', target_id: batch).each_batch(of: BATCH_SIZE) do |todo_batch|
+ logger.info("deleting #{todo_batch.size} todos for issues at group level: #{todo_batch.pluck(:id)}")
+ todo_batch.delete_all
+ end
+
+ batch.delete_all
+ end
+ end
+
+ def down
+ # no-op
+ end
+
+ private
+
+ def logger
+ @logger ||= Gitlab::BackgroundMigration::Logger.build
+ end
+end
diff --git a/db/post_migrate/20231207155340_prepare_iid_namespace_unique_index_in_issues.rb b/db/post_migrate/20231207155340_prepare_iid_namespace_unique_index_in_issues.rb
new file mode 100644
index 00000000000..a0149a79f83
--- /dev/null
+++ b/db/post_migrate/20231207155340_prepare_iid_namespace_unique_index_in_issues.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class PrepareIidNamespaceUniqueIndexInIssues < Gitlab::Database::Migration[2.2]
+ INDEX_NAME = 'index_issues_on_namespace_id_iid_unique'
+
+ milestone '16.8'
+
+ # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/435856
+ def up
+ prepare_async_index :issues, [:namespace_id, :iid], unique: true, name: INDEX_NAME
+ end
+
+ def down
+ unprepare_async_index :issues, [:namespace_id, :iid], unique: true, name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20231213064314_remove_ci_editor_ai_conversation_messages_table.rb b/db/post_migrate/20231213064314_remove_ci_editor_ai_conversation_messages_table.rb
new file mode 100644
index 00000000000..b108805a22d
--- /dev/null
+++ b/db/post_migrate/20231213064314_remove_ci_editor_ai_conversation_messages_table.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+class RemoveCiEditorAiConversationMessagesTable < Gitlab::Database::Migration[2.2]
+ milestone '16.8'
+
+ def up
+ drop_table :ci_editor_ai_conversation_messages, if_exists: true
+ end
+
+ def down
+ create_table :ci_editor_ai_conversation_messages do |t|
+ t.bigint :user_id,
+ null: false
+ t.bigint :project_id,
+ null: false
+ t.timestamps_with_timezone null: false
+ t.text :role, limit: 100,
+ null: false
+ t.text :content, limit: 16384,
+ null: true
+ t.text :async_errors, array: true, null: false, default: []
+
+ t.index [:user_id, :project_id, :created_at],
+ name: :index_ci_editor_ai_messages_on_user_project_and_created_at
+
+ t.index :project_id,
+ name: :index_ci_editor_ai_messages_project_id
+
+ t.index :created_at,
+ name: :index_ci_editor_ai_messages_created_at
+ end
+ end
+end
diff --git a/db/schema_migrations/20231205165049 b/db/schema_migrations/20231205165049
new file mode 100644
index 00000000000..31d9412d92e
--- /dev/null
+++ b/db/schema_migrations/20231205165049
@@ -0,0 +1 @@
+0ee24818863477396cd51f071d113ebc35f8e9a90f90a5d5e7237032c5f55bd3 \ No newline at end of file
diff --git a/db/schema_migrations/20231207145335 b/db/schema_migrations/20231207145335
new file mode 100644
index 00000000000..0918b3e1c99
--- /dev/null
+++ b/db/schema_migrations/20231207145335
@@ -0,0 +1 @@
+94f37e35b90378cfa2cc26aa5114495bfb1f407ace69e5104b354110f797e15d \ No newline at end of file
diff --git a/db/schema_migrations/20231207155340 b/db/schema_migrations/20231207155340
new file mode 100644
index 00000000000..dc9528f0fe4
--- /dev/null
+++ b/db/schema_migrations/20231207155340
@@ -0,0 +1 @@
+0e9bec42c0fcff647bf36fb61fc6fbb4c850da8346c404d2d48b4054f559b213 \ No newline at end of file
diff --git a/db/schema_migrations/20231213064314 b/db/schema_migrations/20231213064314
new file mode 100644
index 00000000000..ca689b6efe9
--- /dev/null
+++ b/db/schema_migrations/20231213064314
@@ -0,0 +1 @@
+800e0153034af8cffab47cce9362092ec76ba6aa59645b55ecf754bbbdba69d2 \ No newline at end of file
diff --git a/db/schema_migrations/20231213065249 b/db/schema_migrations/20231213065249
new file mode 100644
index 00000000000..86109e19921
--- /dev/null
+++ b/db/schema_migrations/20231213065249
@@ -0,0 +1 @@
+dece1580b6d5b6663b557761b69a8333f83f3f06c38be377299aeacc5ca8e163 \ No newline at end of file
diff --git a/db/schema_migrations/20231216190018 b/db/schema_migrations/20231216190018
new file mode 100644
index 00000000000..e94fc46ebeb
--- /dev/null
+++ b/db/schema_migrations/20231216190018
@@ -0,0 +1 @@
+aedec8e22474291e722e18fdc79fc10a1d4569db2e2760a4aebd21119d2c0fd4 \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index d755f53054c..4be0eebfde6 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -13979,28 +13979,6 @@ CREATE SEQUENCE ci_deleted_objects_id_seq
ALTER SEQUENCE ci_deleted_objects_id_seq OWNED BY ci_deleted_objects.id;
-CREATE TABLE ci_editor_ai_conversation_messages (
- id bigint NOT NULL,
- user_id bigint NOT NULL,
- project_id bigint NOT NULL,
- created_at timestamp with time zone NOT NULL,
- updated_at timestamp with time zone NOT NULL,
- role text NOT NULL,
- content text,
- async_errors text[] DEFAULT '{}'::text[] NOT NULL,
- CONSTRAINT check_10b793171f CHECK ((char_length(role) <= 100)),
- CONSTRAINT check_c83d789632 CHECK ((char_length(content) <= 16384))
-);
-
-CREATE SEQUENCE ci_editor_ai_conversation_messages_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
-ALTER SEQUENCE ci_editor_ai_conversation_messages_id_seq OWNED BY ci_editor_ai_conversation_messages.id;
-
CREATE TABLE ci_freeze_periods (
id bigint NOT NULL,
project_id bigint NOT NULL,
@@ -24312,6 +24290,8 @@ CREATE TABLE topics (
total_projects_count bigint DEFAULT 0 NOT NULL,
non_private_projects_count bigint DEFAULT 0 NOT NULL,
title text,
+ slug text,
+ CONSTRAINT check_0eda72aeb0 CHECK ((char_length(slug) <= 255)),
CONSTRAINT check_223b50f9be CHECK ((char_length(title) <= 255)),
CONSTRAINT check_26753fb43a CHECK ((char_length(avatar) <= 255)),
CONSTRAINT check_5d1a07c8c8 CHECK ((char_length(description) <= 1024)),
@@ -26486,8 +26466,6 @@ ALTER TABLE ONLY ci_daily_build_group_report_results ALTER COLUMN id SET DEFAULT
ALTER TABLE ONLY ci_deleted_objects ALTER COLUMN id SET DEFAULT nextval('ci_deleted_objects_id_seq'::regclass);
-ALTER TABLE ONLY ci_editor_ai_conversation_messages ALTER COLUMN id SET DEFAULT nextval('ci_editor_ai_conversation_messages_id_seq'::regclass);
-
ALTER TABLE ONLY ci_freeze_periods ALTER COLUMN id SET DEFAULT nextval('ci_freeze_periods_id_seq'::regclass);
ALTER TABLE ONLY ci_group_variables ALTER COLUMN id SET DEFAULT nextval('ci_group_variables_id_seq'::regclass);
@@ -28444,9 +28422,6 @@ ALTER TABLE ONLY ci_daily_build_group_report_results
ALTER TABLE ONLY ci_deleted_objects
ADD CONSTRAINT ci_deleted_objects_pkey PRIMARY KEY (id);
-ALTER TABLE ONLY ci_editor_ai_conversation_messages
- ADD CONSTRAINT ci_editor_ai_conversation_messages_pkey PRIMARY KEY (id);
-
ALTER TABLE ONLY ci_freeze_periods
ADD CONSTRAINT ci_freeze_periods_pkey PRIMARY KEY (id);
@@ -32203,12 +32178,6 @@ CREATE INDEX index_ci_daily_build_group_report_results_on_project_and_date ON ci
CREATE INDEX index_ci_deleted_objects_on_pick_up_at ON ci_deleted_objects USING btree (pick_up_at);
-CREATE INDEX index_ci_editor_ai_messages_created_at ON ci_editor_ai_conversation_messages USING btree (created_at);
-
-CREATE INDEX index_ci_editor_ai_messages_on_user_project_and_created_at ON ci_editor_ai_conversation_messages USING btree (user_id, project_id, created_at);
-
-CREATE INDEX index_ci_editor_ai_messages_project_id ON ci_editor_ai_conversation_messages USING btree (project_id);
-
CREATE INDEX index_ci_finished_build_ch_sync_events_for_partitioned_query ON ONLY p_ci_finished_build_ch_sync_events USING btree (((build_id % (100)::bigint)), build_id) WHERE (processed = false);
CREATE INDEX index_ci_freeze_periods_on_project_id ON ci_freeze_periods USING btree (project_id);
@@ -34871,6 +34840,8 @@ CREATE UNIQUE INDEX index_topics_on_name ON topics USING btree (name);
CREATE INDEX index_topics_on_name_trigram ON topics USING gin (name gin_trgm_ops);
+CREATE UNIQUE INDEX index_topics_on_slug ON topics USING btree (slug) WHERE (slug IS NOT NULL);
+
CREATE INDEX index_topics_total_projects_count ON topics USING btree (total_projects_count DESC, id);
CREATE UNIQUE INDEX index_trending_projects_on_project_id ON trending_projects USING btree (project_id);