/*
  Warnings:

  - You are about to drop the column `quantity` on the `ProductUsage` table. All the data in the column will be lost.
  - You are about to drop the column `usageDate` on the `ProductUsage` table. All the data in the column will be lost.
  - A unique constraint covering the columns `[stripeCustomerId]` on the table `User` will be added. If there are existing duplicate values, this will fail.
  - Added the required column `billingPeriodEnd` to the `ProductUsage` table without a default value. This is not possible if the table is not empty.
  - Added the required column `billingPeriodStart` to the `ProductUsage` table without a default value. This is not possible if the table is not empty.
  - Added the required column `updatedAt` to the `ProductUsage` table without a default value. This is not possible if the table is not empty.

*/
-- AlterTable
ALTER TABLE "ProductUsage" DROP COLUMN "quantity",
DROP COLUMN "usageDate",
ADD COLUMN     "billingPeriodEnd" TIMESTAMP(3) NOT NULL,
ADD COLUMN     "billingPeriodStart" TIMESTAMP(3) NOT NULL,
ADD COLUMN     "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN     "subscriptionPlanId" INTEGER,
ADD COLUMN     "updatedAt" TIMESTAMP(3) NOT NULL,
ADD COLUMN     "usageCount" INTEGER NOT NULL DEFAULT 0,
ADD COLUMN     "usageLimit" INTEGER NOT NULL DEFAULT 0;

-- AlterTable
ALTER TABLE "User" ADD COLUMN     "stripeCustomerId" TEXT;

-- CreateIndex
CREATE INDEX "ProductUsage_billingPeriodStart_billingPeriodEnd_idx" ON "ProductUsage"("billingPeriodStart", "billingPeriodEnd");

-- CreateIndex
CREATE UNIQUE INDEX "User_stripeCustomerId_key" ON "User"("stripeCustomerId");
