PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS "User" (
    "id" TEXT NOT NULL PRIMARY KEY,
    "username" TEXT NOT NULL
);
INSERT INTO User VALUES('afo41yngw19cjh2','fake');
CREATE TABLE IF NOT EXISTS "Session" (
    "id" TEXT NOT NULL PRIMARY KEY,
    "user_id" TEXT NOT NULL,
    "active_expires" BIGINT NOT NULL,
    "idle_expires" BIGINT NOT NULL,
    CONSTRAINT "Session_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO Session VALUES('lwigbqkcyudn0h2xksfjmqomf28mwsq3hjge8xaf','afo41yngw19cjh2',1705150414256,1706360014256);
CREATE TABLE IF NOT EXISTS "Key" (
    "id" TEXT NOT NULL PRIMARY KEY,
    "hashed_password" TEXT,
    "user_id" TEXT NOT NULL,
    CONSTRAINT "Key_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO "Key" VALUES('username:fake','s2:1wc2gp27g4q9vur0:39545e2a52143d9027dafb8dc8a427cfd2a3cce55eb536506ac868c96ed665289cc75a022b967fd5bc24603c4cde8a152a8d94022a7e0c95c22ffd718aadbf21','afo41yngw19cjh2');
CREATE TABLE IF NOT EXISTS "Track" (
    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    "title" TEXT NOT NULL,
    "objectKey" TEXT NOT NULL,
    "producerId" TEXT NOT NULL,
    "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" DATETIME NOT NULL,
    CONSTRAINT "Track_producerId_fkey" FOREIGN KEY ("producerId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO Track VALUES(1,'Meow','507ebeff-6f8e-45a0-9c1b-021a262f350a.mp3','afo41yngw19cjh2',1705065010419,1705065010419);
CREATE TABLE IF NOT EXISTS "TrackVersion" (
    "id" TEXT NOT NULL PRIMARY KEY,
    "trackId" INTEGER NOT NULL,
    "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" DATETIME NOT NULL,
    CONSTRAINT "TrackVersion_trackId_fkey" FOREIGN KEY ("trackId") REFERENCES "Track" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO TrackVersion VALUES('700ab0a6-fbf4-482e-b283-8b3d3984324f',1,1705065010424,1705065010424);
CREATE TABLE IF NOT EXISTS "Comment" (
    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    "content" TEXT NOT NULL,
    "authorId" TEXT NOT NULL,
    "trackVersionId" TEXT NOT NULL,
    "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" DATETIME NOT NULL,
    CONSTRAINT "Comment_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
    CONSTRAINT "Comment_trackVersionId_fkey" FOREIGN KEY ("trackVersionId") REFERENCES "TrackVersion" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO Comment VALUES (1,'UwU','afo41yngw19cjh2','700ab0a6-fbf4-482e-b283-8b3d3984324f',1705078453000,1705078453000);
DELETE FROM sqlite_sequence;
INSERT INTO sqlite_sequence VALUES('Track',1);
CREATE UNIQUE INDEX "User_id_key" ON "User"("id");
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");
CREATE INDEX "User_username_idx" ON "User"("username");
CREATE UNIQUE INDEX "Session_id_key" ON "Session"("id");
CREATE INDEX "Session_user_id_idx" ON "Session"("user_id");
CREATE UNIQUE INDEX "Key_id_key" ON "Key"("id");
CREATE INDEX "Key_user_id_idx" ON "Key"("user_id");
CREATE INDEX "Track_producerId_idx" ON "Track"("producerId");
CREATE INDEX "TrackVersion_trackId_idx" ON "TrackVersion"("trackId");
CREATE INDEX "Comment_authorId_trackVersionId_idx" ON "Comment"("authorId", "trackVersionId");
COMMIT;
