Finalize converting deployments to bigint
What does this MR do?
This migration finalizes the conversion of deployments.deployable_id to bigint, following the pattern in !64779 (merged)
It takes the following steps:
- Ensure the migration copying from
deployable_idtodeployable_id_convert_to_bigintis complete - Create a new index
index_deployments_on_deployable_type_and_deployable_id_bigintto match the existing index - Swap the column and index names, and drop the old index.
Database Migration Timing
-
create index concurrently index_deployments_on_deployable_type_and_deployable_id_bigint ON deployments(deployable_type, deployable_id_convert_to_bigint);
Migration Output
Up
== 20210802131812 FinalizeConvertDeploymentsBigint: migrating =================
-- transaction_open?()
-> 0.0000s
-- index_exists?("deployments", ["deployable_type", "deployable_id_convert_to_bigint"], {:name=>"index_deployments_on_deployable_type_and_deployable_id_bigint", :algorithm=>:concurrently})
-> 0.0096s
-- execute("SET statement_timeout TO 0")
-> 0.0008s
-- add_index("deployments", ["deployable_type", "deployable_id_convert_to_bigint"], {:name=>"index_deployments_on_deployable_type_and_deployable_id_bigint", :algorithm=>:concurrently})
-> 0.0048s
-- execute("RESET ALL")
-> 0.0007s
-- quote_column_name("deployable_id")
-> 0.0000s
-- quote_column_name("deployable_id_tmp")
-> 0.0000s
-- execute("ALTER TABLE deployments RENAME COLUMN \"deployable_id\" TO \"deployable_id_tmp\"")
-> 0.0007s
-- quote_column_name("deployable_id_convert_to_bigint")
-> 0.0000s
-- quote_column_name("deployable_id")
-> 0.0000s
-- execute("ALTER TABLE deployments RENAME COLUMN \"deployable_id_convert_to_bigint\" TO \"deployable_id\"")
-> 0.0006s
-- quote_column_name("deployable_id_tmp")
-> 0.0000s
-- quote_column_name("deployable_id_convert_to_bigint")
-> 0.0000s
-- execute("ALTER TABLE deployments RENAME COLUMN \"deployable_id_tmp\" TO \"deployable_id_convert_to_bigint\"")
-> 0.0006s
-- quote_table_name("trigger_77f5e1d20482")
-> 0.0000s
-- execute("ALTER FUNCTION \"trigger_77f5e1d20482\" RESET ALL")
-> 0.0005s
-- execute("DROP INDEX index_deployments_on_deployable_type_and_deployable_id")
-> 0.0007s
-- rename_index("deployments", "index_deployments_on_deployable_type_and_deployable_id_bigint", "index_deployments_on_deployable_type_and_deployable_id")
-> 0.0006s
== 20210802131812 FinalizeConvertDeploymentsBigint: migrated (0.0370s) ========
Down
== 20210802131812 FinalizeConvertDeploymentsBigint: reverting =================
-- transaction_open?()
-> 0.0000s
-- index_exists?("deployments", ["deployable_type", "deployable_id_convert_to_bigint"], {:name=>"index_deployments_on_deployable_type_and_deployable_id_bigint", :algorithm=>:concurrently})
-> 0.0057s
-- execute("SET statement_timeout TO 0")
-> 0.0004s
-- add_index("deployments", ["deployable_type", "deployable_id_convert_to_bigint"], {:name=>"index_deployments_on_deployable_type_and_deployable_id_bigint", :algorithm=>:concurrently})
-> 0.0025s
-- execute("RESET ALL")
-> 0.0005s
-- quote_column_name("deployable_id")
-> 0.0000s
-- quote_column_name("deployable_id_tmp")
-> 0.0000s
-- execute("ALTER TABLE deployments RENAME COLUMN \"deployable_id\" TO \"deployable_id_tmp\"")
-> 0.0005s
-- quote_column_name("deployable_id_convert_to_bigint")
-> 0.0000s
-- quote_column_name("deployable_id")
-> 0.0000s
-- execute("ALTER TABLE deployments RENAME COLUMN \"deployable_id_convert_to_bigint\" TO \"deployable_id\"")
-> 0.0004s
-- quote_column_name("deployable_id_tmp")
-> 0.0000s
-- quote_column_name("deployable_id_convert_to_bigint")
-> 0.0000s
-- execute("ALTER TABLE deployments RENAME COLUMN \"deployable_id_tmp\" TO \"deployable_id_convert_to_bigint\"")
-> 0.0004s
-- quote_table_name("trigger_77f5e1d20482")
-> 0.0000s
-- execute("ALTER FUNCTION \"trigger_77f5e1d20482\" RESET ALL")
-> 0.0005s
-- execute("DROP INDEX index_deployments_on_deployable_type_and_deployable_id")
-> 0.0006s
-- rename_index("deployments", "index_deployments_on_deployable_type_and_deployable_id_bigint", "index_deployments_on_deployable_type_and_deployable_id")
-> 0.0005s
== 20210802131812 FinalizeConvertDeploymentsBigint: reverted (0.0206s) ========
Screenshots or Screencasts (strongly suggested)
How to setup and validate locally (strongly suggested)
Does this MR meet the acceptance criteria?
Conformity
-
I have included changelog trailers, or none are needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) - [x I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?)
-
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) -
I have tested this MR in all supported browsers, or it's not needed. -
I have informed the Infrastructure department of a default or new setting change per definition of done, or it's not needed.
Edited by Simon Tomlinson