-- CreateTable
CREATE TABLE "tbl_order_activity" (
    "id" BIGSERIAL NOT NULL,
    "user_id" BIGINT NOT NULL,
    "brand_id" BIGINT NOT NULL,
    "order_id" BIGINT NOT NULL,
    "currency" VARCHAR(64),
    "currency_symbol" VARCHAR(16),
    "amount" DECIMAL(13,2),
    "completed_by" VARCHAR(256),
    "order_activity_tag" VARCHAR(128),
    "is_active" BOOLEAN DEFAULT true,
    "inserted_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
    "updated_at" TIMESTAMP(3),

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

-- CreateIndex
CREATE INDEX "tbl_order_activity_order_id_user_id_brand_id_currency_curre_idx" ON "tbl_order_activity"("order_id", "user_id", "brand_id", "currency", "currency_symbol", "amount", "completed_by", "order_activity_tag");

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

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

-- AddForeignKey
ALTER TABLE "tbl_order_activity" ADD CONSTRAINT "tbl_order_activity_order_id_fkey" FOREIGN KEY ("order_id") REFERENCES "tbl_order"("id") ON DELETE CASCADE ON UPDATE CASCADE;
