Skip to content

Sync validate foreign key for ci_pipeline_messages

Tianwen Chen requested to merge 422797-validate-foreign-key into master

What does this MR do and why?

This is the second migration to validate the foreign key for ci_pipeline_messages async created synchronously in !130899 (merged)

See https://docs.gitlab.com/ee/development/database/add_foreign_key_to_existing_column.html#add-a-migration-to-validate-the-fk-synchronously

See the following output from postgres.ai that the foreign key validation is completed on prod:

Table "public.ci_pipeline_messages"
            Column             |   Type   | Collation | Nullable |                     Default                      | Storage  | Compression | Stats target | Description 
-------------------------------+----------+-----------+----------+--------------------------------------------------+----------+-------------+--------------+-------------
 id                            | bigint   |           | not null | nextval('ci_pipeline_messages_id_seq'::regclass) | plain    |             |              | 
 severity                      | smallint |           | not null | 0                                                | plain    |             |              | 
 pipeline_id                   | integer  |           | not null |                                                  | plain    |             |              | 
 content                       | text     |           | not null |                                                  | extended |             |              | 
 pipeline_id_convert_to_bigint | bigint   |           | not null | 0                                                | plain    |             |              | 
Indexes:
    "ci_pipeline_messages_pkey" PRIMARY KEY, btree (id)
    "index_ci_pipeline_messages_on_pipeline_id" btree (pipeline_id)
    "index_ci_pipeline_messages_on_pipeline_id_convert_to_bigint" btree (pipeline_id_convert_to_bigint)
Check constraints:
    "check_58ca2981b2" CHECK (char_length(content) <= 10000)
Foreign-key constraints:
    "fk_0946fea681" FOREIGN KEY (pipeline_id_convert_to_bigint) REFERENCES ci_pipelines(id) ON DELETE CASCADE
    "fk_rails_8d3b04e3e1" FOREIGN KEY (pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE
Triggers:
    trigger_bfad0e2b9c86 BEFORE INSERT OR UPDATE ON ci_pipeline_messages FOR EACH ROW EXECUTE FUNCTION trigger_bfad0e2b9c86()
Access method: heap

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #422797 (closed)

Edited by Marius Bobin

Merge request reports