-- CreateTable
CREATE TABLE "tbl_cart" (
    "id" BIGSERIAL NOT NULL,
    "user_id" BIGINT NOT NULL,
    "brand_id" BIGINT NOT NULL,
    "product_id" BIGINT NOT NULL,
    "qty" INTEGER DEFAULT 1,
    "inserted_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
    "updated_at" TIMESTAMP(3),

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

-- CreateIndex
CREATE INDEX "tbl_cart_user_id_idx" ON "tbl_cart"("user_id");

-- CreateIndex
CREATE INDEX "tbl_cart_product_id_idx" ON "tbl_cart"("product_id");

-- CreateIndex
CREATE INDEX "tbl_cart_brand_id_idx" ON "tbl_cart"("brand_id");

-- CreateIndex
CREATE INDEX "tbl_category_parent_id_idx" ON "tbl_category"("parent_id");

-- CreateIndex
CREATE INDEX "tbl_category_category_name_idx" ON "tbl_category"("category_name");

-- CreateIndex
CREATE INDEX "tbl_dropdown_list_name_idx" ON "tbl_dropdown_list"("name");

-- CreateIndex
CREATE INDEX "tbl_dropdown_list_type_idx" ON "tbl_dropdown_list"("type");

-- CreateIndex
CREATE INDEX "tbl_product_user_id_idx" ON "tbl_product"("user_id");

-- CreateIndex
CREATE INDEX "tbl_product_product_name_idx" ON "tbl_product"("product_name");

-- CreateIndex
CREATE INDEX "tbl_user_first_name_idx" ON "tbl_user"("first_name");

-- CreateIndex
CREATE INDEX "tbl_user_last_name_idx" ON "tbl_user"("last_name");

-- CreateIndex
CREATE INDEX "tbl_user_email_idx" ON "tbl_user"("email");

-- CreateIndex
CREATE INDEX "tbl_user_country_code_idx" ON "tbl_user"("country_code");

-- CreateIndex
CREATE INDEX "tbl_user_mobile_number_idx" ON "tbl_user"("mobile_number");

-- CreateIndex
CREATE INDEX "tbl_user_profile_image_idx" ON "tbl_user"("profile_image");

-- CreateIndex
CREATE INDEX "tbl_user_business_name_idx" ON "tbl_user"("business_name");

-- CreateIndex
CREATE INDEX "tbl_user_business_profile_banner_image_idx" ON "tbl_user"("business_profile_banner_image");

-- CreateIndex
CREATE INDEX "tbl_user_business_profile_image_idx" ON "tbl_user"("business_profile_image");

-- CreateIndex
CREATE INDEX "tbl_user_profile_banner_image_idx" ON "tbl_user"("profile_banner_image");

-- CreateIndex
CREATE INDEX "tbl_user_device_token_idx" ON "tbl_user_device"("token");

-- CreateIndex
CREATE INDEX "tbl_user_device_user_id_idx" ON "tbl_user_device"("user_id");

-- AddForeignKey
ALTER TABLE "tbl_cart" ADD CONSTRAINT "tbl_cart_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "tbl_user"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "tbl_cart" ADD CONSTRAINT "tbl_cart_brand_id_fkey" FOREIGN KEY ("brand_id") REFERENCES "tbl_user"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "tbl_cart" ADD CONSTRAINT "tbl_cart_product_id_fkey" FOREIGN KEY ("product_id") REFERENCES "tbl_product"("id") ON DELETE CASCADE ON UPDATE CASCADE;
