From 8b70327a9d53d31b2f853ffc09e132ef933278a2 Mon Sep 17 00:00:00 2001 From: Grain-Yu <70142140+Grain-Yu@users.noreply.github.com> Date: Tue, 10 Oct 2023 22:27:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=8EV1.9.1=E5=8D=87=E7=BA=A7=E5=88=B01.10.?= =?UTF-8?q?0=E7=89=88=E6=9C=AC=E5=8D=87=E7=BA=A7=E9=81=87=E5=88=B0?= =?UTF-8?q?=E7=9A=84BUG=20#2299?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/hhyo/Archery/issues/2299 --- src/init_sql/v1.10.0.sql | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/init_sql/v1.10.0.sql b/src/init_sql/v1.10.0.sql index c750bed..c739b89 100644 --- a/src/init_sql/v1.10.0.sql +++ b/src/init_sql/v1.10.0.sql @@ -3,10 +3,21 @@ alter table instance_account add db_name varchar(128) default '' not null comment '数据库名(mongodb)' after host; -- instance_account表调整唯一索引 + +-- 删除外键 +set @drop_fk_sql=(select concat('alter table instance_account drop foreign key ',constraint_name) from information_schema.table_constraints where constraint_type='foreign key' and table_name = 'instance_account'); +prepare stmt from @drop_fk_sql; +execute stmt; +drop prepare stmt; + set @drop_sql=(select concat('alter table instance_account drop index ', constraint_name) from information_schema.table_constraints where table_schema=database() and table_name='instance_account' and constraint_type='UNIQUE'); prepare stmt from @drop_sql; execute stmt; drop prepare stmt; alter table instance_account add unique index uidx_instanceid_user_host_dbname(`instance_id`, `user`, `host`, `db_name`); + +-- 然后在索引重建后,再重新添加外键 +alter table instance_account add constraint fk_account_sql_instance_id foreign key (instance_id) references sql_instance(id); + --- 增加 ssl 支持 -ALTER TABLE sql_instance ADD is_ssl tinyint(1) DEFAULT 0 COMMENT '是否启用SSL'; \ No newline at end of file +ALTER TABLE sql_instance ADD is_ssl tinyint(1) DEFAULT 0 COMMENT '是否启用SSL';