/*
  Warnings:

  - The values [PaymentWait] on the enum `QuotationStatus` will be removed. If these variants are still used in the database, this will fail.

*/
-- CreateEnum
CREATE TYPE "PaymentStatus" AS ENUM ('PaymentWait', 'PaymentSuccess');

-- AlterEnum
BEGIN;
CREATE TYPE "QuotationStatus_new" AS ENUM ('PaymentPending', 'PaymentInProcess', 'PaymentSuccess', 'ProcessComplete', 'Canceled');
ALTER TABLE "Quotation" ALTER COLUMN "quotationStatus" DROP DEFAULT;
ALTER TABLE "Quotation" ALTER COLUMN "quotationStatus" TYPE "QuotationStatus_new" USING ("quotationStatus"::text::"QuotationStatus_new");
ALTER TYPE "QuotationStatus" RENAME TO "QuotationStatus_old";
ALTER TYPE "QuotationStatus_new" RENAME TO "QuotationStatus";
DROP TYPE "QuotationStatus_old";
ALTER TABLE "Quotation" ALTER COLUMN "quotationStatus" SET DEFAULT 'PaymentPending';
COMMIT;

-- AlterTable
ALTER TABLE "Quotation" ALTER COLUMN "quotationStatus" SET DEFAULT 'PaymentPending';

-- CreateTable
CREATE TABLE "QuotationPayment" (
    "id" TEXT NOT NULL,
    "paymentStatus" "PaymentStatus" NOT NULL,
    "date" TIMESTAMP(3) NOT NULL,
    "amount" DOUBLE PRECISION NOT NULL,
    "remark" TEXT,
    "quotationId" TEXT NOT NULL,

    CONSTRAINT "QuotationPayment_pkey" PRIMARY KEY ("id")
);

-- AddForeignKey
ALTER TABLE "QuotationPayment" ADD CONSTRAINT "QuotationPayment_quotationId_fkey" FOREIGN KEY ("quotationId") REFERENCES "Quotation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
