Skip to content

Commit

Permalink
Update v1.10.0.sql
Browse files Browse the repository at this point in the history
Resolved delete uniq index: instance_account_instance_id_user_host_514c1ac6_uniq to raise fk error.
  • Loading branch information
willianflasky authored Dec 17, 2024
1 parent d97ccdc commit e9b6ce2
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/init_sql/v1.10.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,25 @@ alter table instance_account
add db_name varchar(128) default '' not null comment '数据库名(mongodb)' after host;

-- instance_account表调整唯一索引
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`);
-- 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`);

-- resolved delete uniq index: instance_account_instance_id_user_host_514c1ac6_uniq to raise fk error.
-- 禁用外键检查
SET foreign_key_checks = 0;
-- 删除外键约束
ALTER TABLE instance_account DROP FOREIGN KEY instance_account_instance_id_53a7a305_fk_sql_instance_id;
-- 删除不需要的唯一索引
ALTER TABLE instance_account DROP INDEX instance_account_instance_id_user_host_514c1ac6_uniq;
-- 添加新的唯一索引
ALTER TABLE instance_account ADD UNIQUE INDEX uidx_instanceid_user_host_dbname(`instance_id`, `user`, `host`, `db_name`);
-- 重新添加外键约束
ALTER TABLE instance_account ADD CONSTRAINT instance_account_instance_id_53a7a305_fk_sql_instance_id FOREIGN KEY (`instance_id`) REFERENCES sql_instance (`id`);
-- 重新启用外键检查
SET foreign_key_checks = 1;

--- 增加 ssl 支持
ALTER TABLE sql_instance ADD is_ssl tinyint(1) DEFAULT 0 COMMENT '是否启用SSL';
ALTER TABLE sql_instance ADD is_ssl tinyint(1) DEFAULT 0 COMMENT '是否启用SSL';

0 comments on commit e9b6ce2

Please sign in to comment.