Add custom inputs to commission types
This commit is contained in:
34
prisma/migrations/20250707151218_type_field/migration.sql
Normal file
34
prisma/migrations/20250707151218_type_field/migration.sql
Normal file
@ -0,0 +1,34 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "CommissionField" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"sortIndex" INTEGER NOT NULL DEFAULT 0,
|
||||
"fieldType" TEXT NOT NULL,
|
||||
"label" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"required" BOOLEAN NOT NULL DEFAULT false,
|
||||
|
||||
CONSTRAINT "CommissionField_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "CommissionTypeField" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"sortIndex" INTEGER NOT NULL DEFAULT 0,
|
||||
"typeId" TEXT NOT NULL,
|
||||
"fieldId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "CommissionTypeField_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "CommissionTypeField_typeId_fieldId_key" ON "CommissionTypeField"("typeId", "fieldId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "CommissionTypeField" ADD CONSTRAINT "CommissionTypeField_typeId_fkey" FOREIGN KEY ("typeId") REFERENCES "CommissionType"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "CommissionTypeField" ADD CONSTRAINT "CommissionTypeField_fieldId_fkey" FOREIGN KEY ("fieldId") REFERENCES "CommissionField"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `CommissionField` table. If the table is not empty, all the data it contains will be lost.
|
||||
- You are about to drop the `CommissionTypeField` table. If the table is not empty, all the data it contains will be lost.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "CommissionTypeField" DROP CONSTRAINT "CommissionTypeField_fieldId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "CommissionTypeField" DROP CONSTRAINT "CommissionTypeField_typeId_fkey";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "CommissionField";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "CommissionTypeField";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "CommissionCustomInput" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"sortIndex" INTEGER NOT NULL DEFAULT 0,
|
||||
"inputType" TEXT NOT NULL,
|
||||
"label" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"required" BOOLEAN NOT NULL DEFAULT false,
|
||||
|
||||
CONSTRAINT "CommissionCustomInput_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "CommissionTypeCustomInput" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"sortIndex" INTEGER NOT NULL DEFAULT 0,
|
||||
"typeId" TEXT NOT NULL,
|
||||
"customInputId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "CommissionTypeCustomInput_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "CommissionTypeCustomInput_typeId_customInputId_key" ON "CommissionTypeCustomInput"("typeId", "customInputId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "CommissionTypeCustomInput" ADD CONSTRAINT "CommissionTypeCustomInput_typeId_fkey" FOREIGN KEY ("typeId") REFERENCES "CommissionType"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "CommissionTypeCustomInput" ADD CONSTRAINT "CommissionTypeCustomInput_customInputId_fkey" FOREIGN KEY ("customInputId") REFERENCES "CommissionCustomInput"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `inputType` on the `CommissionCustomInput` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `label` on the `CommissionCustomInput` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `required` on the `CommissionCustomInput` table. All the data in the column will be lost.
|
||||
- A unique constraint covering the columns `[name]` on the table `CommissionCustomInput` will be added. If there are existing duplicate values, this will fail.
|
||||
- Added the required column `fieldId` to the `CommissionCustomInput` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `inputType` to the `CommissionTypeCustomInput` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `label` to the `CommissionTypeCustomInput` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "CommissionCustomInput" DROP COLUMN "inputType",
|
||||
DROP COLUMN "label",
|
||||
DROP COLUMN "required",
|
||||
ADD COLUMN "fieldId" TEXT NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "CommissionTypeCustomInput" ADD COLUMN "inputType" TEXT NOT NULL,
|
||||
ADD COLUMN "label" TEXT NOT NULL,
|
||||
ADD COLUMN "required" BOOLEAN NOT NULL DEFAULT false;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "CommissionCustomInput_name_key" ON "CommissionCustomInput"("name");
|
@ -24,8 +24,9 @@ model CommissionType {
|
||||
|
||||
description String?
|
||||
|
||||
options CommissionTypeOption[]
|
||||
extras CommissionTypeExtra[]
|
||||
options CommissionTypeOption[]
|
||||
extras CommissionTypeExtra[]
|
||||
customInputs CommissionTypeCustomInput[]
|
||||
}
|
||||
|
||||
model CommissionOption {
|
||||
@ -54,6 +55,18 @@ model CommissionExtra {
|
||||
types CommissionTypeExtra[]
|
||||
}
|
||||
|
||||
model CommissionCustomInput {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
sortIndex Int @default(0)
|
||||
|
||||
name String @unique
|
||||
fieldId String
|
||||
|
||||
types CommissionTypeCustomInput[]
|
||||
}
|
||||
|
||||
model CommissionTypeOption {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
@ -92,6 +105,25 @@ model CommissionTypeExtra {
|
||||
@@unique([typeId, extraId])
|
||||
}
|
||||
|
||||
model CommissionTypeCustomInput {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
sortIndex Int @default(0)
|
||||
|
||||
typeId String
|
||||
customInputId String
|
||||
|
||||
inputType String
|
||||
label String
|
||||
required Boolean @default(false)
|
||||
|
||||
type CommissionType @relation(fields: [typeId], references: [id])
|
||||
customInput CommissionCustomInput @relation(fields: [customInputId], references: [id])
|
||||
|
||||
@@unique([typeId, customInputId])
|
||||
}
|
||||
|
||||
model TermsOfService {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
|
Reference in New Issue
Block a user