180 lines
6.6 KiB
TypeScript
180 lines
6.6 KiB
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
import { hash } from 'bcryptjs';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
console.log('Seeding database...');
|
|
|
|
const adminPassword = await hash('admin123', 12);
|
|
const driverPassword = await hash('driver123', 12);
|
|
|
|
const admin = await prisma.user.upsert({
|
|
where: { email: 'admin@savethemoment.de' },
|
|
update: {},
|
|
create: {
|
|
email: 'admin@savethemoment.de',
|
|
name: 'Dennis Forte',
|
|
password: adminPassword,
|
|
role: 'ADMIN',
|
|
phoneNumber: '+49 123 456789',
|
|
},
|
|
});
|
|
|
|
const driver1 = await prisma.user.upsert({
|
|
where: { email: 'fahrer1@savethemoment.de' },
|
|
update: {},
|
|
create: {
|
|
email: 'fahrer1@savethemoment.de',
|
|
name: 'Max Mustermann',
|
|
password: driverPassword,
|
|
role: 'DRIVER',
|
|
phoneNumber: '+49 123 456780',
|
|
},
|
|
});
|
|
|
|
const driver2 = await prisma.user.upsert({
|
|
where: { email: 'fahrer2@savethemoment.de' },
|
|
update: {},
|
|
create: {
|
|
email: 'fahrer2@savethemoment.de',
|
|
name: 'Anna Schmidt',
|
|
password: driverPassword,
|
|
role: 'DRIVER',
|
|
phoneNumber: '+49 123 456781',
|
|
},
|
|
});
|
|
|
|
const luebeck = await prisma.location.upsert({
|
|
where: { slug: 'luebeck' },
|
|
update: {},
|
|
create: {
|
|
name: 'Lübeck',
|
|
city: 'Lübeck',
|
|
slug: 'luebeck',
|
|
websiteUrl: 'https://fotobox-luebeck.de',
|
|
contactEmail: 'info@fotobox-luebeck.de',
|
|
},
|
|
});
|
|
|
|
const hamburg = await prisma.location.upsert({
|
|
where: { slug: 'hamburg' },
|
|
update: {},
|
|
create: {
|
|
name: 'Hamburg',
|
|
city: 'Hamburg',
|
|
slug: 'hamburg',
|
|
websiteUrl: 'https://hamburg-fotobox.de',
|
|
contactEmail: 'info@hamburg-fotobox.de',
|
|
},
|
|
});
|
|
|
|
const kiel = await prisma.location.upsert({
|
|
where: { slug: 'kiel' },
|
|
update: {},
|
|
create: {
|
|
name: 'Kiel',
|
|
city: 'Kiel',
|
|
slug: 'kiel',
|
|
websiteUrl: 'https://fotobox-kiel.de',
|
|
contactEmail: 'info@fotobox-kiel.de',
|
|
},
|
|
});
|
|
|
|
const berlin = await prisma.location.upsert({
|
|
where: { slug: 'berlin' },
|
|
update: {},
|
|
create: {
|
|
name: 'Berlin',
|
|
city: 'Berlin',
|
|
slug: 'berlin',
|
|
websiteUrl: 'https://fotobox-potsdam.de',
|
|
contactEmail: 'info@fotobox-potsdam.de',
|
|
},
|
|
});
|
|
|
|
const rostock = await prisma.location.upsert({
|
|
where: { slug: 'rostock' },
|
|
update: {},
|
|
create: {
|
|
name: 'Rostock',
|
|
city: 'Rostock',
|
|
slug: 'rostock',
|
|
websiteUrl: 'https://fotobox-rostock.de',
|
|
contactEmail: 'info@fotobox-rostock.de',
|
|
},
|
|
});
|
|
|
|
await prisma.priceConfig.createMany({
|
|
data: [
|
|
{ locationId: luebeck.id, model: 'VINTAGE_SMILE', basePrice: 399, pricePerKm: 0.8, includedKm: 30 },
|
|
{ locationId: luebeck.id, model: 'VINTAGE_PHOTOS', basePrice: 449, pricePerKm: 0.8, includedKm: 30 },
|
|
{ locationId: luebeck.id, model: 'NOSTALGIE', basePrice: 499, pricePerKm: 0.8, includedKm: 30 },
|
|
{ locationId: luebeck.id, model: 'MAGIC_MIRROR', basePrice: 599, pricePerKm: 0.8, includedKm: 30 },
|
|
|
|
{ locationId: hamburg.id, model: 'VINTAGE_SMILE', basePrice: 419, pricePerKm: 0.9, includedKm: 25 },
|
|
{ locationId: hamburg.id, model: 'VINTAGE_PHOTOS', basePrice: 469, pricePerKm: 0.9, includedKm: 25 },
|
|
{ locationId: hamburg.id, model: 'NOSTALGIE', basePrice: 519, pricePerKm: 0.9, includedKm: 25 },
|
|
{ locationId: hamburg.id, model: 'MAGIC_MIRROR', basePrice: 619, pricePerKm: 0.9, includedKm: 25 },
|
|
|
|
{ locationId: kiel.id, model: 'VINTAGE_SMILE', basePrice: 389, pricePerKm: 0.75, includedKm: 35 },
|
|
{ locationId: kiel.id, model: 'VINTAGE_PHOTOS', basePrice: 439, pricePerKm: 0.75, includedKm: 35 },
|
|
{ locationId: kiel.id, model: 'NOSTALGIE', basePrice: 489, pricePerKm: 0.75, includedKm: 35 },
|
|
{ locationId: kiel.id, model: 'MAGIC_MIRROR', basePrice: 589, pricePerKm: 0.75, includedKm: 35 },
|
|
|
|
{ locationId: berlin.id, model: 'VINTAGE_SMILE', basePrice: 409, pricePerKm: 0.85, includedKm: 30 },
|
|
{ locationId: berlin.id, model: 'VINTAGE_PHOTOS', basePrice: 459, pricePerKm: 0.85, includedKm: 30 },
|
|
{ locationId: berlin.id, model: 'NOSTALGIE', basePrice: 509, pricePerKm: 0.85, includedKm: 30 },
|
|
{ locationId: berlin.id, model: 'MAGIC_MIRROR', basePrice: 609, pricePerKm: 0.85, includedKm: 30 },
|
|
|
|
{ locationId: rostock.id, model: 'VINTAGE_SMILE', basePrice: 379, pricePerKm: 0.75, includedKm: 35 },
|
|
{ locationId: rostock.id, model: 'VINTAGE_PHOTOS', basePrice: 429, pricePerKm: 0.75, includedKm: 35 },
|
|
{ locationId: rostock.id, model: 'NOSTALGIE', basePrice: 479, pricePerKm: 0.75, includedKm: 35 },
|
|
{ locationId: rostock.id, model: 'MAGIC_MIRROR', basePrice: 579, pricePerKm: 0.75, includedKm: 35 },
|
|
],
|
|
skipDuplicates: true,
|
|
});
|
|
|
|
await prisma.photobox.createMany({
|
|
data: [
|
|
{ locationId: luebeck.id, model: 'VINTAGE_SMILE', serialNumber: 'LUE-VS-001' },
|
|
{ locationId: luebeck.id, model: 'VINTAGE_SMILE', serialNumber: 'LUE-VS-002' },
|
|
{ locationId: luebeck.id, model: 'VINTAGE_PHOTOS', serialNumber: 'LUE-VP-001' },
|
|
{ locationId: luebeck.id, model: 'NOSTALGIE', serialNumber: 'LUE-NOS-001' },
|
|
{ locationId: luebeck.id, model: 'MAGIC_MIRROR', serialNumber: 'LUE-MM-001' },
|
|
|
|
{ locationId: hamburg.id, model: 'VINTAGE_SMILE', serialNumber: 'HAM-VS-001' },
|
|
{ locationId: hamburg.id, model: 'VINTAGE_SMILE', serialNumber: 'HAM-VS-002' },
|
|
{ locationId: hamburg.id, model: 'VINTAGE_PHOTOS', serialNumber: 'HAM-VP-001' },
|
|
{ locationId: hamburg.id, model: 'NOSTALGIE', serialNumber: 'HAM-NOS-001' },
|
|
{ locationId: hamburg.id, model: 'MAGIC_MIRROR', serialNumber: 'HAM-MM-001' },
|
|
|
|
{ locationId: kiel.id, model: 'VINTAGE_SMILE', serialNumber: 'KIEL-VS-001' },
|
|
{ locationId: kiel.id, model: 'VINTAGE_PHOTOS', serialNumber: 'KIEL-VP-001' },
|
|
{ locationId: kiel.id, model: 'NOSTALGIE', serialNumber: 'KIEL-NOS-001' },
|
|
|
|
{ locationId: berlin.id, model: 'VINTAGE_SMILE', serialNumber: 'BER-VS-001' },
|
|
{ locationId: berlin.id, model: 'MAGIC_MIRROR', serialNumber: 'BER-MM-001' },
|
|
|
|
{ locationId: rostock.id, model: 'VINTAGE_SMILE', serialNumber: 'ROS-VS-001' },
|
|
{ locationId: rostock.id, model: 'NOSTALGIE', serialNumber: 'ROS-NOS-001' },
|
|
],
|
|
skipDuplicates: true,
|
|
});
|
|
|
|
console.log('Database seeded successfully!');
|
|
console.log('\nTest Accounts:');
|
|
console.log('Admin: admin@savethemoment.de / admin123');
|
|
console.log('Fahrer 1: fahrer1@savethemoment.de / driver123');
|
|
console.log('Fahrer 2: fahrer2@savethemoment.de / driver123');
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
});
|