25 lines
906 B
SQL
25 lines
906 B
SQL
-- CreateTable
|
|
CREATE TABLE "Score" (
|
|
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
"accuracy" REAL NOT NULL,
|
|
"best_id" INTEGER,
|
|
"created_at" DATETIME NOT NULL,
|
|
"score_id" INTEGER,
|
|
"score" INTEGER NOT NULL,
|
|
"beatmap_id" INTEGER NOT NULL,
|
|
"beatmapset_id" INTEGER NOT NULL,
|
|
"user_id" INTEGER NOT NULL
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "Transition" (
|
|
"before_id" INTEGER NOT NULL,
|
|
"after_id" INTEGER NOT NULL,
|
|
|
|
PRIMARY KEY ("before_id", "after_id"),
|
|
CONSTRAINT "Transition_before_id_fkey" FOREIGN KEY ("before_id") REFERENCES "Score" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
CONSTRAINT "Transition_after_id_fkey" FOREIGN KEY ("after_id") REFERENCES "Score" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "Score_user_id_beatmap_id_created_at_score_key" ON "Score"("user_id", "beatmap_id", "created_at", "score");
|