Skip to content

Instantly share code, notes, and snippets.

@dextercd
Created August 17, 2022 17:53
Show Gist options
  • Save dextercd/e075acc2c21d2fb29d34811e98470fa0 to your computer and use it in GitHub Desktop.
Save dextercd/e075acc2c21d2fb29d34811e98470fa0 to your computer and use it in GitHub Desktop.
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
model User {
id String @id @unique
favColor String?
// duelStats Duels[]
nfds NFDItem[]
lastRandom DateTime @default(dbgenerated("0"))
lastLoss DateTime @default(dbgenerated("0"))
}
model NFDItem {
id Int @id @default(autoincrement())
// name String @id @unique
name String @unique
code String @unique
filename String @unique
owner User @relation(fields: [ownerId], references: [id])
ownerId String
mintDate DateTime @default(dbgenerated("0"))
previousOwners String @default("")
}
model NFDEnjoyer {
id String @id @unique
mintCount Int @default(0)
lastMint DateTime @default(dbgenerated("0"))
lastGiftGiven DateTime @default(dbgenerated("0"))
lastSlurp DateTime @default(dbgenerated("0"))
lastRename DateTime @default(dbgenerated("0"))
consecutiveFails Int @default(4)
successfulMints Int @default(0)
failedMints Int @default(0)
favourite Int @default(-1)
}
CREATE TABLE IF NOT EXISTS "User" (
"id" TEXT NOT NULL PRIMARY KEY,
"favColor" TEXT,
"lastRandom" DATETIME NOT NULL DEFAULT 0,
"lastLoss" DATETIME NOT NULL DEFAULT 0
);
CREATE TABLE IF NOT EXISTS "NFDItem" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" TEXT NOT NULL,
"code" TEXT NOT NULL,
"filename" TEXT NOT NULL,
"ownerId" TEXT NOT NULL,
"mintDate" DATETIME NOT NULL DEFAULT 0,
"previousOwners" TEXT NOT NULL DEFAULT '',
CONSTRAINT "NFDItem_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NOT EXISTS "NFDEnjoyer" (
"id" TEXT NOT NULL PRIMARY KEY,
"mintCount" INTEGER NOT NULL DEFAULT 0,
"lastMint" DATETIME NOT NULL DEFAULT 0,
"lastGiftGiven" DATETIME NOT NULL DEFAULT 0,
"lastSlurp" DATETIME NOT NULL DEFAULT 0,
"lastRename" DATETIME NOT NULL DEFAULT 0,
"consecutiveFails" INTEGER NOT NULL DEFAULT 4,
"successfulMints" INTEGER NOT NULL DEFAULT 0,
"failedMints" INTEGER NOT NULL DEFAULT 0,
"favourite" INTEGER NOT NULL DEFAULT -1
);
CREATE UNIQUE INDEX "User_id_key" ON "User"("id");
CREATE UNIQUE INDEX "NFDItem_name_key" ON "NFDItem"("name");
CREATE UNIQUE INDEX "NFDItem_code_key" ON "NFDItem"("code");
CREATE UNIQUE INDEX "NFDItem_filename_key" ON "NFDItem"("filename");
CREATE UNIQUE INDEX "NFDEnjoyer_id_key" ON "NFDEnjoyer"("id");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment