diff --git a/bun.lockb b/bun.lockb index 2f1fc70..5cf8ee3 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 998ceef..5a89fa5 100644 --- a/package.json +++ b/package.json @@ -3,16 +3,20 @@ "module": "src/index.ts", "type": "module", "scripts": { - "dev": "bun --watch src/index.ts | pino-pretty" + "dev": "bun --watch src/index.ts | pino-pretty", + "prisma:generate": "prisma generate" }, "devDependencies": { - "@types/bun": "latest" + "@types/bun": "latest", + "prisma": "^6.0.1" }, "peerDependencies": { "typescript": "^5.0.0" }, "dependencies": { "@pothos/core": "^4.3.0", + "@pothos/plugin-prisma": "^4.4.0", + "@prisma/client": "6.0.1", "graphql": "^16.9.0", "graphql-yoga": "^5.10.4", "pino": "^9.5.0", diff --git a/prisma/dev.db b/prisma/dev.db new file mode 100644 index 0000000..33bbdb7 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..8c85613 Binary files /dev/null and b/prisma/dev.db-journal differ diff --git a/prisma/migrations/20241202163245_init/migration.sql b/prisma/migrations/20241202163245_init/migration.sql new file mode 100644 index 0000000..16407fb --- /dev/null +++ b/prisma/migrations/20241202163245_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..0f11436 --- /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 +}