update prisma/seed.ts
This commit is contained in:
parent
b7df0455a5
commit
0797d85d78
@ -1,7 +1,12 @@
|
||||
import { PrismaClient, UserRole, RoomStatus } from '@prisma/client';
|
||||
import bcrypt from 'bcryptjs';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
// Demo-Passwörter — nur für die Testdaten, sollten in Produktion geändert werden.
|
||||
const LANDLORD_DEMO_PASSWORD = 'Vermieter2026!';
|
||||
const TENANT_DEMO_PASSWORD = 'Mieter2026!';
|
||||
|
||||
/**
|
||||
* Erzeugt Testdaten für die lokale Entwicklung:
|
||||
* - 1 Vermieter
|
||||
@ -11,6 +16,7 @@ const prisma = new PrismaClient();
|
||||
*/
|
||||
async function main() {
|
||||
console.log('Seed: lösche vorhandene Testdaten...');
|
||||
await prisma.invitation.deleteMany();
|
||||
await prisma.payment.deleteMany();
|
||||
await prisma.contract.deleteMany();
|
||||
await prisma.room.deleteMany();
|
||||
@ -19,7 +25,7 @@ async function main() {
|
||||
const landlord = await prisma.user.create({
|
||||
data: {
|
||||
email: 'vermieter@example.com',
|
||||
passwordHash: 'not-a-real-hash',
|
||||
passwordHash: await bcrypt.hash(LANDLORD_DEMO_PASSWORD, 12),
|
||||
fullName: 'Giuseppe Lombardo',
|
||||
role: UserRole.LANDLORD,
|
||||
},
|
||||
@ -49,7 +55,7 @@ async function main() {
|
||||
const tenant = await prisma.user.create({
|
||||
data: {
|
||||
email: `mieter${i + 1}@example.com`,
|
||||
passwordHash: 'not-a-real-hash',
|
||||
passwordHash: await bcrypt.hash(TENANT_DEMO_PASSWORD, 12),
|
||||
fullName: tenantNames[i],
|
||||
role: UserRole.TENANT,
|
||||
roomId: room.id,
|
||||
@ -79,7 +85,9 @@ async function main() {
|
||||
});
|
||||
}
|
||||
|
||||
console.log('Seed abgeschlossen. Vermieter-Login (Demo):', landlord.email);
|
||||
console.log('Seed abgeschlossen.');
|
||||
console.log(`Vermieter-Login (Demo): ${landlord.email} / ${LANDLORD_DEMO_PASSWORD}`);
|
||||
console.log(`Mieter-Login (Demo, z.B. mieter1@example.com): ${TENANT_DEMO_PASSWORD}`);
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user