feat: convert to nextjs

This commit is contained in:
2024-12-07 07:45:24 +01:00
parent b248ee80ee
commit 633b8ee207
52 changed files with 4121 additions and 982 deletions

View File

@@ -0,0 +1,26 @@
-- CreateTable
CREATE TABLE "consumer" (
"id" SERIAL NOT NULL,
"letters" TEXT NOT NULL,
"year" INTEGER NOT NULL,
"zipCode" TEXT NOT NULL,
"persona" JSONB NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "consumer_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "purchases" (
"id" SERIAL NOT NULL,
"value" JSONB NOT NULL,
"consumerId" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "purchases_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "purchases" ADD CONSTRAINT "purchases_consumerId_fkey" FOREIGN KEY ("consumerId") REFERENCES "consumer"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@@ -0,0 +1,17 @@
/*
Warnings:
- You are about to drop the column `persona` on the `consumer` table. All the data in the column will be lost.
- You are about to drop the column `year` on the `consumer` table. All the data in the column will be lost.
- Added the required column `birthday` to the `consumer` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "consumer" DROP COLUMN "persona",
DROP COLUMN "year",
ADD COLUMN "birthday" TIMESTAMP(3) NOT NULL,
ADD COLUMN "editedValue" JSONB,
ADD COLUMN "value" JSONB;
-- AlterTable
ALTER TABLE "purchases" ALTER COLUMN "value" DROP NOT NULL;

View File

@@ -0,0 +1,4 @@
-- AlterTable
ALTER TABLE "consumer" ALTER COLUMN "letters" DROP NOT NULL,
ALTER COLUMN "zipCode" DROP NOT NULL,
ALTER COLUMN "birthday" DROP NOT NULL;

View File

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

9
prisma/prisma.ts Normal file
View File

@@ -0,0 +1,9 @@
import { PrismaClient } from '@prisma/client';
const globalForPrisma = global as unknown as { prisma: PrismaClient };
export const prisma = globalForPrisma.prisma || new PrismaClient();
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;
export default prisma;

34
prisma/schema.prisma Normal file
View File

@@ -0,0 +1,34 @@
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("POSTGRES_PRISMA_URL") // uses connection pooling
directUrl = env("POSTGRES_URL_NON_POOLING") // uses a direct connection
}
model Consumer {
id Int @id @default(autoincrement())
letters String?
birthday DateTime?
zipCode String?
value Json?
editedValue Json?
purchaseLists PurchaseList[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("consumer")
}
model PurchaseList {
id Int @id @default(autoincrement())
value Json?
consumer Consumer @relation(fields: [consumerId], references: [id])
consumerId Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("purchases")
}