diff --git a/.env b/.env new file mode 100644 index 0000000..02ba082 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +VITE_APP_VERSION=1.0.0-alpha +DATABASE_URL="file:./dev.db" \ No newline at end of file diff --git a/.env.development b/.env.development deleted file mode 100644 index 3283edf..0000000 --- a/.env.development +++ /dev/null @@ -1 +0,0 @@ -VITE_APP_VERSION=1.0.0-alpha \ No newline at end of file diff --git a/.gitignore b/.gitignore index 68204fe..ce55f38 100644 --- a/.gitignore +++ b/.gitignore @@ -13,13 +13,6 @@ node_modules .DS_Store Thumbs.db -# Env -.env -.env.* -!.env.example -!.env.test -!.env.development - # Vite vite.config.js.timestamp-* vite.config.ts.timestamp-* diff --git a/bun.lockb b/bun.lockb index 50ee1dc..83c74e3 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 292b9d9..a87cdc4 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "test": "npm run test:unit -- --run && npm run test:e2e", "storybook": "storybook dev -p 6006", "build-storybook": "storybook build", - "test:e2e": "playwright test" + "test:e2e": "playwright test", + "prisma:generate": "prisma generate" }, "devDependencies": { "@chromatic-com/storybook": "^3.2.2", @@ -38,6 +39,7 @@ "prettier": "^3.3.2", "prettier-plugin-svelte": "^3.2.6", "prettier-plugin-tailwindcss": "^0.6.5", + "prisma": "^6.0.1", "storybook": "^8.4.7", "svelte": "^5.0.0", "svelte-check": "^4.0.0", @@ -49,6 +51,7 @@ }, "dependencies": { "@pothos/core": "^4.3.0", + "@prisma/client": "6.0.1", "@tailwindcss/typography": "^0.5.15", "@types/bun": "^1.1.14", "graphql": "^16.9.0", @@ -58,4 +61,4 @@ "storybook-dark-mode": "^4.0.2", "zod": "^3.24.0" } -} +} \ No newline at end of file diff --git a/prisma/dev.db b/prisma/dev.db new file mode 100644 index 0000000..14dfc11 Binary files /dev/null and b/prisma/dev.db differ diff --git a/prisma/dev.db-journal b/prisma/dev.db-journal new file mode 100644 index 0000000..be0024e Binary files /dev/null and b/prisma/dev.db-journal differ diff --git a/prisma/migrations/20241210153750_init/migration.sql b/prisma/migrations/20241210153750_init/migration.sql new file mode 100644 index 0000000..16407fb --- /dev/null +++ b/prisma/migrations/20241210153750_init/migration.sql @@ -0,0 +1,19 @@ +-- CreateTable +CREATE TABLE "User" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "email" TEXT NOT NULL, + "name" TEXT +); + +-- CreateTable +CREATE TABLE "Post" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "title" TEXT NOT NULL, + "content" TEXT, + "published" BOOLEAN NOT NULL DEFAULT false, + "authorId" INTEGER NOT NULL, + CONSTRAINT "Post_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); + +-- CreateIndex +CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml new file mode 100644 index 0000000..e5e5c47 --- /dev/null +++ b/prisma/migrations/migration_lock.toml @@ -0,0 +1,3 @@ +# Please do not edit this file manually +# It should be added in your version-control system (i.e. Git) +provider = "sqlite" \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma new file mode 100644 index 0000000..0cd53f5 --- /dev/null +++ b/prisma/schema.prisma @@ -0,0 +1,31 @@ +// 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" +} + +generator pothos { + provider = "prisma-pothos-types" +} + +datasource db { + provider = "sqlite" + url = env("DATABASE_URL") +} + +model User { + id Int @id @default(autoincrement()) + email String @unique + name String? + posts Post[] +} + +model Post { + id Int @id @default(autoincrement()) + title String + content String? + published Boolean @default(false) + author User @relation(fields: [authorId], references: [id]) + authorId Int +} \ No newline at end of file diff --git a/src/lib/prisma/index.ts b/src/lib/prisma/index.ts new file mode 100644 index 0000000..fbb7b51 --- /dev/null +++ b/src/lib/prisma/index.ts @@ -0,0 +1,3 @@ +import { PrismaClient } from '@prisma/client'; + +export const prisma = new PrismaClient(); \ No newline at end of file