Skip to content
代码片段 群组 项目
提交 da01ab51 编辑于 作者: Marius Bobin's avatar Marius Bobin
浏览文件

Merge branch '422816-cleanup' into 'master'

Cleanup for converted ci_stages.pipeline_id conversion

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/137379



Merged-by: default avatarMarius Bobin <mbobin@gitlab.com>
Approved-by: default avatarMarius Bobin <mbobin@gitlab.com>
Reviewed-by: default avatarEthan Urie <eurie@gitlab.com>
Reviewed-by: default avatarTianwen Chen <tchen@gitlab.com>
Co-authored-by: default avatarTianwen Chen <tchen@gitlab.com>
No related branches found
No related tags found
无相关合并请求
# frozen_string_literal: true
class CleanupCiStagesPipelineIdBigint < Gitlab::Database::Migration[2.2]
include Gitlab::Database::MigrationHelpers::WraparoundAutovacuum
disable_ddl_transaction!
milestone "16.7"
TABLE = :ci_stages
REFERENCING_TABLE = :ci_pipelines
COLUMN = :pipeline_id
OLD_COLUMN = :pipeline_id_convert_to_bigint
INDEXES = {
'index_ci_stages_on_pipeline_id_convert_to_bigint_and_name' => [
[:pipeline_id_convert_to_bigint, :name], { unique: true }
],
'index_ci_stages_on_pipeline_id_convert_to_bigint' => [
[:pipeline_id_convert_to_bigint], {}
],
'index_ci_stages_on_pipeline_id_convert_to_bigint_and_id' => [
[:pipeline_id_convert_to_bigint, :id], { where: 'status = ANY (ARRAY[0, 1, 2, 8, 9, 10])' }
],
'index_ci_stages_on_pipeline_id_convert_to_bigint_and_position' => [
[:pipeline_id_convert_to_bigint, :position], {}
]
}
OLD_FK_NAME = :fk_c5ddde695f
def up
return unless can_execute_on?(:ci_pipelines, :ci_stages)
with_lock_retries(raise_on_exhaustion: true) do
lock_tables(REFERENCING_TABLE, TABLE)
cleanup_conversion_of_integer_to_bigint(TABLE, [COLUMN])
end
end
def down
return unless can_execute_on?(:ci_pipelines, :ci_stages)
restore_conversion_of_integer_to_bigint(TABLE, [COLUMN])
INDEXES.each do |index_name, (columns, options)|
add_concurrent_index(TABLE, columns, name: index_name, **options)
end
add_concurrent_foreign_key(
TABLE, REFERENCING_TABLE,
column: OLD_COLUMN, name: OLD_FK_NAME,
on_delete: :cascade, validate: true, reverse_lock_order: true
)
end
end
7f3abae7002d20e30f9e4a30d580e49c5d72a7728d13ee45a5392fb4396da13b
\ No newline at end of file
......@@ -531,15 +531,6 @@ RETURN NULL;
END
$$;
 
CREATE FUNCTION trigger_07bc3c48f407() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW."pipeline_id_convert_to_bigint" := NEW."pipeline_id";
RETURN NEW;
END;
$$;
CREATE FUNCTION trigger_10ee1357e825() RETURNS trigger
LANGUAGE plpgsql
AS $$
......@@ -14721,7 +14712,6 @@ ALTER SEQUENCE ci_sources_projects_id_seq OWNED BY ci_sources_projects.id;
 
CREATE TABLE ci_stages (
project_id integer,
pipeline_id_convert_to_bigint integer,
created_at timestamp without time zone,
updated_at timestamp without time zone,
name character varying,
......@@ -32344,14 +32334,6 @@ CREATE UNIQUE INDEX index_ci_stages_on_pipeline_id_and_name ON ci_stages USING b
 
CREATE INDEX index_ci_stages_on_pipeline_id_and_position ON ci_stages USING btree (pipeline_id, "position");
 
CREATE INDEX index_ci_stages_on_pipeline_id_convert_to_bigint ON ci_stages USING btree (pipeline_id_convert_to_bigint);
CREATE INDEX index_ci_stages_on_pipeline_id_convert_to_bigint_and_id ON ci_stages USING btree (pipeline_id_convert_to_bigint, id) WHERE (status = ANY (ARRAY[0, 1, 2, 8, 9, 10]));
CREATE UNIQUE INDEX index_ci_stages_on_pipeline_id_convert_to_bigint_and_name ON ci_stages USING btree (pipeline_id_convert_to_bigint, name);
CREATE INDEX index_ci_stages_on_pipeline_id_convert_to_bigint_and_position ON ci_stages USING btree (pipeline_id_convert_to_bigint, "position");
CREATE INDEX index_ci_stages_on_project_id ON ci_stages USING btree (project_id);
 
CREATE INDEX index_ci_subscriptions_projects_author_id ON ci_subscriptions_projects USING btree (author_id);
......@@ -37036,8 +37018,6 @@ CREATE TRIGGER push_rules_loose_fk_trigger AFTER DELETE ON push_rules REFERENCIN
 
CREATE TRIGGER tags_loose_fk_trigger AFTER DELETE ON tags REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records();
 
CREATE TRIGGER trigger_07bc3c48f407 BEFORE INSERT OR UPDATE ON ci_stages FOR EACH ROW EXECUTE FUNCTION trigger_07bc3c48f407();
CREATE TRIGGER trigger_10ee1357e825 BEFORE INSERT OR UPDATE ON p_ci_builds FOR EACH ROW EXECUTE FUNCTION trigger_10ee1357e825();
 
CREATE TRIGGER trigger_b2d852e1e2cb BEFORE INSERT OR UPDATE ON ci_pipelines FOR EACH ROW EXECUTE FUNCTION trigger_b2d852e1e2cb();
......@@ -37953,9 +37933,6 @@ ALTER TABLE ONLY timelogs
ALTER TABLE ONLY geo_event_log
ADD CONSTRAINT fk_c4b1c1f66e FOREIGN KEY (repository_deleted_event_id) REFERENCES geo_repository_deleted_events(id) ON DELETE CASCADE;
 
ALTER TABLE ONLY ci_stages
ADD CONSTRAINT fk_c5ddde695f FOREIGN KEY (pipeline_id_convert_to_bigint) REFERENCES ci_pipelines(id) ON DELETE CASCADE;
ALTER TABLE ONLY issues
ADD CONSTRAINT fk_c63cbf6c25 FOREIGN KEY (closed_by_id) REFERENCES users(id) ON DELETE SET NULL;
 
......@@ -42,10 +42,6 @@ ci_stages:
- index_ci_stages_on_pipeline_id
index_ci_stages_on_pipeline_id_and_position:
- index_ci_stages_on_pipeline_id
index_ci_stages_on_pipeline_id_convert_to_bigint_and_name:
- index_ci_stages_on_pipeline_id_convert_to_bigint
index_ci_stages_on_pipeline_id_convert_to_bigint_and_position:
- index_ci_stages_on_pipeline_id_convert_to_bigint
dast_site_tokens:
index_dast_site_token_on_project_id_and_url:
- index_dast_site_tokens_on_project_id
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册