CREATE TABLE "plan" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"stripe_id" varchar(255) NOT NULL,
	"name" varchar(255),
	"description" text,
	"type" varchar(15) NOT NULL,
	"content" jsonb DEFAULT '{}'::jsonb NOT NULL,
	"created_at" timestamp with time zone DEFAULT now() NOT NULL,
	"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "plan_price" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"plan_id" uuid NOT NULL,
	"stripe_id" varchar(255) NOT NULL,
	"name" varchar(255) NOT NULL,
	"description" text NOT NULL,
	"type" varchar(10) DEFAULT 'recurring' NOT NULL,
	"is_active" boolean DEFAULT true NOT NULL,
	"period" varchar(15) NOT NULL,
	"billing_scheme" varchar(15) NOT NULL,
	"currency" varchar(3) DEFAULT 'usd' NOT NULL,
	"price" integer,
	"tiers_mode" varchar(15),
	"tiers" jsonb,
	"created_at" timestamp with time zone DEFAULT now() NOT NULL,
	"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "plan_price" ADD CONSTRAINT "plan_price_plan_id_plan_id_fk" FOREIGN KEY ("plan_id") REFERENCES "public"."plan"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "plan_name_index" ON "plan" USING btree ("name");--> statement-breakpoint
CREATE UNIQUE INDEX "plan_stripe_id_index" ON "plan" USING btree ("stripe_id");--> statement-breakpoint
CREATE INDEX "plan_price_name_index" ON "plan_price" USING btree ("name");--> statement-breakpoint
CREATE UNIQUE INDEX "plan_price_stripe_id_index" ON "plan_price" USING btree ("stripe_id");--> statement-breakpoint
CREATE INDEX "plan_price_is_active_index" ON "plan_price" USING btree ("is_active");--> statement-breakpoint
CREATE INDEX "plan_price_period_index" ON "plan_price" USING btree ("period");--> statement-breakpoint
CREATE INDEX "plan_price_billing_scheme_index" ON "plan_price" USING btree ("billing_scheme");--> statement-breakpoint
CREATE INDEX "plan_price_currency_index" ON "plan_price" USING btree ("currency");