Finalize converting deployments to bigint

Merged Simon Tomlinson requested to merge stomlinson/finalize-convert-deployments into master

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_id to deployable_id_convert_to_bigint is complete
  • Create a new index index_deployments_on_deployable_type_and_deployable_id_bigint to match the existing index
  • Swap the column and index names, and drop the old index.

Database Migration Timing

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

Availability and Testing

Edited by Simon Tomlinson