/*
  Warnings:

  - The primary key for the `reviews` table will be changed. If it partially fails, the table could be left without primary key constraint.
  - You are about to drop the column `ImageURL` on the `reviews` table. All the data in the column will be lost.
  - You are about to drop the column `ItemID` on the `reviews` table. All the data in the column will be lost.
  - You are about to drop the column `Rating` on the `reviews` table. All the data in the column will be lost.
  - You are about to drop the column `ReviewDate` on the `reviews` table. All the data in the column will be lost.
  - You are about to drop the column `ReviewID` on the `reviews` table. All the data in the column will be lost.
  - You are about to drop the column `ReviewText` on the `reviews` table. All the data in the column will be lost.
  - You are about to drop the column `ReviewerName` on the `reviews` table. All the data in the column will be lost.
  - Added the required column `itemid` to the `reviews` table without a default value. This is not possible if the table is not empty.
  - Added the required column `review_id` to the `reviews` table without a default value. This is not possible if the table is not empty.
  - Added the required column `shopid` to the `reviews` table without a default value. This is not possible if the table is not empty.

*/
-- DropForeignKey
ALTER TABLE "public"."reviews" DROP CONSTRAINT "reviews_ItemID_fkey";

-- AlterTable
ALTER TABLE "public"."reviews" DROP CONSTRAINT "reviews_pkey",
DROP COLUMN "ImageURL",
DROP COLUMN "ItemID",
DROP COLUMN "Rating",
DROP COLUMN "ReviewDate",
DROP COLUMN "ReviewID",
DROP COLUMN "ReviewText",
DROP COLUMN "ReviewerName",
ADD COLUMN     "anonymous" BOOLEAN,
ADD COLUMN     "author_username" TEXT,
ADD COLUMN     "comment" TEXT,
ADD COLUMN     "is_repeated_purchase" BOOLEAN,
ADD COLUMN     "itemid" BIGINT NOT NULL,
ADD COLUMN     "like_count" INTEGER,
ADD COLUMN     "order_id" BIGINT,
ADD COLUMN     "product_quality_rating" INTEGER,
ADD COLUMN     "product_url" TEXT,
ADD COLUMN     "rating_star" INTEGER,
ADD COLUMN     "review_creation_time" TIMESTAMP(3),
ADD COLUMN     "review_id" BIGINT NOT NULL,
ADD COLUMN     "review_tags" TEXT,
ADD COLUMN     "shopid" BIGINT NOT NULL,
ADD COLUMN     "user_loyalty_tier" TEXT,
ADD CONSTRAINT "reviews_pkey" PRIMARY KEY ("review_id");

-- CreateTable
CREATE TABLE "public"."review_media" (
    "id" SERIAL NOT NULL,
    "review_id" BIGINT NOT NULL,
    "media_type" TEXT,
    "media_url" TEXT,
    "description" TEXT,

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

-- AddForeignKey
ALTER TABLE "public"."reviews" ADD CONSTRAINT "reviews_itemid_fkey" FOREIGN KEY ("itemid") REFERENCES "public"."products"("ItemID") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "public"."review_media" ADD CONSTRAINT "review_media_review_id_fkey" FOREIGN KEY ("review_id") REFERENCES "public"."reviews"("review_id") ON DELETE CASCADE ON UPDATE CASCADE;
