Skip to content
代码片段 群组 项目
未验证 提交 4917d415 编辑于 作者: George Koltsov's avatar George Koltsov 提交者: GitLab
浏览文件

Update instance_integrations table to match integrations schema

- Add project_id/group_id/inherit_from_id columns to match existing
integrations table for easier transition of data
- Add IS NULL constraints to project_id/group_id/inherit_from_id since
these values will always be null for instance integrations
- Add instance=true constraint

Changelog: other
上级 d1939d0e
No related branches found
No related tags found
无相关合并请求
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
module Integrations module Integrations
class InstanceIntegration < Integration class InstanceIntegration < Integration
include IgnorableColumns
self.table_name = 'instance_integrations' self.table_name = 'instance_integrations'
self.inheritance_column = :type_new # rubocop:disable Database/AvoidInheritanceColumn -- supporting instance integrations migration
ignore_column :type, remove_with: '17.7', remove_after: '2024-12-02'
end end
end end
# frozen_string_literal: true
class UpdateInstanceIntegrationsTable < Gitlab::Database::Migration[2.2]
milestone '17.6'
disable_ddl_transaction!
def up
add_column :instance_integrations, :project_id, :bigint, null: true, if_not_exists: true
add_column :instance_integrations, :group_id, :bigint, null: true, if_not_exists: true
add_column :instance_integrations, :inherit_from_id, :bigint, null: true, if_not_exists: true
add_column :instance_integrations, :instance, :boolean, default: true, if_not_exists: true
add_check_constraint :instance_integrations, 'project_id IS NULL', 'project_id_null_constraint'
add_check_constraint :instance_integrations, 'group_id IS NULL', 'group_id_null_constraint'
add_check_constraint :instance_integrations, 'inherit_from_id IS NULL', 'inherit_from_id_null_constraint'
add_check_constraint :instance_integrations, 'instance = TRUE', 'instance_is_true_constraint'
end
def down
remove_column :instance_integrations, :project_id, if_exists: true
remove_column :instance_integrations, :group_id, if_exists: true
remove_column :instance_integrations, :inherit_from_id, if_exists: true
remove_column :instance_integrations, :instance, if_exists: true
end
end
# frozen_string_literal: true
class RenameInstanceIntegrationsTypeToTypeNew < Gitlab::Database::Migration[2.2]
milestone '17.6'
disable_ddl_transaction!
def up
rename_column_concurrently :instance_integrations, :type, :type_new
end
def down
undo_rename_column_concurrently :instance_integrations, :type, :type_new
end
end
# frozen_string_literal: true
class CleanupInstanceIntegrationsTypeRename < Gitlab::Database::Migration[2.2]
milestone '17.6'
disable_ddl_transaction!
def up
cleanup_concurrent_column_rename :instance_integrations, :type, :type_new
end
def down
undo_cleanup_concurrent_column_rename :instance_integrations, :type, :type_new
end
end
dcfbdf675f0ebc3b0a05881fa19cffcf505f977c86d355e0a67535c96f309945
\ No newline at end of file
a1d6a2bbb0053e26d256ea9a86e618df16e73cb91cbbdb74772c8c5c4d5368a9
\ No newline at end of file
573b6e641a7da39f16be66702d687f266d4bf084e6816acd98380716cc09d5bf
\ No newline at end of file
...@@ -12720,11 +12720,19 @@ CREATE TABLE instance_integrations ( ...@@ -12720,11 +12720,19 @@ CREATE TABLE instance_integrations (
group_mention_events boolean DEFAULT false NOT NULL, group_mention_events boolean DEFAULT false NOT NULL,
group_confidential_mention_events boolean DEFAULT false NOT NULL, group_confidential_mention_events boolean DEFAULT false NOT NULL,
category text DEFAULT 'common'::text, category text DEFAULT 'common'::text,
type text,
encrypted_properties bytea, encrypted_properties bytea,
encrypted_properties_iv bytea, encrypted_properties_iv bytea,
project_id bigint,
group_id bigint,
inherit_from_id bigint,
instance boolean DEFAULT true,
type_new text,
CONSTRAINT check_2f305455fe CHECK ((char_length(type_new) <= 255)),
CONSTRAINT check_611836812c CHECK ((char_length(category) <= 255)), CONSTRAINT check_611836812c CHECK ((char_length(category) <= 255)),
CONSTRAINT check_69b7b09aa8 CHECK ((char_length(type) <= 255)) CONSTRAINT group_id_null_constraint CHECK ((group_id IS NULL)),
CONSTRAINT inherit_from_id_null_constraint CHECK ((inherit_from_id IS NULL)),
CONSTRAINT instance_is_true_constraint CHECK ((instance = true)),
CONSTRAINT project_id_null_constraint CHECK ((project_id IS NULL))
); );
   
CREATE SEQUENCE instance_integrations_id_seq CREATE SEQUENCE instance_integrations_id_seq
...@@ -230,7 +230,8 @@ ...@@ -230,7 +230,8 @@
ai_testing_terms_acceptances: %w[user_id], # testing terms only have 1 entry, and if the user is deleted the record should remain ai_testing_terms_acceptances: %w[user_id], # testing terms only have 1 entry, and if the user is deleted the record should remain
namespace_settings: %w[early_access_program_joined_by_id], # isn't used inside product itself. Only through Snowflake namespace_settings: %w[early_access_program_joined_by_id], # isn't used inside product itself. Only through Snowflake
workspaces_agent_config_versions: %w[item_id], # polymorphic associations workspaces_agent_config_versions: %w[item_id], # polymorphic associations
work_item_types: %w[correct_id] # temporary column that is not a foreign key work_item_types: %w[correct_id], # temporary column that is not a foreign key
instance_integrations: %w[project_id group_id inherit_from_id] # these columns are not used in instance integrations
}.with_indifferent_access.freeze }.with_indifferent_access.freeze
context 'for table' do context 'for table' do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册