-- CreateTable
CREATE TABLE "tbl_customer_order" (
    "id" BIGSERIAL NOT NULL,
    "user_id" BIGINT NOT NULL,
    "brand_id" BIGINT NOT NULL,
    "total" DECIMAL(13,2),
    "internal_note" TEXT,
    "is_user_blocked" BOOLEAN DEFAULT false,
    "last_order_at" TIMESTAMP(3),
    "inserted_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
    "updated_at" TIMESTAMP(3),

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

-- CreateIndex
CREATE INDEX "tbl_customer_order_user_id_idx" ON "tbl_customer_order"("user_id");

-- CreateIndex
CREATE INDEX "tbl_customer_order_brand_id_idx" ON "tbl_customer_order"("brand_id");

-- CreateIndex
CREATE INDEX "tbl_customer_order_total_idx" ON "tbl_customer_order"("total");

-- CreateIndex
CREATE INDEX "tbl_customer_order_internal_note_idx" ON "tbl_customer_order"("internal_note");

-- CreateIndex
CREATE INDEX "tbl_customer_order_last_order_at_idx" ON "tbl_customer_order"("last_order_at");

-- CreateIndex
CREATE INDEX "tbl_customer_order_is_user_blocked_idx" ON "tbl_customer_order"("is_user_blocked");

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

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