From 4bf35e52390ecb78d95c45e2122fbcdd5774f053 Mon Sep 17 00:00:00 2001 From: Kamil Date: Wed, 2 Dec 2020 14:29:05 +0100 Subject: [PATCH] added some unique constraints --- src/Database.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Database.cpp b/src/Database.cpp index 73caad8..db4a2f7 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -98,11 +98,12 @@ void Database::createTables() { "SkywayLocationFlag2" INTEGER DEFAULT 0 NOT NULL, "CurrentMissionID" INTEGER DEFAULT 0 NOT NULL, PRIMARY KEY("PlayerID" AUTOINCREMENT), - FOREIGN KEY("AccountID") REFERENCES "Accounts"("AccountID") ON DELETE CASCADE + FOREIGN KEY("AccountID") REFERENCES "Accounts"("AccountID") ON DELETE CASCADE, + UNIQUE ("AccountID", "Slot") ); CREATE TABLE IF NOT EXISTS "Appearances" ( - "PlayerID" INTEGER NOT NULL, + "PlayerID" INTEGER UNIQUE NOT NULL, "Body" INTEGER DEFAULT 0 NOT NULL, "EyeColor" INTEGER DEFAULT 1 NOT NULL, "FaceStyle" INTEGER DEFAULT 1 NOT NULL, @@ -120,16 +121,18 @@ void Database::createTables() { "Id" INTEGER NOT NULL, "Type" INTEGER NOT NULL, "Opt" INTEGER NOT NULL, - "TimeLimit" INTEGER NOT DEFALUT 0 NULL, - FOREIGN KEY("PlayerID") REFERENCES "Players"("PlayerID") ON DELETE CASCADE + "TimeLimit" INTEGER DEFAULT 0 NOT NULL, + FOREIGN KEY("PlayerID") REFERENCES "Players"("PlayerID") ON DELETE CASCADE, + UNIQUE ("PlayerId", "Slot") ); CREATE TABLE IF NOT EXISTS "Nanos" ( "PlayerId" INTEGER NOT NULL, "Id" INTEGER NOT NULL, "Skill" INTEGER NOT NULL, - "Stamina" INTEGER DEFAULT = 150 NOT NULL, - FOREIGN KEY("PlayerID") REFERENCES "Players"("PlayerID") ON DELETE CASCADE + "Stamina" INTEGER DEFAULT 150 NOT NULL, + FOREIGN KEY("PlayerID") REFERENCES "Players"("PlayerID") ON DELETE CASCADE, + UNIQUE ("PlayerId", "Id") ); CREATE TABLE IF NOT EXISTS "RunningQuests" (