-- CreateTable
CREATE TABLE "Session" (
    "id" TEXT NOT NULL,
    "shop" TEXT NOT NULL,
    "state" TEXT NOT NULL,
    "isOnline" BOOLEAN NOT NULL DEFAULT false,
    "scope" TEXT,
    "expires" TIMESTAMP(3),
    "accessToken" TEXT NOT NULL,
    "userId" BIGINT,
    "firstName" TEXT,
    "lastName" TEXT,
    "email" TEXT,
    "accountOwner" BOOLEAN NOT NULL DEFAULT false,
    "locale" TEXT,
    "collaborator" BOOLEAN DEFAULT false,
    "emailVerified" BOOLEAN DEFAULT false,

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

-- CreateTable
CREATE TABLE "Frame" (
    "id" SERIAL NOT NULL,
    "title" TEXT NOT NULL,
    "frameColor" TEXT NOT NULL,
    "shadowColor" TEXT NOT NULL,
    "imageUrl" TEXT,
    "shop" TEXT NOT NULL,

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

-- CreateTable
CREATE TABLE "Size" (
    "id" SERIAL NOT NULL,
    "label" TEXT NOT NULL,
    "width" TEXT NOT NULL,
    "height" TEXT NOT NULL,
    "mat" TEXT NOT NULL,
    "price" DOUBLE PRECISION NOT NULL,
    "imageUrl" TEXT,
    "shop" TEXT NOT NULL,
    "order" INTEGER NOT NULL DEFAULT 0,

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

-- CreateTable
CREATE TABLE "FrameOption" (
    "id" INTEGER NOT NULL,
    "optionId" INTEGER NOT NULL,
    "frameId" INTEGER NOT NULL,
    "value" BOOLEAN,

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

-- CreateTable
CREATE TABLE "Offbeat" (
    "id" SERIAL NOT NULL,
    "name" TEXT NOT NULL,
    "shop" TEXT NOT NULL,
    "order" INTEGER DEFAULT 0,

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

-- CreateTable
CREATE TABLE "Option" (
    "id" SERIAL NOT NULL,
    "offbeatId" INTEGER NOT NULL,
    "sizeId" INTEGER NOT NULL,
    "mat" TEXT,

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

-- AddForeignKey
ALTER TABLE "FrameOption" ADD CONSTRAINT "FrameOption_frameId_fkey" FOREIGN KEY ("frameId") REFERENCES "Frame"("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE "FrameOption" ADD CONSTRAINT "FrameOption_optionId_fkey" FOREIGN KEY ("optionId") REFERENCES "Option"("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE "Option" ADD CONSTRAINT "Option_offbeatId_fkey" FOREIGN KEY ("offbeatId") REFERENCES "Offbeat"("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE "Option" ADD CONSTRAINT "Option_sizeId_fkey" FOREIGN KEY ("sizeId") REFERENCES "Size"("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
