123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- const prisma = require('../../src/prisma/PrismaClient.js');
- async function seedVendors() {
- try {
- // cari user role admin
- const adminUser = await prisma.user.findFirst({
- where: {
- username: 'admin1',
- },
- });
- if (!adminUser) {
- throw new Error('User with role admin not exists');
- }
- // Data vendor yang akan dimasukkan
- const vendors = [
- {
- name: 'MediSoft SIMRS',
- name_pt: 'PT Medisoft Technology',
- strengths: 'Antarmuka user-friendly, support lengkap untuk modul RS',
- weaknesses: 'Harga relatif tinggi',
- website: 'https://medisoft.co.id',
- },
- {
- name: 'SimRS Platinum',
- name_pt: 'PT Platinum Healthtech',
- strengths: 'Integrasi BPJS dan telemedicine',
- weaknesses: 'Customisasi sulit',
- website: 'https://simrsplatinum.id',
- },
- {
- name: 'Hospicare System',
- name_pt: 'PT Hospicare Nusantara',
- strengths: 'Stabil dan dokumentasi lengkap',
- weaknesses: 'Kurang inovatif',
- website: 'https://hospicare.co.id',
- },
- ];
- // Insert vendor dengan created_by dari adminUser.id
- for (const vendor of vendors) {
- await prisma.vendor.create({
- data: {
- ...vendor,
- created_by: adminUser.id,
- },
- });
- }
- console.log('✅ Vendor seeded!');
- } catch (error) {
- console.error('❌ Error seeding vendor:', error);
- }
- }
- module.exports = { seedVendors };
|