source: prisma/seed.js

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

update the seed script. update the prisma schema, use mapping

  • Property mode set to 100644
File size: 2.4 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.user.deleteMany();
9 await prisma.tenant.deleteMany();
10
11 // Define default tenant data
12 const tenantData = {
13 id: "cm7lxc3p00000pb7kmdrxsfod",
14 name: "MVP Masters",
15 email: "info@mvpmasters.com",
16 address: {
17 street: "Makedonska Treta Brigada 56",
18 city: "Skopje",
19 state: "Macedonia",
20 zip: "1000",
21 country: "Macedonia"
22 },
23 phoneNumber: "+389 72 233 943",
24 representative: "Naum Shapkarovski",
25 lastInvoiceNumber: "1",
26 logoUrl: "https://example.com/default-logo.png",
27 vatNumber: "VAT123456789",
28 companyNumber: "COMP123456",
29 bankAccounts: {
30 eur: {
31 accountNumber: "1234567890",
32 routingNumber: "987654321",
33 bicSwift: "DEFBANKXXX",
34 iban: "DE89370400440532013000"
35 },
36 usd: {
37 accountNumber: "0987654321",
38 routingNumber: "123456789",
39 bicSwift: "DEFBANKXXX",
40 iban: "US89370400440532013000"
41 }
42 },
43 // Add services along with the tenant creation
44 services: {
45 create: [
46 {
47 name: "Web Development",
48 sprint: 5000,
49 hour: 150,
50 month: 8000
51 },
52 {
53 name: "UI/UX Design",
54 sprint: 3000,
55 hour: 120,
56 month: 6000
57 },
58 {
59 name: "Consulting",
60 sprint: 4000,
61 hour: 200,
62 month: 7000
63 }
64 ]
65 }
66 };
67
68 // Create default tenant with services
69 const defaultTenant = await prisma.tenant.create({
70 data: tenantData,
71 include: {
72 services: true
73 }
74 });
75
76 // Add default admin user
77 const defaultUser = await prisma.user.create({
78 data: {
79 id: 'dK2y3WezYWWltHCaBRvUFlddkOr2',
80 uid: 'dK2y3WezYWWltHCaBRvUFlddkOr2',
81 email: 'naum@mvpmasters.com',
82 displayName: 'Naum',
83 role: 'ADMIN',
84 tenantId: 'cm7lxc3p00000pb7kmdrxsfod'
85 }
86 });
87
88 console.log('Seeded default tenant:', defaultTenant);
89 console.log('Seeded default user:', defaultUser);
90
91 console.log('🌱 Seeding database...');
92
93 console.log('✅ Seeding complete!');
94}
95
96main()
97 .catch((e) => {
98 console.error('Error seeding database:', e);
99 process.exit(1);
100 })
101 .finally(async () => {
102 await prisma.$disconnect();
103 });
Note: See TracBrowser for help on using the repository browser.