73 lines
1.9 KiB
TypeScript
73 lines
1.9 KiB
TypeScript
import { PrismaClient, Role, SpaceType } from '@prisma/client';
|
|
import * as bcrypt from 'bcrypt';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
const hashedPassword = await bcrypt.hash('admin123', 10);
|
|
|
|
const org = await prisma.organization.upsert({
|
|
where: { id: 'test-org-id' },
|
|
update: {
|
|
logoUrl: 'https://images.unsplash.com/photo-1542744173-8e7e53415bb0?q=80&w=200&h=200&auto=format&fit=crop',
|
|
},
|
|
create: {
|
|
id: 'test-org-id',
|
|
name: 'Test Organization',
|
|
logoUrl: 'https://images.unsplash.com/photo-1542744173-8e7e53415bb0?q=80&w=200&h=200&auto=format&fit=crop',
|
|
},
|
|
});
|
|
|
|
const admin = await prisma.user.upsert({
|
|
where: { email: 'admin@example.com' },
|
|
update: {},
|
|
create: {
|
|
email: 'admin@example.com',
|
|
password: hashedPassword,
|
|
role: Role.ADMIN,
|
|
organizationId: org.id,
|
|
},
|
|
});
|
|
|
|
const building = await prisma.building.create({
|
|
data: {
|
|
name: 'Headquarters',
|
|
organizationId: org.id,
|
|
floors: {
|
|
create: [
|
|
{
|
|
number: 1,
|
|
spaces: {
|
|
create: [
|
|
{ name: 'Desk 101', type: SpaceType.DESK, x: 10, y: 10 },
|
|
{ name: 'Meeting Room A', type: SpaceType.MEETING_ROOM, x: 50, y: 50 },
|
|
{ name: 'Kitchen', type: SpaceType.AMENITY, x: 80, y: 80 },
|
|
],
|
|
},
|
|
},
|
|
{
|
|
number: 2,
|
|
spaces: {
|
|
create: [
|
|
{ name: 'Desk 201', type: SpaceType.DESK, x: 20, y: 20 },
|
|
{ name: 'Boardroom', type: SpaceType.MEETING_ROOM, x: 60, y: 60 },
|
|
],
|
|
},
|
|
},
|
|
],
|
|
},
|
|
},
|
|
});
|
|
|
|
console.log({ org, admin, building });
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
});
|