2026-09-07 12:45:37 +05:30
|
|
|
import { randomUUID } from 'crypto';
|
2026-08-19 16:29:17 +05:30
|
|
|
import { PrismaClient, UserRole } from '@prisma/client';
|
2026-09-07 12:45:37 +05:30
|
|
|
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...');
|
|
|
|
|
|
2026-09-07 12:45:37 +05:30
|
|
|
// 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,
|
2026-09-07 12:45:37 +05:30
|
|
|
passwordHash: await bcrypt.hash(randomUUID(), 10),
|
2026-08-19 16:29:17 +05:30
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|