修复了自动清理由于外键约束为设置联级删除而不生效的问题

This commit is contained in:
zhangyuheng 2024-03-31 11:20:25 +08:00
parent d345656933
commit 350ba9585f
2 changed files with 14 additions and 1 deletions

View File

@ -6,7 +6,7 @@
<groupId>cn.lunadeer</groupId>
<artifactId>Dominion</artifactId>
<version>1.14.6-beta</version>
<version>1.14.7-beta</version>
<packaging>jar</packaging>
<name>Dominion</name>

View File

@ -194,5 +194,18 @@ public class Database {
// 1.12.0
sql = "ALTER TABLE dominion ADD COLUMN IF NOT EXISTS ender_man BOOLEAN NOT NULL DEFAULT FAlSE;";
query(sql);
// 1.14.7
sql = "ALTER TABLE dominion DROP CONSTRAINT IF EXISTS dominion_owner_fkey;";
sql += "ALTER TABLE dominion ADD CONSTRAINT dominion_owner_fkey FOREIGN KEY (owner) REFERENCES player_name(uuid) ON DELETE CASCADE;";
sql += "ALTER TABLE dominion DROP CONSTRAINT IF EXISTS dominion_parent_dom_id_fkey;";
sql += "ALTER TABLE dominion ADD CONSTRAINT dominion_parent_dom_id_fkey FOREIGN KEY (parent_dom_id) REFERENCES dominion(id) ON DELETE CASCADE;";
sql += "ALTER TABLE player_privilege DROP CONSTRAINT IF EXISTS player_privilege_player_uuid_fkey;";
sql += "ALTER TABLE player_privilege ADD CONSTRAINT player_privilege_player_uuid_fkey FOREIGN KEY (player_uuid) REFERENCES player_name(uuid) ON DELETE CASCADE;";
sql += "ALTER TABLE player_privilege DROP CONSTRAINT IF EXISTS player_privilege_dom_id_fkey;";
sql += "ALTER TABLE player_privilege ADD CONSTRAINT player_privilege_dom_id_fkey FOREIGN KEY (dom_id) REFERENCES dominion(id) ON DELETE CASCADE;";
query(sql);
}
}