Skip to content
代码片段 群组 项目
提交 ca9fe296 编辑于 作者: Kamil Trzciński's avatar Kamil Trzciński
浏览文件

Cells: Remove `broadcast_messages.namespace_id` foreign key

As part of column removal lets first remove foreign key.
上级 c8d19426
No related branches found
No related tags found
无相关合并请求
......@@ -3,6 +3,7 @@
class BroadcastMessage < MainClusterwide::ApplicationRecord
include CacheMarkdownField
include Sortable
include IgnorableColumns
ALLOWED_TARGET_ACCESS_LEVELS = [
Gitlab::Access::GUEST,
......@@ -12,6 +13,8 @@ class BroadcastMessage < MainClusterwide::ApplicationRecord
Gitlab::Access::OWNER
].freeze
ignore_column :namespace_id, remove_with: '16.0', remove_after: '2022-06-22'
cache_markdown_field :message, pipeline: :broadcast_message, whitelisted: true
validates :message, presence: true
......
# frozen_string_literal: true
class RemoveNamespacesBroadcastMessagesNamespaceIdFk < Gitlab::Database::Migration[2.1]
disable_ddl_transaction!
def up
return unless foreign_key_exists?(:broadcast_messages, :namespaces, name: "fk_7bf2ec43da")
with_lock_retries do
remove_foreign_key_if_exists(:broadcast_messages, :namespaces,
name: "fk_7bf2ec43da", reverse_lock_order: true)
end
end
def down
add_concurrent_foreign_key(:broadcast_messages, :namespaces,
name: "fk_7bf2ec43da", column: :namespace_id,
target_column: :id, on_delete: :cascade)
end
end
f2b7e2856672f294a7686a61d3b953b8341b21b31a60a2f62419e878c3244d64
\ No newline at end of file
......@@ -34484,9 +34484,6 @@ ALTER TABLE ONLY vulnerabilities
ALTER TABLE ONLY issue_customer_relations_contacts
ADD CONSTRAINT fk_7b92f835bb FOREIGN KEY (contact_id) REFERENCES customer_relations_contacts(id) ON DELETE CASCADE;
 
ALTER TABLE ONLY broadcast_messages
ADD CONSTRAINT fk_7bf2ec43da FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
ALTER TABLE ONLY vulnerabilities
ADD CONSTRAINT fk_7c5bb22a22 FOREIGN KEY (due_date_sourcing_milestone_id) REFERENCES milestones(id) ON DELETE SET NULL;
 
......@@ -168,9 +168,8 @@ def generate_migration(definition)
return unless foreign_key_exists?(:#{definition.from_table}, :#{definition.to_table}, name: "#{definition.name}")
with_lock_retries do
execute('LOCK #{definition.to_table}, #{definition.from_table} IN ACCESS EXCLUSIVE MODE') if transaction_open?
remove_foreign_key_if_exists(:#{definition.from_table}, :#{definition.to_table}, name: "#{definition.name}")
remove_foreign_key_if_exists(:#{definition.from_table}, :#{definition.to_table},
name: "#{definition.name}", reverse_lock_order: true)
end
end
......
......@@ -31,6 +31,7 @@
award_emoji: %w[awardable_id user_id],
aws_roles: %w[role_external_id],
boards: %w[milestone_id iteration_id],
broadcast_messages: %w[namespace_id],
chat_names: %w[chat_id team_id user_id integration_id],
chat_teams: %w[team_id],
ci_build_needs: %w[partition_id build_id],
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册