update subscription module
This commit is contained in:
@@ -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);
|
||||
@@ -1179,3 +1179,37 @@ model PricingConfig {
|
||||
@@unique([plan, billingPeriod])
|
||||
@@map("pricing_configs")
|
||||
}
|
||||
|
||||
model PlanFeature {
|
||||
id String @id @default(cuid())
|
||||
plan Plan
|
||||
label String
|
||||
sortOrder Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([plan, sortOrder])
|
||||
@@map("plan_features")
|
||||
}
|
||||
|
||||
model PricingPromotion {
|
||||
id String @id @default(cuid())
|
||||
code String @unique
|
||||
name String
|
||||
description String?
|
||||
discountType String // 'PERCENTAGE' | 'FIXED'
|
||||
discountValue Int // percentage (1-100) or centimes for FIXED
|
||||
plans String[] // empty array = all plans
|
||||
periods String[] // empty array = all periods
|
||||
maxUses Int?
|
||||
usedCount Int @default(0)
|
||||
validFrom DateTime
|
||||
validUntil DateTime?
|
||||
isActive Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
createdBy String?
|
||||
|
||||
@@index([isActive])
|
||||
@@map("pricing_promotions")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user