update subscription module

This commit is contained in:
root
2026-05-25 04:58:56 -04:00
parent 1606ea0053
commit 8d0b7a5ceb
17 changed files with 4394 additions and 157 deletions
@@ -0,0 +1,22 @@
CREATE TABLE IF NOT EXISTS "pricing_promotions" (
"id" TEXT NOT NULL,
"code" TEXT NOT NULL,
"name" TEXT NOT NULL,
"description" TEXT,
"discountType" TEXT NOT NULL,
"discountValue" INTEGER NOT NULL,
"plans" TEXT[] NOT NULL DEFAULT '{}',
"periods" TEXT[] NOT NULL DEFAULT '{}',
"maxUses" INTEGER,
"usedCount" INTEGER NOT NULL DEFAULT 0,
"validFrom" TIMESTAMP(3) NOT NULL,
"validUntil" TIMESTAMP(3),
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"createdBy" TEXT,
CONSTRAINT "pricing_promotions_pkey" PRIMARY KEY ("id")
);
CREATE UNIQUE INDEX IF NOT EXISTS "pricing_promotions_code_key" ON "pricing_promotions"("code");
CREATE INDEX IF NOT EXISTS "pricing_promotions_isActive_idx" ON "pricing_promotions"("isActive");
@@ -0,0 +1,28 @@
CREATE TABLE "plan_features" (
"id" TEXT NOT NULL,
"plan" "Plan" NOT NULL,
"label" TEXT NOT NULL,
"sortOrder" INTEGER NOT NULL DEFAULT 0,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "plan_features_pkey" PRIMARY KEY ("id")
);
CREATE INDEX "plan_features_plan_sortOrder_idx" ON "plan_features"("plan", "sortOrder");
INSERT INTO "plan_features" ("id", "plan", "label", "sortOrder") VALUES
('plf_starter_1', 'STARTER', 'Up to 10 vehicles', 10),
('plf_starter_2', 'STARTER', '1 user account', 20),
('plf_starter_3', 'STARTER', 'Basic analytics', 30),
('plf_starter_4', 'STARTER', 'Marketplace listing', 40),
('plf_growth_1', 'GROWTH', 'Up to 50 vehicles', 10),
('plf_growth_2', 'GROWTH', '5 user accounts', 20),
('plf_growth_3', 'GROWTH', 'Full analytics', 30),
('plf_growth_4', 'GROWTH', 'Priority marketplace placement', 40),
('plf_growth_5', 'GROWTH', 'Custom branding', 50),
('plf_pro_1', 'PRO', 'Unlimited vehicles', 10),
('plf_pro_2', 'PRO', 'Unlimited user accounts', 20),
('plf_pro_3', 'PRO', 'Advanced reports', 30),
('plf_pro_4', 'PRO', 'API access', 40),
('plf_pro_5', 'PRO', 'Dedicated support', 50);