Add Instance Integrations models
What does this MR do and why?
In order to support integrations in Cells architecture we need to split existing integrations
into group/project integrations (existing integrations
table) and instance wide integrations. In this MR we define new instance integration models which are going to be used later on.
It additionally updates existing (currently empty) instance_integrations
db table to align it's schema with existing integrations
table. We previously created this table trimming any unnecessary columns, but we need them in the end in order to provide a smoother transition. Fewer changes required.
Mentions #474809
Migration output
Up
main: == [advisory_lock_connection] object_id: 126140, pg_backend_pid: 82711
main: == 20241011103239 UpdateInstanceIntegrationTable: migrating ===================
main: -- add_column(:instance_integrations, :project_id, :bigint, {:null=>true})
main: -> 0.0042s
main: -- add_column(:instance_integrations, :group_id, :bigint, {:null=>true})
main: -> 0.0008s
main: -- add_column(:instance_integrations, :inherit_from_id, :bigint, {:null=>true})
main: -> 0.0008s
main: -- add_column(:instance_integrations, :instance, :boolean, {:default=>true})
main: -> 0.0046s
main: -- rename_column(:instance_integrations, :type, :type_new)
main: -> 0.0154s
main: -- transaction_open?(nil)
main: -> 0.0000s
main: -- transaction_open?(nil)
main: -> 0.0000s
main: -- execute("ALTER TABLE instance_integrations\nADD CONSTRAINT project_id_null_constraint\nCHECK ( project_id IS NULL )\nNOT VALID;\n")
main: -> 0.0045s
main: -- execute("SET statement_timeout TO 0")
main: -> 0.0004s
main: -- execute("ALTER TABLE instance_integrations VALIDATE CONSTRAINT project_id_null_constraint;")
main: -> 0.0007s
main: -- execute("RESET statement_timeout")
main: -> 0.0003s
main: -- transaction_open?(nil)
main: -> 0.0000s
main: -- transaction_open?(nil)
main: -> 0.0000s
main: -- execute("ALTER TABLE instance_integrations\nADD CONSTRAINT group_id_null_constraint\nCHECK ( group_id IS NULL )\nNOT VALID;\n")
main: -> 0.0007s
main: -- execute("ALTER TABLE instance_integrations VALIDATE CONSTRAINT group_id_null_constraint;")
main: -> 0.0014s
main: -- transaction_open?(nil)
main: -> 0.0000s
main: -- transaction_open?(nil)
main: -> 0.0000s
main: -- execute("ALTER TABLE instance_integrations\nADD CONSTRAINT inherit_from_id_null_constraint\nCHECK ( inherit_from_id IS NULL )\nNOT VALID;\n")
main: -> 0.0014s
main: -- execute("ALTER TABLE instance_integrations VALIDATE CONSTRAINT inherit_from_id_null_constraint;")
main: -> 0.1876s
main: -- transaction_open?(nil)
main: -> 0.0000s
main: -- transaction_open?(nil)
main: -> 0.0000s
main: -- execute("ALTER TABLE instance_integrations\nADD CONSTRAINT instance_is_true_constraint\nCHECK ( instance = TRUE )\nNOT VALID;\n")
main: -> 0.0015s
main: -- execute("ALTER TABLE instance_integrations VALIDATE CONSTRAINT instance_is_true_constraint;")
main: -> 0.0013s
main: == 20241011103239 UpdateInstanceIntegrationTable: migrated (0.2865s) ==========
main: == [advisory_lock_connection] object_id: 126140, pg_backend_pid: 82711
ci: == [advisory_lock_connection] object_id: 134180, pg_backend_pid: 83133
ci: == 20241011103239 UpdateInstanceIntegrationTable: migrating ===================
ci: -- add_column(:instance_integrations, :project_id, :bigint, {:null=>true})
ci: -> 0.0021s
ci: -- add_column(:instance_integrations, :group_id, :bigint, {:null=>true})
ci: -> 0.0052s
ci: -- add_column(:instance_integrations, :inherit_from_id, :bigint, {:null=>true})
ci: -> 0.0015s
ci: -- add_column(:instance_integrations, :instance, :boolean, {:default=>true})
ci: -> 0.0056s
ci: -- rename_column(:instance_integrations, :type, :type_new)
ci: -> 0.0162s
ci: -- transaction_open?(nil)
ci: -> 0.0000s
ci: -- transaction_open?(nil)
ci: -> 0.0000s
ci: -- execute("ALTER TABLE instance_integrations\nADD CONSTRAINT project_id_null_constraint\nCHECK ( project_id IS NULL )\nNOT VALID;\n")
ci: -> 0.0013s
ci: -- execute("SET statement_timeout TO 0")
ci: -> 0.0004s
ci: -- execute("ALTER TABLE instance_integrations VALIDATE CONSTRAINT project_id_null_constraint;")
ci: -> 0.0011s
ci: -- execute("RESET statement_timeout")
ci: -> 0.0004s
ci: -- transaction_open?(nil)
ci: -> 0.0000s
ci: -- transaction_open?(nil)
ci: -> 0.0000s
ci: -- execute("ALTER TABLE instance_integrations\nADD CONSTRAINT group_id_null_constraint\nCHECK ( group_id IS NULL )\nNOT VALID;\n")
ci: -> 0.0004s
ci: -- execute("ALTER TABLE instance_integrations VALIDATE CONSTRAINT group_id_null_constraint;")
ci: -> 0.0008s
ci: -- transaction_open?(nil)
ci: -> 0.0000s
ci: -- transaction_open?(nil)
ci: -> 0.0000s
ci: -- execute("ALTER TABLE instance_integrations\nADD CONSTRAINT inherit_from_id_null_constraint\nCHECK ( inherit_from_id IS NULL )\nNOT VALID;\n")
ci: -> 0.0025s
ci: -- execute("ALTER TABLE instance_integrations VALIDATE CONSTRAINT inherit_from_id_null_constraint;")
ci: -> 0.0006s
ci: -- transaction_open?(nil)
ci: -> 0.0000s
ci: -- transaction_open?(nil)
ci: -> 0.0000s
ci: -- execute("ALTER TABLE instance_integrations\nADD CONSTRAINT instance_is_true_constraint\nCHECK ( instance = TRUE )\nNOT VALID;\n")
ci: -> 0.0008s
ci: -- execute("ALTER TABLE instance_integrations VALIDATE CONSTRAINT instance_is_true_constraint;")
ci: -> 0.0007s
ci: == 20241011103239 UpdateInstanceIntegrationTable: migrated (0.1041s) ==========
ci: == [advisory_lock_connection] object_id: 134180, pg_backend_pid: 83133
Down
main: == [advisory_lock_connection] object_id: 126200, pg_backend_pid: 81813
main: == 20241011103239 UpdateInstanceIntegrationTable: reverting ===================
main: -- remove_column(:instance_integrations, :project_id, {:if_exists=>true})
main: -> 0.0217s
main: -- remove_column(:instance_integrations, :group_id, {:if_exists=>true})
main: -> 0.0035s
main: -- remove_column(:instance_integrations, :inherit_from_id, {:if_exists=>true})
main: -> 0.0038s
main: -- remove_column(:instance_integrations, :instance, {:if_exists=>true})
main: -> 0.0056s
main: -- rename_column(:instance_integrations, :type_new, :type)
main: -> 0.0033s
main: == 20241011103239 UpdateInstanceIntegrationTable: reverted (0.0478s) ==========
main: == [advisory_lock_connection] object_id: 126200, pg_backend_pid: 81813
ci: == [advisory_lock_connection] object_id: 126140, pg_backend_pid: 82231
ci: == 20241011103239 UpdateInstanceIntegrationTable: reverting ===================
ci: -- remove_column(:instance_integrations, :project_id, {:if_exists=>true})
ci: -> 0.0295s
ci: -- remove_column(:instance_integrations, :group_id, {:if_exists=>true})
ci: -> 0.0030s
ci: -- remove_column(:instance_integrations, :inherit_from_id, {:if_exists=>true})
ci: -> 0.0046s
ci: -- remove_column(:instance_integrations, :instance, {:if_exists=>true})
ci: -> 0.0035s
ci: -- rename_column(:instance_integrations, :type_new, :type)
ci: -> 0.0028s
ci: == 20241011103239 UpdateInstanceIntegrationTable: reverted (0.0593s) ==========
ci: == [advisory_lock_connection] object_id: 126140, pg_backend_pid: 82231
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
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.