feat: attempt to fix the crud with auth

This commit is contained in:
Riccardo
2024-07-07 17:47:57 +02:00
parent ea73368cc9
commit 637520dbf2
27 changed files with 622 additions and 53 deletions

View File

@@ -0,0 +1,36 @@
/*
Warnings:
- You are about to drop the `Module` table. If the table is not empty, all the data it contains will be lost.
*/
-- CreateEnum
CREATE TYPE "CustomerFormType" AS ENUM ('TYPE1', 'TYPE2', 'TYPE3');
-- DropForeignKey
ALTER TABLE "Module" DROP CONSTRAINT "Module_createdById_fkey";
-- DropTable
DROP TABLE "Module";
-- DropEnum
DROP TYPE "ModuleType";
-- CreateTable
CREATE TABLE "CustomerForm" (
"id" DOUBLE PRECISION NOT NULL,
"type" "CustomerFormType" NOT NULL,
"text" TEXT NOT NULL,
"deleted" BOOLEAN NOT NULL DEFAULT false,
"createdById" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "CustomerForm_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "CustomerForm_id_key" ON "CustomerForm"("id");
-- AddForeignKey
ALTER TABLE "CustomerForm" ADD CONSTRAINT "CustomerForm_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@@ -0,0 +1,13 @@
/*
Warnings:
- The primary key for the `CustomerForm` table will be changed. If it partially fails, the table could be left without primary key constraint.
*/
-- DropIndex
DROP INDEX "CustomerForm_id_key";
-- AlterTable
ALTER TABLE "CustomerForm" DROP CONSTRAINT "CustomerForm_pkey",
ALTER COLUMN "id" SET DATA TYPE TEXT,
ADD CONSTRAINT "CustomerForm_pkey" PRIMARY KEY ("id");

View File

@@ -8,29 +8,29 @@ datasource db {
directUrl = env("DATABASE_URL_NON_POOLING") // uses a direct connection
}
enum ModuleType {
enum CustomerFormType {
TYPE1
TYPE2
TYPE3
}
model User {
id String @id @default(cuid())
name String?
email String @unique
deleted Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Module Module[]
id String @id @default(cuid())
name String?
email String @unique
deleted Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
CustomerForm CustomerForm[]
}
model Module {
id Float @id @unique
type ModuleType
model CustomerForm {
id String @id @default(cuid())
type CustomerFormType
text String
deleted Boolean @default(false)
deleted Boolean @default(false)
createdById String
createdBy User @relation(fields: [createdById], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdBy User @relation(fields: [createdById], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}