CREATE TYPE "public"."support_type" AS ENUM('standard', '24/7', 'premium');--> statement-breakpoint CREATE TYPE "public"."subscriber_type" AS ENUM('microfinance', 'student', 'company', 'school');--> statement-breakpoint CREATE TYPE "public"."subscription_status" AS ENUM('active', 'expired', 'canceled');--> statement-breakpoint CREATE TABLE "packages" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "name" varchar(255) NOT NULL, "price" integer NOT NULL, "product_id" uuid NOT NULL, "features" jsonb NOT NULL, "support_type" "support_type" NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL, CONSTRAINT "packages_name_unique" UNIQUE("name") ); --> statement-breakpoint CREATE TABLE "products" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "name" varchar(255) NOT NULL, "description" varchar(255) NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL, CONSTRAINT "products_name_unique" UNIQUE("name") ); --> statement-breakpoint CREATE TABLE "subscriptions" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "protect_key" varchar(255) NOT NULL, "subscriber" jsonb NOT NULL, "package_id" uuid NOT NULL, "start_date" timestamp DEFAULT now() NOT NULL, "duration_in_months" integer NOT NULL, "end_date" timestamp NOT NULL, "sent_sms_count" integer DEFAULT 0 NOT NULL, "status" "subscription_status" DEFAULT 'active' NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL, CONSTRAINT "subscriptions_protect_key_unique" UNIQUE("protect_key") ); --> statement-breakpoint ALTER TABLE "packages" ADD CONSTRAINT "packages_product_id_products_id_fk" FOREIGN KEY ("product_id") REFERENCES "public"."products"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_package_id_packages_id_fk" FOREIGN KEY ("package_id") REFERENCES "public"."packages"("id") ON DELETE no action ON UPDATE no action;