Add Prisma integration with SQLite, update dependencies, and configure Svelte

This commit is contained in:
Norbert Maciaszek
2025-11-24 21:40:52 +01:00
parent ca22858160
commit 0a6e627e77
11 changed files with 1725 additions and 9 deletions

View File

@@ -0,0 +1,24 @@
-- CreateTable
CREATE TABLE "Year" (
"year" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT
);
-- CreateTable
CREATE TABLE "Person" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" TEXT NOT NULL,
"yearId" INTEGER NOT NULL,
CONSTRAINT "Person_yearId_fkey" FOREIGN KEY ("yearId") REFERENCES "Year" ("year") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "Gift" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" TEXT NOT NULL,
"url" TEXT,
"description" TEXT,
"price" REAL,
"status" TEXT NOT NULL DEFAULT 'PLANNED',
"personId" INTEGER NOT NULL,
CONSTRAINT "Gift_personId_fkey" FOREIGN KEY ("personId") REFERENCES "Person" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);

View File

@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (e.g., Git)
provider = "sqlite"

46
prisma/schema.prisma Normal file
View File

@@ -0,0 +1,46 @@
// 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"
}
model Year {
year Int @id
people Person[]
}
model Person {
id Int @id @default(autoincrement())
name String
yearId Int
year Year @relation(fields: [yearId], references: [year])
gifts Gift[]
}
model Gift {
id Int @id @default(autoincrement())
name String
url String?
description String?
price Float?
status GiftStatus @default(PLANNED)
personId Int
person Person @relation(fields: [personId], references: [id])
}
enum GiftStatus {
PLANNED
BUY
BOUGHT
WRAPPED
GIVEN
}