-- CreateEnum CREATE TYPE "PlanId" AS ENUM ('FREE', 'PRO'); -- AlterTable ALTER TABLE "billing_subscriptions" ADD COLUMN "pending_amount" DECIMAL(12,2), ADD COLUMN "price_change_attempts" INTEGER NOT NULL DEFAULT 0, ADD COLUMN "price_change_error" TEXT, ADD COLUMN "price_change_id" TEXT; -- CreateTable CREATE TABLE "plan_configs" ( "plan" "PlanId" NOT NULL, "max_groups" INTEGER, "max_attendees" INTEGER, "whatsapp_automations" BOOLEAN NOT NULL, "mp_charges" BOOLEAN NOT NULL, "updated_by_id" TEXT, "updated_at" TIMESTAMP(3) NOT NULL, CONSTRAINT "plan_configs_pkey" PRIMARY KEY ("plan") ); -- CreateTable CREATE TABLE "plan_prices" ( "country_code" TEXT NOT NULL, "amount" DECIMAL(12,2) NOT NULL, "updated_by_id" TEXT, "updated_at" TIMESTAMP(3) NOT NULL, CONSTRAINT "plan_prices_pkey" PRIMARY KEY ("country_code") ); -- CreateTable CREATE TABLE "plan_price_changes" ( "id" TEXT NOT NULL, "country_code" TEXT NOT NULL, "previous_amount" DECIMAL(12,2), "new_amount" DECIMAL(12,2) NOT NULL, "currency" TEXT NOT NULL, "apply_to_existing" BOOLEAN NOT NULL, "queued" INTEGER NOT NULL DEFAULT 0, "created_by_id" TEXT, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "plan_price_changes_pkey" PRIMARY KEY ("id") ); -- CreateIndex CREATE INDEX "plan_price_changes_country_created_at_idx" ON "plan_price_changes"("country_code", "created_at"); -- CreateIndex CREATE INDEX "billing_subscriptions_pending_amount_idx" ON "billing_subscriptions"("pending_amount"); -- Seed with the defaults that lived in code (`PLAN_LIMITS`, `PRO_PRICE_BY_COUNTRY` -- in packages/shared), so nothing changes on deploy. INSERT INTO "plan_configs" ("plan", "max_groups", "max_attendees", "whatsapp_automations", "mp_charges", "updated_at") VALUES ('FREE', 1, 15, false, false, CURRENT_TIMESTAMP), ('PRO', NULL, NULL, true, true, CURRENT_TIMESTAMP); INSERT INTO "plan_prices" ("country_code", "amount", "updated_at") VALUES ('AR', 15000, CURRENT_TIMESTAMP), ('BR', 49, CURRENT_TIMESTAMP), ('CL', 9900, CURRENT_TIMESTAMP), ('CO', 39900, CURRENT_TIMESTAMP), ('MX', 199, CURRENT_TIMESTAMP), ('PE', 39, CURRENT_TIMESTAMP), ('UY', 390, CURRENT_TIMESTAMP);