Implement License Key API

This commit is contained in:
NeilClack
2026-02-19 13:00:08 -06:00
parent aa51b4a452
commit 664b6daa7f
11 changed files with 1683 additions and 10 deletions
@@ -0,0 +1,13 @@
-- CreateTable
CREATE TABLE "LicenseKey" (
"id" TEXT NOT NULL,
"key" TEXT NOT NULL,
"active" BOOLEAN NOT NULL,
"level" TEXT NOT NULL,
"userId" TEXT NOT NULL,
CONSTRAINT "LicenseKey_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "LicenseKey" ADD CONSTRAINT "LicenseKey_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
+15 -5
View File
@@ -14,18 +14,19 @@ datasource db {
}
model User {
id String @id
id String @id
name String
email String
emailVerified Boolean @default(false)
emailVerified Boolean @default(false)
image String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
roleId Int?
role UserRole? @relation(fields: [roleId], references: [id])
role UserRole? @relation(fields: [roleId], references: [id])
sessions Session[]
accounts Account[]
profile Profile?
licenseKeys LicenseKey[]
@@unique([email])
@@map("user")
@@ -131,3 +132,12 @@ model AffirmationCategory {
name String @unique
affirmations Affirmation[]
}
model LicenseKey {
id String @id @default(uuid())
key String
active Boolean
level String
userId String
user User @relation(fields: [userId], references: [id])
}