Skip to content

Commit

Permalink
调整instance_account唯一索引 (#2179)
Browse files Browse the repository at this point in the history
调整instance_account唯一索引
  • Loading branch information
nick2wang committed Jun 18, 2023
1 parent 59c89bc commit 07ef383
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sql/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ class InstanceAccount(models.Model):
class Meta:
managed = True
db_table = "instance_account"
unique_together = ("instance", "user", "host")
unique_together = ("instance", "user", "host", "db_name")
verbose_name = "实例账号列表"
verbose_name_plural = "实例账号列表"

Expand Down
7 changes: 7 additions & 0 deletions src/init_sql/v1.9.2.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-- https://github.com/hhyo/Archery/pull/2108
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`);

0 comments on commit 07ef383

Please sign in to comment.