63 lines
1.6 KiB
TypeScript
63 lines
1.6 KiB
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
// Réseau d'exemple
|
|
const network = await prisma.network.upsert({
|
|
where: { cidr: '192.168.1.0/24' },
|
|
update: {},
|
|
create: {
|
|
name: 'Homelab LAN',
|
|
cidr: '192.168.1.0/24',
|
|
description: 'Réseau principal du homelab',
|
|
gateway: '192.168.1.1',
|
|
dnsServers: '1.1.1.1,9.9.9.9',
|
|
color: '#3b82f6',
|
|
},
|
|
});
|
|
|
|
// Applications usuelles en homelab
|
|
const apps = [
|
|
{ name: 'Jellyfin', category: 'media', description: 'Serveur multimédia' },
|
|
{ name: 'Home Assistant', category: 'automation', description: 'Domotique' },
|
|
{ name: 'Nextcloud', category: 'storage', description: 'Cloud personnel' },
|
|
{ name: 'Pi-hole', category: 'network', description: 'Bloqueur DNS' },
|
|
{ name: 'Portainer', category: 'management', description: 'Gestion Docker' },
|
|
{ name: 'Grafana', category: 'monitoring', description: 'Dashboards' },
|
|
];
|
|
|
|
for (const app of apps) {
|
|
await prisma.application.upsert({
|
|
where: { name: app.name },
|
|
update: {},
|
|
create: app,
|
|
});
|
|
}
|
|
|
|
// Hôte d'exemple
|
|
await prisma.host.upsert({
|
|
where: { ipAddress: '192.168.1.1' },
|
|
update: {},
|
|
create: {
|
|
ipAddress: '192.168.1.1',
|
|
hostname: 'router',
|
|
description: 'Passerelle / routeur du homelab',
|
|
status: 'UP',
|
|
source: 'MANUAL',
|
|
networkId: network.id,
|
|
},
|
|
});
|
|
|
|
console.log('✅ Seed terminé');
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
});
|