Initial commit: PodcastYes — AI podcast platform
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
// Seed the Plan catalog (admin-tunable mirror of lib/billing/plans.ts).
|
||||
// Run: npm run db:seed
|
||||
import "dotenv/config";
|
||||
import type { Prisma } from "@prisma/client";
|
||||
import { prisma } from "@/lib/db";
|
||||
import { PLANS, PLAN_ORDER } from "@/lib/billing/plans";
|
||||
|
||||
async function main() {
|
||||
for (const key of PLAN_ORDER) {
|
||||
const plan = PLANS[key];
|
||||
await prisma.plan.upsert({
|
||||
where: { key },
|
||||
create: {
|
||||
key,
|
||||
name: plan.name,
|
||||
priceMonthly: plan.priceMonthly,
|
||||
priceYearly: plan.priceYearly,
|
||||
limits: plan.limits as unknown as Prisma.InputJsonValue,
|
||||
features: plan.features as unknown as Prisma.InputJsonValue,
|
||||
},
|
||||
update: {
|
||||
name: plan.name,
|
||||
priceMonthly: plan.priceMonthly,
|
||||
priceYearly: plan.priceYearly,
|
||||
limits: plan.limits as unknown as Prisma.InputJsonValue,
|
||||
features: plan.features as unknown as Prisma.InputJsonValue,
|
||||
},
|
||||
});
|
||||
console.log(`✓ Seeded plan: ${plan.name}`);
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((err) => {
|
||||
console.error("Seed failed:", err.message ?? err);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(() => prisma.$disconnect());
|
||||
Reference in New Issue
Block a user