Skip to content
代码片段 群组 项目
提交 f70ed6fb 编辑于 作者: Thong Kuah's avatar Thong Kuah
浏览文件

Update LFK script to generate constant for migration

上级 230fa199
No related branches found
No related tags found
加载中
......@@ -164,18 +164,20 @@ def generate_migration(definition)
class Remove#{definition.to_table.camelcase}#{definition.from_table.camelcase}#{definition.column.camelcase}Fk < Gitlab::Database::Migration[2.1]
disable_ddl_transaction!
FOREIGN_KEY_NAME = "#{definition.name}"
def up
return unless foreign_key_exists?(:#{definition.from_table}, :#{definition.to_table}, name: "#{definition.name}")
return unless foreign_key_exists?(:#{definition.from_table}, :#{definition.to_table}, name: FOREIGN_KEY_NAME)
with_lock_retries do
remove_foreign_key_if_exists(:#{definition.from_table}, :#{definition.to_table},
name: "#{definition.name}", reverse_lock_order: true)
name: FOREIGN_KEY_NAME, reverse_lock_order: true)
end
end
def down
add_concurrent_foreign_key(:#{definition.from_table}, :#{definition.to_table},
name: "#{definition.name}", column: :#{definition.column},
name: FOREIGN_KEY_NAME, column: :#{definition.column},
target_column: :#{definition.primary_key}, on_delete: :#{definition.on_delete})
end
end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册