* refactor: update database table * refactor: update invoice to have relation with installments * chore: add migration
77 lines
2.8 KiB
SQL
77 lines
2.8 KiB
SQL
/*
|
|
Warnings:
|
|
|
|
- You are about to drop the column `invoice` on the `QuotationPaySplit` table. All the data in the column will be lost.
|
|
- You are about to drop the column `invoiceId` on the `QuotationProductServiceList` table. All the data in the column will be lost.
|
|
|
|
*/
|
|
-- DropForeignKey
|
|
ALTER TABLE "QuotationProductServiceList" DROP CONSTRAINT "QuotationProductServiceList_invoiceId_fkey";
|
|
|
|
-- AlterTable
|
|
ALTER TABLE "QuotationPaySplit" DROP COLUMN "invoice",
|
|
ADD COLUMN "invoiceId" TEXT;
|
|
|
|
-- AlterTable
|
|
ALTER TABLE "QuotationProductServiceList" DROP COLUMN "invoiceId";
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "Notification" (
|
|
"id" TEXT NOT NULL,
|
|
"title" TEXT NOT NULL,
|
|
"detail" TEXT NOT NULL,
|
|
"receiverId" TEXT,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
CONSTRAINT "Notification_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "NotificationGroup" (
|
|
"id" TEXT NOT NULL,
|
|
"name" TEXT NOT NULL,
|
|
|
|
CONSTRAINT "NotificationGroup_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "_NotificationToNotificationGroup" (
|
|
"A" TEXT NOT NULL,
|
|
"B" TEXT NOT NULL
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "_NotificationToUser" (
|
|
"A" TEXT NOT NULL,
|
|
"B" TEXT NOT NULL
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "_NotificationToNotificationGroup_AB_unique" ON "_NotificationToNotificationGroup"("A", "B");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "_NotificationToNotificationGroup_B_index" ON "_NotificationToNotificationGroup"("B");
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "_NotificationToUser_AB_unique" ON "_NotificationToUser"("A", "B");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "_NotificationToUser_B_index" ON "_NotificationToUser"("B");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "Notification" ADD CONSTRAINT "Notification_receiverId_fkey" FOREIGN KEY ("receiverId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "QuotationPaySplit" ADD CONSTRAINT "QuotationPaySplit_invoiceId_fkey" FOREIGN KEY ("invoiceId") REFERENCES "Invoice"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "_NotificationToNotificationGroup" ADD CONSTRAINT "_NotificationToNotificationGroup_A_fkey" FOREIGN KEY ("A") REFERENCES "Notification"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "_NotificationToNotificationGroup" ADD CONSTRAINT "_NotificationToNotificationGroup_B_fkey" FOREIGN KEY ("B") REFERENCES "NotificationGroup"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "_NotificationToUser" ADD CONSTRAINT "_NotificationToUser_A_fkey" FOREIGN KEY ("A") REFERENCES "Notification"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "_NotificationToUser" ADD CONSTRAINT "_NotificationToUser_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|