Skip to content
Snippets Groups Projects
Unverified Commit 175fac5d authored by Marius Bobin's avatar Marius Bobin Committed by GitLab
Browse files

Replace ci_pipelines_config with dynamic partitions

Changelog: other
parent b1ee7761
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -8,4 +8,5 @@ description: TODO
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/21827
milestone: '12.7'
gitlab_schema: gitlab_ci
sharding_key_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/458483
removed_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/169251
removed_in_milestone: '17.6'
# frozen_string_literal: true
class DropCiPipelinesConfig < Gitlab::Database::Migration[2.2]
milestone '17.6'
def up
execute(<<~SQL)
ALTER TABLE p_ci_pipelines_config DETACH PARTITION ci_pipelines_config;
CREATE TABLE IF NOT EXISTS #{fully_qualified_partition_name(100)}
PARTITION OF p_ci_pipelines_config FOR VALUES IN (100);
CREATE TABLE IF NOT EXISTS #{fully_qualified_partition_name(101)}
PARTITION OF p_ci_pipelines_config FOR VALUES IN (101);
CREATE TABLE IF NOT EXISTS #{fully_qualified_partition_name(102)}
PARTITION OF p_ci_pipelines_config FOR VALUES IN (102);
SQL
drop_table(:ci_pipelines_config, if_exists: true)
end
def down
drop_table(fully_qualified_partition_name(100), if_exists: true)
drop_table(fully_qualified_partition_name(101), if_exists: true)
drop_table(fully_qualified_partition_name(102), if_exists: true)
execute(<<~SQL)
CREATE TABLE IF NOT EXISTS ci_pipelines_config
PARTITION OF p_ci_pipelines_config FOR VALUES IN (100, 101, 102);
SQL
end
private
def fully_qualified_partition_name(value)
"#{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}.ci_pipelines_config_#{value}"
end
end
72445beac3fec7519c9afaf36d624753f16609a08bb4b4f4a77761fcc80d4cbd
\ No newline at end of file
Loading
Loading
@@ -3044,6 +3044,15 @@ CREATE TABLE p_ci_pipeline_variables (
)
PARTITION BY LIST (partition_id);
 
CREATE TABLE p_ci_pipelines_config (
pipeline_id bigint NOT NULL,
partition_id bigint NOT NULL,
content text NOT NULL,
project_id bigint,
CONSTRAINT check_b2a19dd79a CHECK ((project_id IS NOT NULL))
)
PARTITION BY LIST (partition_id);
CREATE TABLE p_ci_runner_machine_builds (
partition_id bigint NOT NULL,
build_id bigint NOT NULL,
Loading
Loading
@@ -8973,23 +8982,6 @@ CREATE TABLE ci_pipelines (
CONSTRAINT check_d7e99a025e CHECK ((lock_version IS NOT NULL))
);
 
CREATE TABLE p_ci_pipelines_config (
pipeline_id bigint NOT NULL,
partition_id bigint NOT NULL,
content text NOT NULL,
project_id bigint,
CONSTRAINT check_b2a19dd79a CHECK ((project_id IS NOT NULL))
)
PARTITION BY LIST (partition_id);
CREATE TABLE ci_pipelines_config (
pipeline_id bigint NOT NULL,
partition_id bigint NOT NULL,
content text NOT NULL,
project_id bigint,
CONSTRAINT check_b2a19dd79a CHECK ((project_id IS NOT NULL))
);
CREATE TABLE ci_project_mirrors (
id bigint NOT NULL,
project_id bigint NOT NULL,
Loading
Loading
@@ -21967,8 +21959,6 @@ ALTER TABLE ONLY p_ci_pipeline_variables ATTACH PARTITION ci_pipeline_variables
 
ALTER TABLE ONLY p_ci_pipelines ATTACH PARTITION ci_pipelines FOR VALUES IN ('100', '101', '102');
 
ALTER TABLE ONLY p_ci_pipelines_config ATTACH PARTITION ci_pipelines_config FOR VALUES IN ('100', '101', '102');
ALTER TABLE ONLY p_ci_stages ATTACH PARTITION ci_stages FOR VALUES IN ('100', '101');
 
ALTER TABLE ONLY abuse_events ALTER COLUMN id SET DEFAULT nextval('abuse_events_id_seq'::regclass);
Loading
Loading
@@ -24270,12 +24260,6 @@ ALTER TABLE ONLY p_ci_pipeline_variables
ALTER TABLE ONLY ci_pipeline_variables
ADD CONSTRAINT ci_pipeline_variables_pkey PRIMARY KEY (id, partition_id);
 
ALTER TABLE ONLY p_ci_pipelines_config
ADD CONSTRAINT p_ci_pipelines_config_pkey PRIMARY KEY (pipeline_id, partition_id);
ALTER TABLE ONLY ci_pipelines_config
ADD CONSTRAINT ci_pipelines_config_pkey PRIMARY KEY (pipeline_id, partition_id);
ALTER TABLE ONLY p_ci_pipelines
ADD CONSTRAINT p_ci_pipelines_pkey PRIMARY KEY (id, partition_id);
 
Loading
Loading
@@ -25224,6 +25208,9 @@ ALTER TABLE ONLY p_ci_finished_pipeline_ch_sync_events
ALTER TABLE ONLY p_ci_job_annotations
ADD CONSTRAINT p_ci_job_annotations_pkey PRIMARY KEY (id, partition_id);
 
ALTER TABLE ONLY p_ci_pipelines_config
ADD CONSTRAINT p_ci_pipelines_config_pkey PRIMARY KEY (pipeline_id, partition_id);
ALTER TABLE ONLY p_ci_runner_machine_builds
ADD CONSTRAINT p_ci_runner_machine_builds_pkey PRIMARY KEY (build_id, partition_id);
 
Loading
Loading
@@ -27996,10 +27983,6 @@ CREATE INDEX index_batched_jobs_on_batched_migration_id_and_status ON batched_ba
 
CREATE UNIQUE INDEX index_batched_migrations_on_gl_schema_and_unique_configuration ON batched_background_migrations USING btree (gitlab_schema, job_class_name, table_name, column_name, job_arguments);
 
CREATE INDEX index_p_ci_pipelines_config_on_project_id ON ONLY p_ci_pipelines_config USING btree (project_id);
CREATE INDEX index_bb7e299984 ON ci_pipelines_config USING btree (project_id);
CREATE INDEX index_board_assignees_on_assignee_id ON board_assignees USING btree (assignee_id);
 
CREATE UNIQUE INDEX index_board_assignees_on_board_id_and_assignee_id ON board_assignees USING btree (board_id, assignee_id);
Loading
Loading
@@ -30246,6 +30229,8 @@ CREATE UNIQUE INDEX index_p_ci_job_annotations_on_partition_id_job_id_name ON ON
 
CREATE INDEX index_p_ci_job_annotations_on_project_id ON ONLY p_ci_job_annotations USING btree (project_id);
 
CREATE INDEX index_p_ci_pipelines_config_on_project_id ON ONLY p_ci_pipelines_config USING btree (project_id);
CREATE INDEX index_p_ci_runner_machine_builds_on_project_id ON ONLY p_ci_runner_machine_builds USING btree (project_id);
 
CREATE INDEX index_p_ci_runner_machine_builds_on_runner_machine_id ON ONLY p_ci_runner_machine_builds USING btree (runner_machine_id);
Loading
Loading
@@ -33558,8 +33543,6 @@ ALTER INDEX p_ci_job_artifacts_pkey ATTACH PARTITION ci_job_artifacts_pkey;
 
ALTER INDEX p_ci_pipeline_variables_pkey ATTACH PARTITION ci_pipeline_variables_pkey;
 
ALTER INDEX p_ci_pipelines_config_pkey ATTACH PARTITION ci_pipelines_config_pkey;
ALTER INDEX p_ci_pipelines_pkey ATTACH PARTITION ci_pipelines_pkey;
 
ALTER INDEX p_ci_stages_pkey ATTACH PARTITION ci_stages_pkey;
Loading
Loading
@@ -33570,8 +33553,6 @@ ALTER INDEX p_ci_pipelines_ci_ref_id_id_idx ATTACH PARTITION idx_ci_pipelines_ar
 
ALTER INDEX index_p_ci_builds_on_execution_config_id ATTACH PARTITION index_0928d9f200;
 
ALTER INDEX index_p_ci_pipelines_config_on_project_id ATTACH PARTITION index_bb7e299984;
ALTER INDEX p_ci_builds_metadata_build_id_idx ATTACH PARTITION index_ci_builds_metadata_on_build_id_and_has_exposed_artifacts;
 
ALTER INDEX p_ci_builds_metadata_build_id_id_idx ATTACH PARTITION index_ci_builds_metadata_on_build_id_and_id_and_interruptible;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment