-- AlterEnum
-- This migration adds more than one value to an enum.
-- With PostgreSQL versions 11 and earlier, this is not possible
-- in a single migration. This can be worked around by creating
-- multiple migrations, each migration adding only one value to
-- the enum.


ALTER TYPE "dropDownType" ADD VALUE 'volume_units';
ALTER TYPE "dropDownType" ADD VALUE 'weight_units';

-- CreateTable
CREATE TABLE "tbl_product_weight" (
    "id" BIGSERIAL NOT NULL,
    "product_id" BIGINT NOT NULL,
    "value" DECIMAL(13,2),
    "unit_type" VARCHAR(8),
    "is_active" BOOLEAN DEFAULT true,
    "inserted_at" TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP,
    "updated_at" TIMESTAMP(6),

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

-- CreateTable
CREATE TABLE "tbl_product_volume" (
    "id" BIGSERIAL NOT NULL,
    "product_id" BIGINT NOT NULL,
    "value" DECIMAL(13,2),
    "unit_type" VARCHAR(8),
    "is_active" BOOLEAN DEFAULT true,
    "inserted_at" TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP,
    "updated_at" TIMESTAMP(6),

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

-- CreateIndex
CREATE INDEX "idx_product_weight_product_id" ON "tbl_product_weight"("product_id");

-- CreateIndex
CREATE INDEX "idx_product_volume_product_id" ON "tbl_product_volume"("product_id");

-- AddForeignKey
ALTER TABLE "tbl_product_weight" ADD CONSTRAINT "tbl_product_weight_product_id_fkey" FOREIGN KEY ("product_id") REFERENCES "tbl_product"("id") ON DELETE CASCADE ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE "tbl_product_volume" ADD CONSTRAINT "tbl_product_volume_product_id_fkey" FOREIGN KEY ("product_id") REFERENCES "tbl_product"("id") ON DELETE CASCADE ON UPDATE NO ACTION;
