From 89f28765faa8c2754289b7926f85bdfb5c0c2d77 Mon Sep 17 00:00:00 2001 From: Mathias Private Laptop Date: Tue, 9 Apr 2024 20:48:45 +0200 Subject: [PATCH] (feat): Enable having multiple schema files for prisma before https://github.com/prisma/prisma/issues/2377 is resolved through prisma-multischema --- apps/api/package.json | 2 ++ apps/api/{src/database => prisma}/prisma.service.ts | 0 apps/api/prisma/schema.prisma | 7 +++++++ apps/api/prisma/subschemas/movies.prisma | 6 ++++++ 4 files changed, 15 insertions(+) rename apps/api/{src/database => prisma}/prisma.service.ts (100%) create mode 100644 apps/api/prisma/schema.prisma create mode 100644 apps/api/prisma/subschemas/movies.prisma diff --git a/apps/api/package.json b/apps/api/package.json index faa28e5..c146766 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -17,6 +17,7 @@ "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:e2e": "jest --config ./test/jest-e2e.json", + "db:generate": "npx prisma-multischema generate", "db:migrate": "npx prisma migrate dev", "db:deploy": "npx prisma migrate deploy", "console": "npm run start -- --watch --entryFile repl" @@ -59,6 +60,7 @@ "jest": "^29.7.0", "prettier": "^3.0.0", "prisma": "^5.11.0", + "prisma-multischema": "^1.1.4", "source-map-support": "^0.5.21", "supertest": "^6.3.3", "ts-jest": "^29.1.0", diff --git a/apps/api/src/database/prisma.service.ts b/apps/api/prisma/prisma.service.ts similarity index 100% rename from apps/api/src/database/prisma.service.ts rename to apps/api/prisma/prisma.service.ts diff --git a/apps/api/prisma/schema.prisma b/apps/api/prisma/schema.prisma new file mode 100644 index 0000000..b14cf8f --- /dev/null +++ b/apps/api/prisma/schema.prisma @@ -0,0 +1,7 @@ +//🧩Don't Edit this file.✨Generated in Tue Apr 09 2024 20:47:08 GMT+0200 (Central European Summer Time)✨ +model Movie { + id Int @id @default(autoincrement()) + title String + director String + createdAt DateTime @default(now()) +} diff --git a/apps/api/prisma/subschemas/movies.prisma b/apps/api/prisma/subschemas/movies.prisma new file mode 100644 index 0000000..edd1709 --- /dev/null +++ b/apps/api/prisma/subschemas/movies.prisma @@ -0,0 +1,6 @@ +model Movie { + id Int @id @default(autoincrement()) + title String + director String + createdAt DateTime @default(now()) +} \ No newline at end of file