added vendors table
This commit is contained in:
84
prisma/migrations/20260126161613_add_vendor/migration.sql
Normal file
84
prisma/migrations/20260126161613_add_vendor/migration.sql
Normal file
@@ -0,0 +1,84 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "VendorType" AS ENUM ('VENUE', 'CATERER', 'PHOTOGRAPHER', 'VIDEOGRAPHER', 'FLORIST', 'BAKERY', 'DJ', 'BAND', 'OFFICIANT', 'HAIR_MAKEUP', 'TRANSPORTATION', 'RENTALS', 'DECOR', 'PLANNER', 'STATIONERY', 'OTHER');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "VendorStatus" AS ENUM ('RESEARCHING', 'CONTACTING', 'RESPONDED', 'PROPOSAL_RECEIVED', 'NEGOTIATING', 'CONTRACT_SENT', 'CONTRACT_SIGNED', 'DECLINED', 'BACKUP');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Event" ADD COLUMN "vendorId" TEXT;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Vendor" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"type" "VendorType" NOT NULL,
|
||||
"description" TEXT,
|
||||
"website" TEXT,
|
||||
"contactPerson" TEXT,
|
||||
"email" TEXT,
|
||||
"phone" TEXT,
|
||||
"addressId" TEXT NOT NULL,
|
||||
"status" "VendorStatus" NOT NULL DEFAULT 'CONTACTING',
|
||||
"isBooked" BOOLEAN NOT NULL DEFAULT false,
|
||||
"bookedDate" TIMESTAMP(3),
|
||||
"quotedPrice" DOUBLE PRECISION,
|
||||
"finalCost" DOUBLE PRECISION,
|
||||
"depositPaid" DOUBLE PRECISION,
|
||||
"depositDueDate" TIMESTAMP(3),
|
||||
"finalPaymentDue" TIMESTAMP(3),
|
||||
"paymentNotes" TEXT,
|
||||
"contactUrl" TEXT,
|
||||
"proposalUrl" TEXT,
|
||||
"notes" TEXT,
|
||||
|
||||
CONSTRAINT "Vendor_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Address" (
|
||||
"id" TEXT NOT NULL,
|
||||
"street" TEXT NOT NULL,
|
||||
"city" TEXT NOT NULL,
|
||||
"state" TEXT NOT NULL,
|
||||
"zip" INTEGER NOT NULL,
|
||||
|
||||
CONSTRAINT "Address_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Category" (
|
||||
"id" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"description" TEXT,
|
||||
"color" TEXT DEFAULT '#3B82F6',
|
||||
|
||||
CONSTRAINT "Category_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "_CategoryToVendor" (
|
||||
"A" TEXT NOT NULL,
|
||||
"B" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "_CategoryToVendor_AB_pkey" PRIMARY KEY ("A","B")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Category_name_key" ON "Category"("name");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "_CategoryToVendor_B_index" ON "_CategoryToVendor"("B");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Event" ADD CONSTRAINT "Event_vendorId_fkey" FOREIGN KEY ("vendorId") REFERENCES "Vendor"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Vendor" ADD CONSTRAINT "Vendor_addressId_fkey" FOREIGN KEY ("addressId") REFERENCES "Address"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "_CategoryToVendor" ADD CONSTRAINT "_CategoryToVendor_A_fkey" FOREIGN KEY ("A") REFERENCES "Category"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "_CategoryToVendor" ADD CONSTRAINT "_CategoryToVendor_B_fkey" FOREIGN KEY ("B") REFERENCES "Vendor"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
28
prisma/migrations/20260126162133_formatting/migration.sql
Normal file
28
prisma/migrations/20260126162133_formatting/migration.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `vendorId` on the `Event` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Event" DROP CONSTRAINT "Event_vendorId_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Event" DROP COLUMN "vendorId";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "_EventToVendor" (
|
||||
"A" TEXT NOT NULL,
|
||||
"B" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "_EventToVendor_AB_pkey" PRIMARY KEY ("A","B")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "_EventToVendor_B_index" ON "_EventToVendor"("B");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "_EventToVendor" ADD CONSTRAINT "_EventToVendor_A_fkey" FOREIGN KEY ("A") REFERENCES "Event"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "_EventToVendor" ADD CONSTRAINT "_EventToVendor_B_fkey" FOREIGN KEY ("B") REFERENCES "Vendor"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `addressId` on the `Vendor` table. All the data in the column will be lost.
|
||||
- Added the required column `address` to the `Vendor` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `city` to the `Vendor` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `postalCode` to the `Vendor` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `state` to the `Vendor` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Vendor" DROP CONSTRAINT "Vendor_addressId_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Vendor" DROP COLUMN "addressId",
|
||||
ADD COLUMN "address" TEXT NOT NULL,
|
||||
ADD COLUMN "city" TEXT NOT NULL,
|
||||
ADD COLUMN "country" TEXT NOT NULL DEFAULT 'United States',
|
||||
ADD COLUMN "postalCode" TEXT NOT NULL,
|
||||
ADD COLUMN "state" TEXT NOT NULL;
|
||||
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `address` on the `Vendor` table. All the data in the column will be lost.
|
||||
- Added the required column `street` to the `Vendor` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Vendor" DROP COLUMN "address",
|
||||
ADD COLUMN "street" TEXT NOT NULL;
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `city` on the `Vendor` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `country` on the `Vendor` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `postalCode` on the `Vendor` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `state` on the `Vendor` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `street` on the `Vendor` table. All the data in the column will be lost.
|
||||
- Added the required column `addressId` to the `Vendor` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Vendor" DROP COLUMN "city",
|
||||
DROP COLUMN "country",
|
||||
DROP COLUMN "postalCode",
|
||||
DROP COLUMN "state",
|
||||
DROP COLUMN "street",
|
||||
ADD COLUMN "addressId" TEXT NOT NULL;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Vendor" ADD CONSTRAINT "Vendor_addressId_fkey" FOREIGN KEY ("addressId") REFERENCES "Address"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `contactUrl` on the `Vendor` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Vendor" DROP COLUMN "contactUrl",
|
||||
ADD COLUMN "contractUrl" TEXT;
|
||||
@@ -0,0 +1,8 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Vendor" DROP CONSTRAINT "Vendor_addressId_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Vendor" ALTER COLUMN "addressId" DROP NOT NULL;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Vendor" ADD CONSTRAINT "Vendor_addressId_fkey" FOREIGN KEY ("addressId") REFERENCES "Address"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
Reference in New Issue
Block a user