refactor: 统一数据库约束维护位置
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
xinian
2026-04-27 00:57:18 +08:00
parent ec1855dfac
commit ba1a1ffbea
3 changed files with 5 additions and 27 deletions

View File

@@ -1,7 +1,6 @@
-- server_show 冠名索引修复
-- 目的
-- 1. 允许同一服务器存在多个不同玩家的冠名记录
-- 2. 保证同一玩家对同一服务器只有一条记录续费更新该记录
-- 目的允许同一服务器存在多个不同玩家的冠名记录
-- 同服同属主唯一约束统一在 约束类.sql 中维护
BEGIN;
@@ -12,12 +11,4 @@ DROP INDEX IF EXISTS idx_server_show_server_id;
-- 保留普通查询索引
CREATE INDEX IF NOT EXISTS idx_server_show_server_id ON server_show (server_id);
-- 保证一个玩家对一个服务器最多一条
ALTER TABLE server_show DROP CONSTRAINT IF EXISTS idx_server_show_server_owner;
DROP INDEX IF EXISTS idx_server_show_server_owner;
CREATE UNIQUE INDEX IF NOT EXISTS idx_server_show_server_owner
ON server_show (server_id, owner)
WHERE deleted_at IS NULL;
COMMIT;