-- CreateTable
CREATE TABLE "subscriptions" (
    "uid" TEXT NOT NULL,
    "start_date" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
    "end_date" TIMESTAMP(3),
    "nb_seats" INTEGER NOT NULL,
    "office_uid" VARCHAR(255) NOT NULL,

    CONSTRAINT "subscriptions_pkey" PRIMARY KEY ("uid")
);

-- CreateTable
CREATE TABLE "seats" (
    "uid" TEXT NOT NULL,
    "subscription_uid" VARCHAR(255) NOT NULL,
    "user_uid" VARCHAR(255) NOT NULL,

    CONSTRAINT "seats_pkey" PRIMARY KEY ("uid")
);

-- CreateIndex
CREATE UNIQUE INDEX "subscriptions_uid_key" ON "subscriptions"("uid");

-- CreateIndex
CREATE UNIQUE INDEX "seats_uid_key" ON "seats"("uid");

-- AddForeignKey
ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_office_uid_fkey" FOREIGN KEY ("office_uid") REFERENCES "offices"("uid") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "seats" ADD CONSTRAINT "seats_subscription_uid_fkey" FOREIGN KEY ("subscription_uid") REFERENCES "subscriptions"("uid") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "seats" ADD CONSTRAINT "seats_user_uid_fkey" FOREIGN KEY ("user_uid") REFERENCES "users"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
