feat: add DiscoverySeedContribution + ScanWorkItem tables
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "DiscoverySeedContribution" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"candidateMbid" TEXT NOT NULL,
|
||||||
|
"candidateName" TEXT NOT NULL,
|
||||||
|
"seedMbid" TEXT NOT NULL,
|
||||||
|
"score" DOUBLE PRECISION NOT NULL,
|
||||||
|
"sources" TEXT[],
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "DiscoverySeedContribution_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "ScanWorkItem" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"scanId" TEXT NOT NULL,
|
||||||
|
"artist" TEXT NOT NULL,
|
||||||
|
"album" TEXT NOT NULL,
|
||||||
|
"path" TEXT NOT NULL,
|
||||||
|
"done" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
|
||||||
|
CONSTRAINT "ScanWorkItem_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "DiscoverySeedContribution_candidateMbid_seedMbid_key" ON "DiscoverySeedContribution"("candidateMbid", "seedMbid");
|
||||||
|
CREATE INDEX "DiscoverySeedContribution_candidateMbid_idx" ON "DiscoverySeedContribution"("candidateMbid");
|
||||||
|
CREATE INDEX "DiscoverySeedContribution_seedMbid_idx" ON "DiscoverySeedContribution"("seedMbid");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "ScanWorkItem_scanId_path_key" ON "ScanWorkItem"("scanId", "path");
|
||||||
|
CREATE INDEX "ScanWorkItem_scanId_done_artist_album_idx" ON "ScanWorkItem"("scanId", "done", "artist", "album");
|
||||||
@@ -155,3 +155,29 @@ model DiscoverySuggestion {
|
|||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model DiscoverySeedContribution {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
candidateMbid String
|
||||||
|
candidateName String
|
||||||
|
seedMbid String
|
||||||
|
score Float
|
||||||
|
sources String[]
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
@@unique([candidateMbid, seedMbid])
|
||||||
|
@@index([candidateMbid])
|
||||||
|
@@index([seedMbid])
|
||||||
|
}
|
||||||
|
|
||||||
|
model ScanWorkItem {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
scanId String
|
||||||
|
artist String
|
||||||
|
album String
|
||||||
|
path String
|
||||||
|
done Boolean @default(false)
|
||||||
|
|
||||||
|
@@unique([scanId, path])
|
||||||
|
@@index([scanId, done, artist, album])
|
||||||
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ def conn():
|
|||||||
cur.execute('DELETE FROM "MonitoredRelease"')
|
cur.execute('DELETE FROM "MonitoredRelease"')
|
||||||
cur.execute('DELETE FROM "WatchedArtist"')
|
cur.execute('DELETE FROM "WatchedArtist"')
|
||||||
cur.execute('DELETE FROM "DiscoverySuggestion"')
|
cur.execute('DELETE FROM "DiscoverySuggestion"')
|
||||||
|
cur.execute('DELETE FROM "DiscoverySeedContribution"')
|
||||||
|
cur.execute('DELETE FROM "ScanWorkItem"')
|
||||||
cur.execute('DELETE FROM "Config"')
|
cur.execute('DELETE FROM "Config"')
|
||||||
connection.commit()
|
connection.commit()
|
||||||
yield connection
|
yield connection
|
||||||
@@ -43,6 +45,8 @@ def conn():
|
|||||||
cur.execute('DELETE FROM "MonitoredRelease"')
|
cur.execute('DELETE FROM "MonitoredRelease"')
|
||||||
cur.execute('DELETE FROM "WatchedArtist"')
|
cur.execute('DELETE FROM "WatchedArtist"')
|
||||||
cur.execute('DELETE FROM "DiscoverySuggestion"')
|
cur.execute('DELETE FROM "DiscoverySuggestion"')
|
||||||
|
cur.execute('DELETE FROM "DiscoverySeedContribution"')
|
||||||
|
cur.execute('DELETE FROM "ScanWorkItem"')
|
||||||
cur.execute('DELETE FROM "Config"')
|
cur.execute('DELETE FROM "Config"')
|
||||||
connection.commit()
|
connection.commit()
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user