source: prisma/seed.js@ 057453c

main
Last change on this file since 057453c was 057453c, checked in by Naum Shapkarovski <naumshapkarovski@…>, 5 weeks ago

feat: implement employees

  • Property mode set to 100644
File size: 1.9 KB
Line 
1import { PrismaClient } from '@prisma/client';
2
3const prisma = new PrismaClient();
4
5async function main() {
6 // Clear existing data
7 await prisma.service.deleteMany();
8 await prisma.tenant.deleteMany();
9
10 // Define default tenant data
11 const tenantData = {
12 name: "Default Company",
13 email: "contact@defaultcompany.com",
14 address: {
15 street: "123 Business Street",
16 city: "Business City",
17 state: "BS",
18 zip: "12345",
19 country: "United States"
20 },
21 phoneNumber: "+1 234 567 8900",
22 representative: "John Doe",
23 lastInvoiceNumber: "1",
24 logoUrl: "https://example.com/default-logo.png",
25 vatNumber: "VAT123456789",
26 companyNumber: "COMP123456",
27 bankAccounts: {
28 eur: {
29 accountNumber: "1234567890",
30 routingNumber: "987654321",
31 bicSwift: "DEFBANKXXX",
32 iban: "DE89370400440532013000"
33 },
34 usd: {
35 accountNumber: "0987654321",
36 routingNumber: "123456789",
37 bicSwift: "DEFBANKXXX",
38 iban: "US89370400440532013000"
39 }
40 },
41 // Add services along with the tenant creation
42 services: {
43 create: [
44 {
45 name: "Web Development",
46 sprint: 5000,
47 hour: 150,
48 month: 8000
49 },
50 {
51 name: "UI/UX Design",
52 sprint: 3000,
53 hour: 120,
54 month: 6000
55 },
56 {
57 name: "Consulting",
58 sprint: 4000,
59 hour: 200,
60 month: 7000
61 }
62 ]
63 }
64 };
65
66 // Create default tenant with services
67 const defaultTenant = await prisma.tenant.create({
68 data: tenantData,
69 include: {
70 services: true
71 }
72 });
73
74 console.log('Seeded default tenant:', defaultTenant);
75
76 console.log('🌱 Seeding database...');
77
78 console.log('✅ Seeding complete!');
79}
80
81main()
82 .catch((e) => {
83 console.error('Error seeding database:', e);
84 process.exit(1);
85 })
86 .finally(async () => {
87 await prisma.$disconnect();
88 });
Note: See TracBrowser for help on using the repository browser.