[5d6f37a] | 1 | import { PrismaClient } from '@prisma/client';
|
---|
| 2 |
|
---|
| 3 | const prisma = new PrismaClient();
|
---|
| 4 |
|
---|
| 5 | async function main() {
|
---|
[057453c] | 6 | // Clear existing data
|
---|
| 7 | await prisma.service.deleteMany();
|
---|
| 8 | await prisma.tenant.deleteMany();
|
---|
[5d6f37a] | 9 |
|
---|
[057453c] | 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"
|
---|
[5d6f37a] | 20 | },
|
---|
[057453c] | 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"
|
---|
[5d6f37a] | 33 | },
|
---|
[057453c] | 34 | usd: {
|
---|
| 35 | accountNumber: "0987654321",
|
---|
| 36 | routingNumber: "123456789",
|
---|
| 37 | bicSwift: "DEFBANKXXX",
|
---|
| 38 | iban: "US89370400440532013000"
|
---|
| 39 | }
|
---|
[5d6f37a] | 40 | },
|
---|
[057453c] | 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 | };
|
---|
[5d6f37a] | 65 |
|
---|
[057453c] | 66 | // Create default tenant with services
|
---|
| 67 | const defaultTenant = await prisma.tenant.create({
|
---|
| 68 | data: tenantData,
|
---|
| 69 | include: {
|
---|
| 70 | services: true
|
---|
| 71 | }
|
---|
[5d6f37a] | 72 | });
|
---|
| 73 |
|
---|
[057453c] | 74 | console.log('Seeded default tenant:', defaultTenant);
|
---|
[5d6f37a] | 75 |
|
---|
[057453c] | 76 | console.log('🌱 Seeding database...');
|
---|
[5d6f37a] | 77 |
|
---|
| 78 | console.log('✅ Seeding complete!');
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | main()
|
---|
| 82 | .catch((e) => {
|
---|
[057453c] | 83 | console.error('Error seeding database:', e);
|
---|
[5d6f37a] | 84 | process.exit(1);
|
---|
| 85 | })
|
---|
| 86 | .finally(async () => {
|
---|
| 87 | await prisma.$disconnect();
|
---|
| 88 | });
|
---|