Drop ci_runners_archived table
What does this MR do and why?
This MR drops the ci_runners_archived
table and transfers the old names of the indices to the new partitioned table (which was still using the cryptic and sometimes shortened index_ci_runners_e59bb2812d_on_*
names. The down
method rebuilds the table and relationships, but does not recreate data, since that is lost in the up
method.
I didn't add specs since the documentation mentions:
We don’t enforce tests on post migrations that only perform schema changes.
Changelog: other
References
Table schemas
Before
Partitioned table "public.ci_runners"
┌──────────────────────────────────────┬──────────────────────────┬───────────┬──────────┬────────────────┐
│ Column │ Type │ Collation │ Nullable │ Default │
├──────────────────────────────────────┼──────────────────────────┼───────────┼──────────┼────────────────┤
│ id │ bigint │ │ not null │ │
│ creator_id │ bigint │ │ │ │
│ sharding_key_id │ bigint │ │ │ │
│ created_at │ timestamp with time zone │ │ │ │
│ updated_at │ timestamp with time zone │ │ │ │
│ contacted_at │ timestamp with time zone │ │ │ │
│ token_expires_at │ timestamp with time zone │ │ │ │
│ public_projects_minutes_cost_factor │ double precision │ │ not null │ 1.0 │
│ private_projects_minutes_cost_factor │ double precision │ │ not null │ 1.0 │
│ access_level │ integer │ │ not null │ 0 │
│ maximum_timeout │ integer │ │ │ │
│ runner_type │ smallint │ │ not null │ │
│ registration_type │ smallint │ │ not null │ 0 │
│ creation_state │ smallint │ │ not null │ 0 │
│ active │ boolean │ │ not null │ true │
│ run_untagged │ boolean │ │ not null │ true │
│ locked │ boolean │ │ not null │ false │
│ name │ text │ │ │ │
│ token_encrypted │ text │ │ │ │
│ token │ text │ │ │ │
│ description │ text │ │ │ │
│ maintainer_note │ text │ │ │ │
│ allowed_plans │ text[] │ │ not null │ '{}'::text[] │
│ allowed_plan_ids │ bigint[] │ │ not null │ '{}'::bigint[] │
└──────────────────────────────────────┴──────────────────────────┴───────────┴──────────┴────────────────┘
Partition key: LIST (runner_type)
Indexes:
"ci_runners_pkey" PRIMARY KEY, btree (id, runner_type)
"idx_ci_runners_e59bb2812d_on_contacted_at_and_id_where_inactive" btree (contacted_at DESC, id DESC) WHERE active = false
"idx_ci_runners_e59bb2812d_on_token_expires_at_desc_and_id_desc" btree (token_expires_at DESC, id DESC)
"idx_uniq_ci_runners_e59bb2812d_on_token_and_type_where_not_null" UNIQUE, btree (token, runner_type) WHERE token IS NOT NULL
"index_ci_runners_e59bb2812d_on_active_and_id" btree (active, id)
"index_ci_runners_e59bb2812d_on_contacted_at_and_id_desc" btree (contacted_at, id DESC)
"index_ci_runners_e59bb2812d_on_contacted_at_desc_and_id_desc" btree (contacted_at DESC, id DESC)
"index_ci_runners_e59bb2812d_on_created_at_and_id_desc" btree (created_at, id DESC)
"index_ci_runners_e59bb2812d_on_created_at_and_id_where_inactive" btree (created_at DESC, id DESC) WHERE active = false
"index_ci_runners_e59bb2812d_on_created_at_desc_and_id_desc" btree (created_at DESC, id DESC)
"index_ci_runners_e59bb2812d_on_creator_id_where_not_null" btree (creator_id) WHERE creator_id IS NOT NULL
"index_ci_runners_e59bb2812d_on_description_trigram" gin (description gin_trgm_ops)
"index_ci_runners_e59bb2812d_on_locked" btree (locked)
"index_ci_runners_e59bb2812d_on_sharding_key_id_where_not_null" btree (sharding_key_id) WHERE sharding_key_id IS NOT NULL
"index_ci_runners_e59bb2812d_on_token_expires_at_and_id_desc" btree (token_expires_at, id DESC)
"index_uniq_ci_runners_e59bb2812d_on_token_encrypted_and_type" UNIQUE, btree (token_encrypted, runner_type)
Check constraints:
"check_030ad0773d" CHECK (char_length(token_encrypted) <= 512)
"check_1f8618ab23" CHECK (char_length(name) <= 256)
"check_24b281f5bf" CHECK (char_length(maintainer_note) <= 1024)
"check_5db8ae9d30" CHECK (char_length(description) <= 1024)
"check_af25130d5a" CHECK (char_length(token) <= 128)
Triggers:
assign_ci_runners_id_trigger BEFORE INSERT ON ci_runners FOR EACH ROW EXECUTE FUNCTION assign_ci_runners_id_value()
ci_runners_loose_fk_trigger AFTER DELETE ON ci_runners REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records_override_table('ci_runners')
table_sync_trigger_61879721b5 AFTER INSERT OR DELETE OR UPDATE ON ci_runners FOR EACH ROW EXECUTE FUNCTION table_sync_function_686d6c7993()
Number of partitions: 3 (Use \d+ to list them.)
After
Partitioned table "public.ci_runners"
┌──────────────────────────────────────┬──────────────────────────┬───────────┬──────────┬────────────────┐
│ Column │ Type │ Collation │ Nullable │ Default │
├──────────────────────────────────────┼──────────────────────────┼───────────┼──────────┼────────────────┤
│ id │ bigint │ │ not null │ │
│ creator_id │ bigint │ │ │ │
│ sharding_key_id │ bigint │ │ │ │
│ created_at │ timestamp with time zone │ │ │ │
│ updated_at │ timestamp with time zone │ │ │ │
│ contacted_at │ timestamp with time zone │ │ │ │
│ token_expires_at │ timestamp with time zone │ │ │ │
│ public_projects_minutes_cost_factor │ double precision │ │ not null │ 1.0 │
│ private_projects_minutes_cost_factor │ double precision │ │ not null │ 1.0 │
│ access_level │ integer │ │ not null │ 0 │
│ maximum_timeout │ integer │ │ │ │
│ runner_type │ smallint │ │ not null │ │
│ registration_type │ smallint │ │ not null │ 0 │
│ creation_state │ smallint │ │ not null │ 0 │
│ active │ boolean │ │ not null │ true │
│ run_untagged │ boolean │ │ not null │ true │
│ locked │ boolean │ │ not null │ false │
│ name │ text │ │ │ │
│ token_encrypted │ text │ │ │ │
│ token │ text │ │ │ │
│ description │ text │ │ │ │
│ maintainer_note │ text │ │ │ │
│ allowed_plans │ text[] │ │ not null │ '{}'::text[] │
│ allowed_plan_ids │ bigint[] │ │ not null │ '{}'::bigint[] │
└──────────────────────────────────────┴──────────────────────────┴───────────┴──────────┴────────────────┘
Partition key: LIST (runner_type)
Indexes:
"ci_runners_pkey" PRIMARY KEY, btree (id, runner_type)
"index_ci_runners_on_active_and_id" btree (active, id)
"index_ci_runners_on_contacted_at_and_id_desc" btree (contacted_at, id DESC)
"index_ci_runners_on_contacted_at_and_id_where_inactive" btree (contacted_at DESC, id DESC) WHERE active = false
"index_ci_runners_on_contacted_at_desc_and_id_desc" btree (contacted_at DESC, id DESC)
"index_ci_runners_on_created_at_and_id_desc" btree (created_at, id DESC)
"index_ci_runners_on_created_at_and_id_where_inactive" btree (created_at DESC, id DESC) WHERE active = false
"index_ci_runners_on_created_at_desc_and_id_desc" btree (created_at DESC, id DESC)
"index_ci_runners_on_creator_id_where_creator_id_not_null" btree (creator_id) WHERE creator_id IS NOT NULL
"index_ci_runners_on_description_trigram" gin (description gin_trgm_ops)
"index_ci_runners_on_locked" btree (locked)
"index_ci_runners_on_sharding_key_id_when_not_null" btree (sharding_key_id) WHERE sharding_key_id IS NOT NULL
"index_ci_runners_on_token_and_runner_type_when_token_not_null" UNIQUE, btree (token, runner_type) WHERE token IS NOT NULL
"index_ci_runners_on_token_encrypted_and_runner_type" UNIQUE, btree (token_encrypted, runner_type)
"index_ci_runners_on_token_expires_at_and_id_desc" btree (token_expires_at, id DESC)
"index_ci_runners_on_token_expires_at_desc_and_id_desc" btree (token_expires_at DESC, id DESC)
Check constraints:
"check_030ad0773d" CHECK (char_length(token_encrypted) <= 512)
"check_1f8618ab23" CHECK (char_length(name) <= 256)
"check_24b281f5bf" CHECK (char_length(maintainer_note) <= 1024)
"check_5db8ae9d30" CHECK (char_length(description) <= 1024)
"check_af25130d5a" CHECK (char_length(token) <= 128)
Triggers:
assign_ci_runners_id_trigger BEFORE INSERT ON ci_runners FOR EACH ROW EXECUTE FUNCTION assign_ci_runners_id_value()
ci_runners_loose_fk_trigger AFTER DELETE ON ci_runners REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records_override_table('ci_runners')
Number of partitions: 3 (Use \d+ to list them.)
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Pedro Pombeiro - OOO from Oct 13-24