Files
support_backend/prisma/seed/demo.seed.ts
T

24 lines
949 B
TypeScript
Raw Normal View History

import { randomUUID } from 'crypto';
2026-08-19 16:29:17 +05:30
import { PrismaClient, UserRole } from '@prisma/client';
import bcrypt from 'bcryptjs';
2026-08-19 16:29:17 +05:30
export async function seedDemoData(prisma: PrismaClient): Promise<void> {
// eslint-disable-next-line no-console
console.log(' -> Seeding demo environment data...');
// Legacy demo row, pre-existing since before 010-identity-auth: a CUSTOMER-role User is
// never a real login identity (customer identity is exclusively SaaS-delegated, see
// specs/010-identity-auth/spec.md Assumptions) — passwordHash is populated only to satisfy
// the column's NOT NULL constraint; this account can never authenticate via /auth/login.
2026-08-19 16:29:17 +05:30
await prisma.user.upsert({
where: { email: 'john.doe@example.com' },
update: {},
create: {
email: 'john.doe@example.com',
name: 'John Doe (Demo Customer)',
role: UserRole.CUSTOMER,
passwordHash: await bcrypt.hash(randomUUID(), 10),
2026-08-19 16:29:17 +05:30
},
});
}