-- AlterTable
ALTER TABLE "origin_goods" ADD COLUMN     "tags_manual" BOOLEAN NOT NULL DEFAULT false;

-- CreateTable
CREATE TABLE "origin_good_tags" (
    "id" BIGSERIAL NOT NULL,
    "origin_good_id" BIGINT NOT NULL,
    "tag_id" BIGINT NOT NULL,
    "manual" BOOLEAN NOT NULL DEFAULT false,
    "created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateIndex
CREATE INDEX "origin_good_tags_tag_id_idx" ON "origin_good_tags"("tag_id");

-- CreateIndex
CREATE UNIQUE INDEX "origin_good_tags_origin_good_id_tag_id_key" ON "origin_good_tags"("origin_good_id", "tag_id");

-- AddForeignKey
ALTER TABLE "origin_good_tags" ADD CONSTRAINT "origin_good_tags_origin_good_id_fkey" FOREIGN KEY ("origin_good_id") REFERENCES "origin_goods"("origin_good_id") ON DELETE CASCADE ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE "origin_good_tags" ADD CONSTRAINT "origin_good_tags_tag_id_fkey" FOREIGN KEY ("tag_id") REFERENCES "tags"("tag_id") ON DELETE CASCADE ON UPDATE NO ACTION;
