source: prisma/seed.js@ dc3406b

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

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

  • Property mode set to 100644
File size: 2.4 KB
RevLine 
[5d6f37a]1import { PrismaClient } from '@prisma/client';
2
3const prisma = new PrismaClient();
4
5async function main() {
[057453c]6 // Clear existing data
7 await prisma.service.deleteMany();
[87c9f1e]8 await prisma.user.deleteMany();
[057453c]9 await prisma.tenant.deleteMany();
[5d6f37a]10
[057453c]11 // Define default tenant data
12 const tenantData = {
[87c9f1e]13 id: "cm7lxc3p00000pb7kmdrxsfod",
14 name: "MVP Masters",
15 email: "info@mvpmasters.com",
[057453c]16 address: {
[87c9f1e]17 street: "Makedonska Treta Brigada 56",
18 city: "Skopje",
19 state: "Macedonia",
20 zip: "1000",
21 country: "Macedonia"
[5d6f37a]22 },
[87c9f1e]23 phoneNumber: "+389 72 233 943",
24 representative: "Naum Shapkarovski",
[057453c]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"
[5d6f37a]35 },
[057453c]36 usd: {
37 accountNumber: "0987654321",
38 routingNumber: "123456789",
39 bicSwift: "DEFBANKXXX",
40 iban: "US89370400440532013000"
41 }
[5d6f37a]42 },
[057453c]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 };
[5d6f37a]67
[057453c]68 // Create default tenant with services
69 const defaultTenant = await prisma.tenant.create({
70 data: tenantData,
71 include: {
72 services: true
73 }
[5d6f37a]74 });
75
[87c9f1e]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
[057453c]88 console.log('Seeded default tenant:', defaultTenant);
[87c9f1e]89 console.log('Seeded default user:', defaultUser);
[5d6f37a]90
[057453c]91 console.log('🌱 Seeding database...');
[5d6f37a]92
93 console.log('✅ Seeding complete!');
94}
95
96main()
97 .catch((e) => {
[057453c]98 console.error('Error seeding database:', e);
[5d6f37a]99 process.exit(1);
100 })
101 .finally(async () => {
102 await prisma.$disconnect();
103 });
Note: See TracBrowser for help on using the repository browser.