Merge pull request #42 from internship-humic/feat/admin-data-seeder
chore(seed): menambahkan seeder admin & batch default
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
PORT=**********
|
PORT=**********
|
||||||
NODE_ENV=production
|
NODE_ENV=production
|
||||||
|
|
||||||
|
SEED_ADMIN_USERNAME=admin
|
||||||
|
SEED_ADMIN_PASSWORD=****
|
||||||
|
SEED_ACTIVE_BATCH_NUMBER=7
|
||||||
|
|
||||||
DATABASE_URL="mysql://username:password@host:3306/internify_db"
|
DATABASE_URL="mysql://username:password@host:3306/internify_db"
|
||||||
|
|
||||||
// RSA 256 KEY PAIR FOR JWT SIGNING AND VERIFICATION (bisa digenerate dengan openssl)
|
// RSA 256 KEY PAIR FOR JWT SIGNING AND VERIFICATION (bisa digenerate dengan openssl)
|
||||||
|
|||||||
@@ -0,0 +1,380 @@
|
|||||||
|
const bcrypt = require('bcrypt');
|
||||||
|
const { PrismaClient } = require('../src/generated/prisma');
|
||||||
|
const prisma = new PrismaClient();
|
||||||
|
const { getProjectBackgroundColor } = require('../src/helpers/utils/projectTheme');
|
||||||
|
|
||||||
|
//! Note: File seeder ini hanya digunakan untuk menambahkan data dummy ketika proses development
|
||||||
|
|
||||||
|
// Diperlukan ketika isi databasenya masih kosong dan ingin menambahkan dummy data sebagai testing development [Rafi 08/06/2026 16:34]
|
||||||
|
async function main() {
|
||||||
|
await prisma.taskSubmissionFile.deleteMany({});
|
||||||
|
await prisma.taskSubmission.deleteMany({});
|
||||||
|
await prisma.projectMember.deleteMany({});
|
||||||
|
await prisma.user.deleteMany({});
|
||||||
|
await prisma.task.deleteMany({});
|
||||||
|
await prisma.lamaranMagang.deleteMany({});
|
||||||
|
await prisma.project.deleteMany({});
|
||||||
|
await prisma.lowonganMagang.deleteMany({});
|
||||||
|
await prisma.mahasiswa.deleteMany({});
|
||||||
|
await prisma.riwayatPelamar.deleteMany({});
|
||||||
|
await prisma.feedback.deleteMany({});
|
||||||
|
await prisma.faq.deleteMany({});
|
||||||
|
await prisma.partnership.deleteMany({});
|
||||||
|
await prisma.hasilResearch.deleteMany({});
|
||||||
|
await prisma.batch.deleteMany({});
|
||||||
|
await prisma.admin.deleteMany({});
|
||||||
|
|
||||||
|
const hashedPassword = await bcrypt.hash('password123', 10);
|
||||||
|
|
||||||
|
const admin1 = await prisma.admin.create({
|
||||||
|
data: {
|
||||||
|
nama_depan: 'Admin',
|
||||||
|
nama_belakang: 'One',
|
||||||
|
email: 'admin1@internify.com',
|
||||||
|
password: hashedPassword,
|
||||||
|
role: 'admin',
|
||||||
|
signature: `Admin-One-${Date.now()}`,
|
||||||
|
profile_picture: 'https://placehold.co/150',
|
||||||
|
professional_bio: 'Senior Program Manager at Internify.'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const admin2 = await prisma.admin.create({
|
||||||
|
data: {
|
||||||
|
nama_depan: 'Admin',
|
||||||
|
nama_belakang: 'Two',
|
||||||
|
email: 'admin2@internify.com',
|
||||||
|
password: hashedPassword,
|
||||||
|
role: 'admin',
|
||||||
|
signature: `Admin-Two-${Date.now()}`,
|
||||||
|
profile_picture: 'https://placehold.co/150',
|
||||||
|
professional_bio: 'Lead Engineering Admin at Internify.'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const admin3 = await prisma.admin.create({
|
||||||
|
data: {
|
||||||
|
nama_depan: 'Admin',
|
||||||
|
nama_belakang: 'Three',
|
||||||
|
email: 'admin3@internify.com',
|
||||||
|
password: hashedPassword,
|
||||||
|
role: 'admin',
|
||||||
|
signature: `Admin-Three-${Date.now()}`,
|
||||||
|
profile_picture: 'https://placehold.co/150',
|
||||||
|
professional_bio: 'Design Admin at Internify.'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const mentor1 = await prisma.admin.create({
|
||||||
|
data: {
|
||||||
|
nama_depan: 'Mentor',
|
||||||
|
nama_belakang: 'One',
|
||||||
|
email: 'mentor1@internify.com',
|
||||||
|
password: hashedPassword,
|
||||||
|
role: 'mentor',
|
||||||
|
signature: `Mentor-One-${Date.now()}`,
|
||||||
|
profile_picture: 'https://placehold.co/150',
|
||||||
|
professional_bio: 'Backend Mentor focused on API design, project review, and task evaluation.'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const mentor2 = await prisma.admin.create({
|
||||||
|
data: {
|
||||||
|
nama_depan: 'Mentor',
|
||||||
|
nama_belakang: 'Two',
|
||||||
|
email: 'mentor2@internify.com',
|
||||||
|
password: hashedPassword,
|
||||||
|
role: 'mentor',
|
||||||
|
signature: `Mentor-Two-${Date.now()}`,
|
||||||
|
profile_picture: 'https://placehold.co/150',
|
||||||
|
professional_bio: 'Product and UI/UX Mentor focused on design review and intern guidance.'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const batch1 = await prisma.batch.create({
|
||||||
|
data: { id: 1, batch_number: 1, is_active: false }
|
||||||
|
});
|
||||||
|
const batch2 = await prisma.batch.create({
|
||||||
|
data: { id: 2, batch_number: 2, is_active: false }
|
||||||
|
});
|
||||||
|
const batch3 = await prisma.batch.create({
|
||||||
|
data: { id: 3, batch_number: 3, is_active: true }
|
||||||
|
});
|
||||||
|
|
||||||
|
await prisma.hasilResearch.createMany({
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
nama_project: 'AI Intern Matcher',
|
||||||
|
deskripsi: 'Match students using machine learning algorithms',
|
||||||
|
image_path: 'https://placehold.co/600x400',
|
||||||
|
link_project: 'https://github.com/internify/ai-matcher'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
nama_project: 'Feedback Sentiment Analyzer',
|
||||||
|
deskripsi: 'Analyze student feedback sentiment trends',
|
||||||
|
image_path: 'https://placehold.co/600x400',
|
||||||
|
link_project: 'https://github.com/internify/sentiment'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
nama_project: 'LMS Portal Engine',
|
||||||
|
deskripsi: 'Modular learning management system backend',
|
||||||
|
image_path: 'https://placehold.co/600x400',
|
||||||
|
link_project: 'https://github.com/internify/lms'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
await prisma.partnership.createMany({
|
||||||
|
data: [
|
||||||
|
{ nama_partner: 'Google Indonesia', image_path: 'https://placehold.co/150' },
|
||||||
|
{ nama_partner: 'Microsoft Indonesia', image_path: 'https://placehold.co/150' },
|
||||||
|
{ nama_partner: 'Meta APAC', image_path: 'https://placehold.co/150' }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
// 5. Faq
|
||||||
|
await prisma.faq.createMany({
|
||||||
|
data: [
|
||||||
|
{ pertanyaan: 'Bagaimana cara mendaftar magang?', jawaban: 'Buka menu Lowongan Magang, pilih salah satu lowongan aktif, dan klik tombol daftar.' },
|
||||||
|
{ pertanyaan: 'Apakah program magang ini berbayar?', jawaban: 'Tergantung pada tipe lowongan (paid/unpaid). Detail tertera di tiap deskripsi lowongan.' },
|
||||||
|
{ pertanyaan: 'Berapa lama durasi program magang?', jawaban: 'Biasanya durasi magang berlangsung antara 3 hingga 6 bulan penuh.' }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
// 6. Feedback
|
||||||
|
await prisma.feedback.createMany({
|
||||||
|
data: [
|
||||||
|
{ nama: 'Muhammad Zhafran Ilham', universitas: 'Universitas Telkom Bandung', pesan: 'Pengalaman develelop langsung yang berharga serta experience tersendiri juga dalam membangun teamwork', batch: 6, posisi: 'Backend Developer', tahun: 2026, image_path: 'https://placehold.co/150' },
|
||||||
|
{ nama: 'Anom Ayu Radhaswasti', universitas: 'Universitas Telkom Bandung', pesan: 'Pengalaman yang membuka wawasan baru mengenai dunia kerja profesional, mulai dari proses pengembangan proyek hingga pentingnya komunikasi dan kerja sama dalam tim.', batch: 6, posisi: 'UI/UX Designer', tahun: 2026, image_path: 'https://placehold.co/150' },
|
||||||
|
{ nama: 'Muhammad Rafi Athallah', universitas: 'Universitas Telkom Bandung' ,pesan: 'Ilmu adalah fondasi utama yang sangat penting untuk membuka wawasan, mempertajam pola pikir, serta menjamin masa depan yang lebih cerah dan penuh dengan peluang yang luas.', batch: 6, posisi: 'Backend Developer', tahun: 2026, image_path: 'https://placehold.co/150' },
|
||||||
|
{ nama: 'Kemas M. Aryadary Rasyad', universitas: 'Universitas Telkom Bandung' ,pesan: 'Bagi saya, pengalaman magang di humic akan menjadi bekal saya untuk pengalaman dunia kerja profesional kedepannya', batch: 6, posisi: 'Frontend Developer', tahun: 2026, image_path: 'https://placehold.co/150' },
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
// 7. RiwayatPelamar
|
||||||
|
await prisma.riwayatPelamar.createMany({
|
||||||
|
data: [
|
||||||
|
{ batch: 1, negara: 'Indonesia', posisi: 'Web Developer', tahun: 2025, jumlah: 100, pelamar_diterima: 10, pelamar_ditolak: 70, pelamar_diproses: 20, presentase_diterima: 10.0, presentase_ditolak: 70.0, presentase_diproses: 20.0 },
|
||||||
|
{ batch: 2, negara: 'Indonesia', posisi: 'UI/UX Designer', tahun: 2025, jumlah: 150, pelamar_diterima: 15, pelamar_ditolak: 120, pelamar_diproses: 15, presentase_diterima: 10.0, presentase_ditolak: 80.0, presentase_diproses: 10.0 },
|
||||||
|
{ batch: 2, negara: 'Malaysia', posisi: 'Data Analyst', tahun: 2026, jumlah: 50, pelamar_diterima: 5, pelamar_ditolak: 40, pelamar_diproses: 5, presentase_diterima: 10.0, presentase_ditolak: 80.0, presentase_diproses: 10.0 }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
// 8. Mahasiswa
|
||||||
|
const mhs1 = await prisma.mahasiswa.create({
|
||||||
|
data: { nama_depan: 'Rafi', nama_belakang: 'Athallah', email: 'rafi@student.com', kontak: '08123456789', jurusan: 'Teknik Informatika', universitas: 'ITS', negara: 'Indonesia', cv_path: 'https://example.com/cv-rafi.pdf', portofolio_path: 'https://example.com/portfolio-rafi.pdf', motivasi: 'Ingin mendalami Node.js', relevant_skills: 'Node.js, React, MySQL' }
|
||||||
|
});
|
||||||
|
const mhs2 = await prisma.mahasiswa.create({
|
||||||
|
data: { nama_depan: 'Alice', nama_belakang: 'Smith', email: 'alice@student.com', kontak: '08234567890', jurusan: 'Sistem Informasi', universitas: 'UI', negara: 'Indonesia', cv_path: 'https://example.com/cv-alice.pdf', portofolio_path: 'https://example.com/portfolio-alice.pdf', motivasi: 'Tertarik dengan UI/UX design', relevant_skills: 'Figma, CSS, React' }
|
||||||
|
});
|
||||||
|
const mhs3 = await prisma.mahasiswa.create({
|
||||||
|
data: { nama_depan: 'Bob', nama_belakang: 'Johnson', email: 'bob@student.com', kontak: '08345678901', jurusan: 'Ilmu Komputer', universitas: 'UGM', negara: 'Indonesia', cv_path: 'https://example.com/cv-bob.pdf', portofolio_path: 'https://example.com/portfolio-bob.pdf', motivasi: 'Ingin berkarir di data science', relevant_skills: 'Python, SQL, R' }
|
||||||
|
});
|
||||||
|
const mhs4 = await prisma.mahasiswa.create({
|
||||||
|
data: { nama_depan: 'Dina', nama_belakang: 'Pratama', email: 'dina@student.com', kontak: '08456789012', jurusan: 'Rekayasa Perangkat Lunak',universitas: 'Telkom University', negara: 'Indonesia',cv_path: 'https://example.com/cv-dina.pdf',portofolio_path: 'https://example.com/portfolio-dina.pdf', motivasi: 'Ingin mengembangkan kemampuan backend development', relevant_skills: 'Express.js, Prisma, MySQL' }
|
||||||
|
});
|
||||||
|
const mhs5 = await prisma.mahasiswa.create({
|
||||||
|
data: { nama_depan: 'Eka', nama_belakang: 'Saputra', email: 'eka@student.com', kontak: '08567890123', jurusan: 'Teknik Informatika', universitas: 'Universitas Brawijaya', negara: 'Indonesia', cv_path: 'https://example.com/cv-eka.pdf', portofolio_path: 'https://example.com/portfolio-eka.pdf', motivasi: 'Ingin belajar pengembangan aplikasi web secara profesional', relevant_skills: 'JavaScript, React, Node.js' }
|
||||||
|
});
|
||||||
|
const mhs6 = await prisma.mahasiswa.create({
|
||||||
|
data: { nama_depan: 'Fajar', nama_belakang: 'Nugroho', email: 'fajar@student.com', kontak: '08678901234', jurusan: 'Sistem Informasi', universitas: 'Universitas Airlangga', negara: 'Indonesia', cv_path: 'https://example.com/cv-fajar.pdf', portofolio_path: 'https://example.com/portfolio-fajar.pdf', motivasi: 'Ingin mendalami analisis data dan dashboard reporting', relevant_skills: 'Python, SQL, Tableau' }
|
||||||
|
});
|
||||||
|
const mhs7 = await prisma.mahasiswa.create({
|
||||||
|
data: { nama_depan: 'Gita', nama_belakang: 'Ramadhani', email: 'gita@student.com', kontak: '08789012345', jurusan: 'Desain Komunikasi Visual', universitas: 'Institut Teknologi Bandung', negara: 'Indonesia', cv_path: 'https://example.com/cv-gita.pdf', portofolio_path: 'https://example.com/portfolio-gita.pdf', motivasi: 'Ingin meningkatkan pengalaman dalam UI/UX design', relevant_skills: 'Figma, Wireframing, Prototyping' }
|
||||||
|
});
|
||||||
|
const mhs8 = await prisma.mahasiswa.create({
|
||||||
|
data: { nama_depan: 'Hana', nama_belakang: 'Wijaya', email: 'hana@student.com', kontak: '08890123456', jurusan: 'Ilmu Komputer', universitas: 'Universitas Padjadjaran', negara: 'Indonesia', cv_path: 'https://example.com/cv-hana.pdf', portofolio_path: 'https://example.com/portfolio-hana.pdf', motivasi: 'Ingin belajar pengembangan sistem berbasis cloud', relevant_skills: 'Cloud Computing, REST API, PostgreSQL' }
|
||||||
|
});
|
||||||
|
|
||||||
|
// 9. LowonganMagang
|
||||||
|
const lowongan1 = await prisma.lowonganMagang.create({
|
||||||
|
data: { id: 'LOW-001', posisi: 'Web Developer', kelompok_peminatan: 'Software Engineering', image_path: 'https://placehold.co/600x400', jobdesk: 'Build REST APIs and user interfaces', lokasi: 'Remote', kualifikasi: 'Knowledge of Node.js & React', benefit: 'Certificate, stipend', durasi_awal: new Date('2026-07-01'), durasi_akhir: new Date('2026-12-31'), id_batch: batch3.id, status_lowongan: 'dibuka', paid: 'paid' }
|
||||||
|
});
|
||||||
|
const lowongan2 = await prisma.lowonganMagang.create({
|
||||||
|
data: { id: 'LOW-002', posisi: 'UI/UX Designer', kelompok_peminatan: 'Design', image_path: 'https://placehold.co/600x400', jobdesk: 'Create wireframes, mockups, and high-fidelity designs', lokasi: 'Hybrid', kualifikasi: 'Proficiency in Figma', benefit: 'Certificate, mentoring', durasi_awal: new Date('2026-07-01'), durasi_akhir: new Date('2026-12-31'), id_batch: batch3.id, status_lowongan: 'dibuka', paid: 'unpaid' }
|
||||||
|
});
|
||||||
|
const lowongan3 = await prisma.lowonganMagang.create({
|
||||||
|
data: { id: 'LOW-003', posisi: 'Data Analyst', kelompok_peminatan: 'Data Science', image_path: 'https://placehold.co/600x400', jobdesk: 'Analyze dataset and create interactive dashboard', lokasi: 'Onsite', kualifikasi: 'Skills in Python, SQL, Tableau', benefit: 'Certificate, meals', durasi_awal: new Date('2026-07-01'), durasi_akhir: new Date('2026-12-31'), id_batch: batch3.id, status_lowongan: 'dibuka', paid: 'paid' }
|
||||||
|
});
|
||||||
|
|
||||||
|
// 10. Project
|
||||||
|
const proj1 = await prisma.project.create({
|
||||||
|
data: { id_admin: admin1.id, project_icon: 'code', background_color: getProjectBackgroundColor('code'), project_name: 'Internify Platform Dev', slug: slugify('Internify Platform Dev', 'Project 1 slug'), description: 'Upgrading the core Internify platform backend and web client.', start_date: new Date('2026-07-15'), end_date: new Date('2026-10-15'), status: 'active' }
|
||||||
|
});
|
||||||
|
const proj2 = await prisma.project.create({
|
||||||
|
data: { id_admin: admin2.id, project_icon: 'shield', background_color: getProjectBackgroundColor('shield'), project_name: 'Auth Gateway Module', slug: slugify('Auth Gateway Module', 'Project 2 slug'), description: 'Securing API gateway with unified OAuth2 authentication.', start_date: new Date('2026-07-15'), end_date: new Date('2026-10-15'), status: 'active' }
|
||||||
|
});
|
||||||
|
const proj3 = await prisma.project.create({
|
||||||
|
data: { id_admin: admin1.id, project_icon: 'chart', background_color: getProjectBackgroundColor('chart'), project_name: 'Recruitment Analytics Dashboard', slug: slugify('Recruitment Analytics Dashboard', 'Project 3 slug'), description: 'Developing analytical charts for recruitment metrics.', start_date: new Date('2026-07-15'), end_date: new Date('2026-10-15'), status: 'active' }
|
||||||
|
});
|
||||||
|
const proj4 = await prisma.project.create({
|
||||||
|
data: { id_admin: mentor1.id, project_icon: 'gear', background_color: getProjectBackgroundColor('gear'), project_name: 'Mentor Backend Task Management Project', slug: slugify('Mentor Backend Project', 'Project 4 slug'), description: 'Project owned by mentor for backend project and task management.', start_date: new Date('2026-07-20'), end_date: new Date('2026-10-15'), status: 'active' }
|
||||||
|
});
|
||||||
|
const proj5 = await prisma.project.create({
|
||||||
|
data: { id_admin: mentor2.id, project_icon: 'clipboard', background_color: getProjectBackgroundColor('clipboard'), project_name: 'Mentor UI UX Evaluation Project', slug: slugify('Mentor UI UX Evaluation Project', 'Project 5 slug'), description: 'Project owned by mentor for testing UI/UX mentoring workflow.', start_date: new Date('2026-07-18'), end_date: new Date('2026-10-15'), status: 'active' }
|
||||||
|
});
|
||||||
|
|
||||||
|
// 11. LamaranMagang
|
||||||
|
const lamaran1 = await prisma.lamaranMagang.create({
|
||||||
|
data: { id_mahasiswa: mhs1.id, id_lowongan_magang: lowongan1.id, status: 'diterima', batch: batch3.id, update_at: new Date() }
|
||||||
|
});
|
||||||
|
const lamaran2 = await prisma.lamaranMagang.create({
|
||||||
|
data: { id_mahasiswa: mhs2.id, id_lowongan_magang: lowongan2.id, status: 'diterima', batch: batch3.id, update_at: new Date() }
|
||||||
|
});
|
||||||
|
const lamaran3 = await prisma.lamaranMagang.create({
|
||||||
|
data: { id_mahasiswa: mhs3.id, id_lowongan_magang: lowongan3.id, status: 'diterima', batch: batch3.id, update_at: new Date() }
|
||||||
|
});
|
||||||
|
const lamaran4 = await prisma.lamaranMagang.create({
|
||||||
|
data: { id_mahasiswa: mhs4.id, id_lowongan_magang: lowongan1.id, status: 'diterima', batch: batch3.id, update_at: new Date() }
|
||||||
|
});
|
||||||
|
const lamaran5 = await prisma.lamaranMagang.create({
|
||||||
|
data: { id_mahasiswa: mhs5.id, id_lowongan_magang: lowongan1.id, status: 'diterima', batch: batch3.id, update_at: new Date() }
|
||||||
|
});
|
||||||
|
const lamaran6 = await prisma.lamaranMagang.create({
|
||||||
|
data: { id_mahasiswa: mhs6.id, id_lowongan_magang: lowongan3.id, status: 'diterima', batch: batch3.id, update_at: new Date() }
|
||||||
|
});
|
||||||
|
const lamaran7 = await prisma.lamaranMagang.create({
|
||||||
|
data: { id_mahasiswa: mhs7.id, id_lowongan_magang: lowongan2.id, status: 'diterima', batch: batch3.id, update_at: new Date() }
|
||||||
|
});
|
||||||
|
const lamaran8 = await prisma.lamaranMagang.create({
|
||||||
|
data: { id_mahasiswa: mhs8.id, id_lowongan_magang: lowongan1.id, status: 'diterima', batch: batch3.id, update_at: new Date() }
|
||||||
|
});
|
||||||
|
|
||||||
|
// 12. Task
|
||||||
|
const task1 = await prisma.task.create({
|
||||||
|
data: { id_project: proj1.id, title: 'Database Setup', slug: slugify('Database Setup', 'Task 1 slug'), description: 'Setup database schema and write initial seed script.', deadline_at: new Date('2026-08-01'), submission_type: 'url_link' }
|
||||||
|
});
|
||||||
|
const task2 = await prisma.task.create({
|
||||||
|
data: { id_project: proj1.id, title: 'API Specification', slug: slugify('API Specification', 'Task 2 slug'), description: 'Draft comprehensive swagger API document.', deadline_at: new Date('2026-08-15'), submission_type: 'file_upload' }
|
||||||
|
});
|
||||||
|
const task3 = await prisma.task.create({
|
||||||
|
data: { id_project: proj2.id, title: 'Implement JWT Validation', slug: slugify('Implement JWT Validation', 'Task 3 slug'), description: 'Setup middleware and keys for JWT validation.', deadline_at: new Date('2026-08-10'), submission_type: 'url_link' }
|
||||||
|
});
|
||||||
|
const task4 = await prisma.task.create({
|
||||||
|
data: { id_project: proj4.id, slug: slugify('Review REST API Structure', 'task'), title: 'Review REST API Structure', description: 'Review endpoint structure, response format, and service-repository separation.', deadline_at: new Date('2026-08-20'), submission_type: 'url_link' }
|
||||||
|
});
|
||||||
|
const task5 = await prisma.task.create({
|
||||||
|
data: { id_project: proj4.id, slug: slugify('Prepare Backend Progress Report', 'task'), title: 'Prepare Backend Progress Report', description: 'Prepare a short report about implemented backend features and blockers.', deadline_at: new Date('2026-08-25'), submission_type: 'file_upload'}
|
||||||
|
});
|
||||||
|
const task6 =await prisma.task.create({
|
||||||
|
data: { id_project: proj5.id, slug: slugify('Create UI Review Notes', 'task'), title: 'Create UI Review Notes', description: 'Create UI/UX review notes for dashboard, project detail, and task submission pages.', deadline_at: new Date('2026-08-22'), submission_type: 'file_upload' }
|
||||||
|
});
|
||||||
|
|
||||||
|
// 13. User
|
||||||
|
const user1 = await prisma.user.create({
|
||||||
|
data: { id_mahasiswa: mhs1.id, id_lamaran_magang: lamaran1.id, full_name: 'Rafi Athallah', email: 'rafi@student.com', password: hashedPassword, role: 'intern', is_active: true }
|
||||||
|
});
|
||||||
|
const user2 = await prisma.user.create({
|
||||||
|
data: { id_mahasiswa: mhs2.id, id_lamaran_magang: lamaran2.id, full_name: 'Alice Smith', email: 'alice@student.com', password: hashedPassword, role: 'intern', is_active: true }
|
||||||
|
});
|
||||||
|
const user3 = await prisma.user.create({
|
||||||
|
data: { id_mahasiswa: mhs3.id, id_lamaran_magang: lamaran3.id, full_name: 'Bob Johnson', email: 'bob@student.com', password: hashedPassword, role: 'intern', is_active: true }
|
||||||
|
});
|
||||||
|
const user4 = await prisma.user.create({
|
||||||
|
data: { id_mahasiswa: mhs4.id, id_lamaran_magang: lamaran4.id, full_name: 'Dina Pratama', email: 'dina@student.com', password: hashedPassword, role: 'intern', is_active: true }
|
||||||
|
});
|
||||||
|
const user5 = await prisma.user.create({
|
||||||
|
data: { id_mahasiswa: mhs5.id, id_lamaran_magang: lamaran5.id, full_name: 'Eka Saputra', email: 'eka@student.com', password: hashedPassword, role: 'intern', is_active: true }
|
||||||
|
});
|
||||||
|
const user6 = await prisma.user.create({
|
||||||
|
data: { id_mahasiswa: mhs6.id, id_lamaran_magang: lamaran6.id, full_name: 'Fajar Nugroho', email: 'fajar@student.com', password: hashedPassword, role: 'intern', is_active: true }
|
||||||
|
});
|
||||||
|
const user7 = await prisma.user.create({
|
||||||
|
data: { id_mahasiswa: mhs7.id, id_lamaran_magang: lamaran7.id, full_name: 'Gita Ramadhani', email: 'gita@student.com', password: hashedPassword, role: 'intern', is_active: true }
|
||||||
|
});
|
||||||
|
const user8 = await prisma.user.create({
|
||||||
|
data: { id_mahasiswa: mhs8.id, id_lamaran_magang: lamaran8.id, full_name: 'Hana Wijaya', email: 'hana@student.com', password: hashedPassword, role: 'intern', is_active: true }
|
||||||
|
});
|
||||||
|
|
||||||
|
// 14. ProjectMember
|
||||||
|
await prisma.projectMember.createMany({
|
||||||
|
data: [
|
||||||
|
{ id_project: proj1.id, id_user: user1.id, status: 'active' },
|
||||||
|
{ id_project: proj1.id, id_user: user2.id, status: 'active' },
|
||||||
|
{ id_project: proj2.id, id_user: user3.id, status: 'active' }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
// 15. TaskSubmission
|
||||||
|
await prisma.taskSubmission.create({
|
||||||
|
data: {
|
||||||
|
id_task: task1.id,
|
||||||
|
id_user: user1.id,
|
||||||
|
url_link: 'https://github.com/rafiathallah3',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await prisma.taskSubmission.create({
|
||||||
|
data: {
|
||||||
|
id_task: task2.id,
|
||||||
|
id_user: user2.id,
|
||||||
|
|
||||||
|
// Backward compatibility untuk frontend lama
|
||||||
|
file_path: '/uploads/task-submissions/alice-api-specification-part-1.pdf',
|
||||||
|
|
||||||
|
// Multi-file submission data
|
||||||
|
files: {
|
||||||
|
create: [
|
||||||
|
{
|
||||||
|
file_path: '/uploads/task-submissions/alice-api-specification-part-1.pdf',
|
||||||
|
original_name: 'alice-api-specification-part-1.pdf',
|
||||||
|
mime_type: 'application/pdf',
|
||||||
|
size_bytes: 204800,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
file_path: '/uploads/task-submissions/alice-api-specification-part-2.pdf',
|
||||||
|
original_name: 'alice-api-specification-part-2.pdf',
|
||||||
|
mime_type: 'application/pdf',
|
||||||
|
size_bytes: 256000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
file_path: '/uploads/task-submissions/alice-api-specification-appendix.pdf',
|
||||||
|
original_name: 'alice-api-specification-appendix.pdf',
|
||||||
|
mime_type: 'application/pdf',
|
||||||
|
size_bytes: 128000,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await prisma.taskSubmission.create({
|
||||||
|
data: {
|
||||||
|
id_task: task3.id,
|
||||||
|
id_user: user3.id,
|
||||||
|
url_link: 'https://github.com/bob/auth-gateway',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function slugify(value, fallback = 'item') {
|
||||||
|
if (!value || typeof value !== 'string') {
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
let slug = value
|
||||||
|
.toString()
|
||||||
|
.normalize('NFD')
|
||||||
|
.replace(/[\u0300-\u036f]/g, '')
|
||||||
|
.toLowerCase()
|
||||||
|
.trim()
|
||||||
|
.replace(/[^a-z0-9\s-]/g, '')
|
||||||
|
.replace(/\s+/g, '-')
|
||||||
|
.replace(/-+/g, '-')
|
||||||
|
.replace(/^-|-$/g, '');
|
||||||
|
|
||||||
|
if (!slug) {
|
||||||
|
slug = fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^\d+$/.test(slug)) {
|
||||||
|
slug = `${fallback}-${slug}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return slug;
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
|
.catch((e) => {
|
||||||
|
console.error('Error seeding data:', e);
|
||||||
|
process.exit(1);
|
||||||
|
})
|
||||||
|
.finally(async () => {
|
||||||
|
await prisma.$disconnect();
|
||||||
|
});
|
||||||
+62
-343
@@ -1,371 +1,90 @@
|
|||||||
const bcrypt = require('bcrypt');
|
const bcrypt = require('bcrypt');
|
||||||
const { PrismaClient } = require('../src/generated/prisma');
|
const { PrismaClient } = require('../src/generated/prisma');
|
||||||
|
|
||||||
const prisma = new PrismaClient();
|
const prisma = new PrismaClient();
|
||||||
const { getProjectBackgroundColor } = require('../src/helpers/utils/projectTheme');
|
|
||||||
|
|
||||||
// Diperlukan ketika isi databasenya masih kosong dan ingin menambahkan dummy data sebagai testing development [Rafi 08/06/2026 16:34]
|
async function seedAdmin() {
|
||||||
async function main() {
|
const adminSeederEmail = process.env.SEED_ADMIN_EMAIL?.trim() || 'admin';
|
||||||
await prisma.taskSubmissionFile.deleteMany({});
|
const adminSeederPassword = process.env.SEED_ADMIN_PASSWORD?.trim();
|
||||||
await prisma.taskSubmission.deleteMany({});
|
|
||||||
await prisma.projectMember.deleteMany({});
|
|
||||||
await prisma.user.deleteMany({});
|
|
||||||
await prisma.task.deleteMany({});
|
|
||||||
await prisma.lamaranMagang.deleteMany({});
|
|
||||||
await prisma.project.deleteMany({});
|
|
||||||
await prisma.lowonganMagang.deleteMany({});
|
|
||||||
await prisma.mahasiswa.deleteMany({});
|
|
||||||
await prisma.riwayatPelamar.deleteMany({});
|
|
||||||
await prisma.feedback.deleteMany({});
|
|
||||||
await prisma.faq.deleteMany({});
|
|
||||||
await prisma.partnership.deleteMany({});
|
|
||||||
await prisma.hasilResearch.deleteMany({});
|
|
||||||
await prisma.batch.deleteMany({});
|
|
||||||
await prisma.admin.deleteMany({});
|
|
||||||
|
|
||||||
const hashedPassword = await bcrypt.hash('password123', 10);
|
if (!adminSeederPassword) {
|
||||||
|
throw new Error('SEED_ADMIN_PASSWORD belum diinputkan di environment variable');
|
||||||
|
}
|
||||||
|
|
||||||
const admin1 = await prisma.admin.create({
|
const hashedPassword = await bcrypt.hash(adminSeederPassword, 10);
|
||||||
data: {
|
|
||||||
nama_depan: 'Admin',
|
const admin = await prisma.admin.upsert({
|
||||||
nama_belakang: 'One',
|
where: {
|
||||||
email: 'admin1@internify.com',
|
email: adminSeederEmail,
|
||||||
|
},
|
||||||
|
update: {
|
||||||
password: hashedPassword,
|
password: hashedPassword,
|
||||||
role: 'admin',
|
role: 'admin',
|
||||||
signature: `Admin-One-${Date.now()}`,
|
},
|
||||||
profile_picture: 'https://placehold.co/150',
|
create: {
|
||||||
professional_bio: 'Senior Program Manager at Internify.'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const admin2 = await prisma.admin.create({
|
|
||||||
data: {
|
|
||||||
nama_depan: 'Admin',
|
nama_depan: 'Admin',
|
||||||
nama_belakang: 'Two',
|
nama_belakang: '',
|
||||||
email: 'admin2@internify.com',
|
email: adminSeederEmail,
|
||||||
password: hashedPassword,
|
password: hashedPassword,
|
||||||
role: 'admin',
|
role: 'admin',
|
||||||
signature: `Admin-Two-${Date.now()}`,
|
signature: `Admin-${Date.now()}`,
|
||||||
profile_picture: 'https://placehold.co/150',
|
profile_picture: null,
|
||||||
professional_bio: 'Lead Engineering Admin at Internify.'
|
professional_bio: 'System Administrator',
|
||||||
}
|
|
||||||
});
|
|
||||||
const admin3 = await prisma.admin.create({
|
|
||||||
data: {
|
|
||||||
nama_depan: 'Admin',
|
|
||||||
nama_belakang: 'Three',
|
|
||||||
email: 'admin3@internify.com',
|
|
||||||
password: hashedPassword,
|
|
||||||
role: 'admin',
|
|
||||||
signature: `Admin-Three-${Date.now()}`,
|
|
||||||
profile_picture: 'https://placehold.co/150',
|
|
||||||
professional_bio: 'Design Admin at Internify.'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const mentor1 = await prisma.admin.create({
|
|
||||||
data: {
|
|
||||||
nama_depan: 'Mentor',
|
|
||||||
nama_belakang: 'One',
|
|
||||||
email: 'mentor1@internify.com',
|
|
||||||
password: hashedPassword,
|
|
||||||
role: 'mentor',
|
|
||||||
signature: `Mentor-One-${Date.now()}`,
|
|
||||||
profile_picture: 'https://placehold.co/150',
|
|
||||||
professional_bio: 'Backend Mentor focused on API design, project review, and task evaluation.'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const mentor2 = await prisma.admin.create({
|
|
||||||
data: {
|
|
||||||
nama_depan: 'Mentor',
|
|
||||||
nama_belakang: 'Two',
|
|
||||||
email: 'mentor2@internify.com',
|
|
||||||
password: hashedPassword,
|
|
||||||
role: 'mentor',
|
|
||||||
signature: `Mentor-Two-${Date.now()}`,
|
|
||||||
profile_picture: 'https://placehold.co/150',
|
|
||||||
professional_bio: 'Product and UI/UX Mentor focused on design review and intern guidance.'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const batch1 = await prisma.batch.create({
|
|
||||||
data: { id: 1, batch_number: 1, is_active: false }
|
|
||||||
});
|
|
||||||
const batch2 = await prisma.batch.create({
|
|
||||||
data: { id: 2, batch_number: 2, is_active: false }
|
|
||||||
});
|
|
||||||
const batch3 = await prisma.batch.create({
|
|
||||||
data: { id: 3, batch_number: 3, is_active: true }
|
|
||||||
});
|
|
||||||
|
|
||||||
await prisma.hasilResearch.createMany({
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
nama_project: 'AI Intern Matcher',
|
|
||||||
deskripsi: 'Match students using machine learning algorithms',
|
|
||||||
image_path: 'https://placehold.co/600x400',
|
|
||||||
link_project: 'https://github.com/internify/ai-matcher'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
nama_project: 'Feedback Sentiment Analyzer',
|
|
||||||
deskripsi: 'Analyze student feedback sentiment trends',
|
|
||||||
image_path: 'https://placehold.co/600x400',
|
|
||||||
link_project: 'https://github.com/internify/sentiment'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
nama_project: 'LMS Portal Engine',
|
|
||||||
deskripsi: 'Modular learning management system backend',
|
|
||||||
image_path: 'https://placehold.co/600x400',
|
|
||||||
link_project: 'https://github.com/internify/lms'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
await prisma.partnership.createMany({
|
|
||||||
data: [
|
|
||||||
{ nama_partner: 'Google Indonesia', image_path: 'https://placehold.co/150' },
|
|
||||||
{ nama_partner: 'Microsoft Indonesia', image_path: 'https://placehold.co/150' },
|
|
||||||
{ nama_partner: 'Meta APAC', image_path: 'https://placehold.co/150' }
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
// 5. Faq
|
|
||||||
await prisma.faq.createMany({
|
|
||||||
data: [
|
|
||||||
{ pertanyaan: 'Bagaimana cara mendaftar magang?', jawaban: 'Buka menu Lowongan Magang, pilih salah satu lowongan aktif, dan klik tombol daftar.' },
|
|
||||||
{ pertanyaan: 'Apakah program magang ini berbayar?', jawaban: 'Tergantung pada tipe lowongan (paid/unpaid). Detail tertera di tiap deskripsi lowongan.' },
|
|
||||||
{ pertanyaan: 'Berapa lama durasi program magang?', jawaban: 'Biasanya durasi magang berlangsung antara 3 hingga 6 bulan penuh.' }
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
// 6. Feedback
|
|
||||||
await prisma.feedback.createMany({
|
|
||||||
data: [
|
|
||||||
{ nama: 'Muhammad Zhafran Ilham', universitas: 'Universitas Telkom Bandung', pesan: 'Pengalaman develelop langsung yang berharga serta experience tersendiri juga dalam membangun teamwork', batch: 6, posisi: 'Backend Developer', tahun: 2026, image_path: 'https://placehold.co/150' },
|
|
||||||
{ nama: 'Anom Ayu Radhaswasti', universitas: 'Universitas Telkom Bandung', pesan: 'Pengalaman yang membuka wawasan baru mengenai dunia kerja profesional, mulai dari proses pengembangan proyek hingga pentingnya komunikasi dan kerja sama dalam tim.', batch: 6, posisi: 'UI/UX Designer', tahun: 2026, image_path: 'https://placehold.co/150' },
|
|
||||||
{ nama: 'Muhammad Rafi Athallah', universitas: 'Universitas Telkom Bandung' ,pesan: 'Ilmu adalah fondasi utama yang sangat penting untuk membuka wawasan, mempertajam pola pikir, serta menjamin masa depan yang lebih cerah dan penuh dengan peluang yang luas.', batch: 6, posisi: 'Backend Developer', tahun: 2026, image_path: 'https://placehold.co/150' },
|
|
||||||
{ nama: 'Kemas M. Aryadary Rasyad', universitas: 'Universitas Telkom Bandung' ,pesan: 'Bagi saya, pengalaman magang di humic akan menjadi bekal saya untuk pengalaman dunia kerja profesional kedepannya', batch: 6, posisi: 'Frontend Developer', tahun: 2026, image_path: 'https://placehold.co/150' },
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
// 7. RiwayatPelamar
|
|
||||||
await prisma.riwayatPelamar.createMany({
|
|
||||||
data: [
|
|
||||||
{ batch: 1, negara: 'Indonesia', posisi: 'Web Developer', tahun: 2025, jumlah: 100, pelamar_diterima: 10, pelamar_ditolak: 70, pelamar_diproses: 20, presentase_diterima: 10.0, presentase_ditolak: 70.0, presentase_diproses: 20.0 },
|
|
||||||
{ batch: 2, negara: 'Indonesia', posisi: 'UI/UX Designer', tahun: 2025, jumlah: 150, pelamar_diterima: 15, pelamar_ditolak: 120, pelamar_diproses: 15, presentase_diterima: 10.0, presentase_ditolak: 80.0, presentase_diproses: 10.0 },
|
|
||||||
{ batch: 2, negara: 'Malaysia', posisi: 'Data Analyst', tahun: 2026, jumlah: 50, pelamar_diterima: 5, pelamar_ditolak: 40, pelamar_diproses: 5, presentase_diterima: 10.0, presentase_ditolak: 80.0, presentase_diproses: 10.0 }
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
// 8. Mahasiswa
|
|
||||||
const mhs1 = await prisma.mahasiswa.create({
|
|
||||||
data: { nama_depan: 'Rafi', nama_belakang: 'Athallah', email: 'rafi@student.com', kontak: '08123456789', jurusan: 'Teknik Informatika', universitas: 'ITS', negara: 'Indonesia', cv_path: 'https://example.com/cv-rafi.pdf', portofolio_path: 'https://example.com/portfolio-rafi.pdf', motivasi: 'Ingin mendalami Node.js', relevant_skills: 'Node.js, React, MySQL' }
|
|
||||||
});
|
|
||||||
const mhs2 = await prisma.mahasiswa.create({
|
|
||||||
data: { nama_depan: 'Alice', nama_belakang: 'Smith', email: 'alice@student.com', kontak: '08234567890', jurusan: 'Sistem Informasi', universitas: 'UI', negara: 'Indonesia', cv_path: 'https://example.com/cv-alice.pdf', portofolio_path: 'https://example.com/portfolio-alice.pdf', motivasi: 'Tertarik dengan UI/UX design', relevant_skills: 'Figma, CSS, React' }
|
|
||||||
});
|
|
||||||
const mhs3 = await prisma.mahasiswa.create({
|
|
||||||
data: { nama_depan: 'Bob', nama_belakang: 'Johnson', email: 'bob@student.com', kontak: '08345678901', jurusan: 'Ilmu Komputer', universitas: 'UGM', negara: 'Indonesia', cv_path: 'https://example.com/cv-bob.pdf', portofolio_path: 'https://example.com/portfolio-bob.pdf', motivasi: 'Ingin berkarir di data science', relevant_skills: 'Python, SQL, R' }
|
|
||||||
});
|
|
||||||
const mhs4 = await prisma.mahasiswa.create({
|
|
||||||
data: { nama_depan: 'Dina', nama_belakang: 'Pratama', email: 'dina@student.com', kontak: '08456789012', jurusan: 'Rekayasa Perangkat Lunak',universitas: 'Telkom University', negara: 'Indonesia',cv_path: 'https://example.com/cv-dina.pdf',portofolio_path: 'https://example.com/portfolio-dina.pdf', motivasi: 'Ingin mengembangkan kemampuan backend development', relevant_skills: 'Express.js, Prisma, MySQL' }
|
|
||||||
});
|
|
||||||
const mhs5 = await prisma.mahasiswa.create({
|
|
||||||
data: { nama_depan: 'Eka', nama_belakang: 'Saputra', email: 'eka@student.com', kontak: '08567890123', jurusan: 'Teknik Informatika', universitas: 'Universitas Brawijaya', negara: 'Indonesia', cv_path: 'https://example.com/cv-eka.pdf', portofolio_path: 'https://example.com/portfolio-eka.pdf', motivasi: 'Ingin belajar pengembangan aplikasi web secara profesional', relevant_skills: 'JavaScript, React, Node.js' }
|
|
||||||
});
|
|
||||||
const mhs6 = await prisma.mahasiswa.create({
|
|
||||||
data: { nama_depan: 'Fajar', nama_belakang: 'Nugroho', email: 'fajar@student.com', kontak: '08678901234', jurusan: 'Sistem Informasi', universitas: 'Universitas Airlangga', negara: 'Indonesia', cv_path: 'https://example.com/cv-fajar.pdf', portofolio_path: 'https://example.com/portfolio-fajar.pdf', motivasi: 'Ingin mendalami analisis data dan dashboard reporting', relevant_skills: 'Python, SQL, Tableau' }
|
|
||||||
});
|
|
||||||
const mhs7 = await prisma.mahasiswa.create({
|
|
||||||
data: { nama_depan: 'Gita', nama_belakang: 'Ramadhani', email: 'gita@student.com', kontak: '08789012345', jurusan: 'Desain Komunikasi Visual', universitas: 'Institut Teknologi Bandung', negara: 'Indonesia', cv_path: 'https://example.com/cv-gita.pdf', portofolio_path: 'https://example.com/portfolio-gita.pdf', motivasi: 'Ingin meningkatkan pengalaman dalam UI/UX design', relevant_skills: 'Figma, Wireframing, Prototyping' }
|
|
||||||
});
|
|
||||||
const mhs8 = await prisma.mahasiswa.create({
|
|
||||||
data: { nama_depan: 'Hana', nama_belakang: 'Wijaya', email: 'hana@student.com', kontak: '08890123456', jurusan: 'Ilmu Komputer', universitas: 'Universitas Padjadjaran', negara: 'Indonesia', cv_path: 'https://example.com/cv-hana.pdf', portofolio_path: 'https://example.com/portfolio-hana.pdf', motivasi: 'Ingin belajar pengembangan sistem berbasis cloud', relevant_skills: 'Cloud Computing, REST API, PostgreSQL' }
|
|
||||||
});
|
|
||||||
|
|
||||||
// 9. LowonganMagang
|
|
||||||
const lowongan1 = await prisma.lowonganMagang.create({
|
|
||||||
data: { id: 'LOW-001', posisi: 'Web Developer', kelompok_peminatan: 'Software Engineering', image_path: 'https://placehold.co/600x400', jobdesk: 'Build REST APIs and user interfaces', lokasi: 'Remote', kualifikasi: 'Knowledge of Node.js & React', benefit: 'Certificate, stipend', durasi_awal: new Date('2026-07-01'), durasi_akhir: new Date('2026-12-31'), id_batch: batch3.id, status_lowongan: 'dibuka', paid: 'paid' }
|
|
||||||
});
|
|
||||||
const lowongan2 = await prisma.lowonganMagang.create({
|
|
||||||
data: { id: 'LOW-002', posisi: 'UI/UX Designer', kelompok_peminatan: 'Design', image_path: 'https://placehold.co/600x400', jobdesk: 'Create wireframes, mockups, and high-fidelity designs', lokasi: 'Hybrid', kualifikasi: 'Proficiency in Figma', benefit: 'Certificate, mentoring', durasi_awal: new Date('2026-07-01'), durasi_akhir: new Date('2026-12-31'), id_batch: batch3.id, status_lowongan: 'dibuka', paid: 'unpaid' }
|
|
||||||
});
|
|
||||||
const lowongan3 = await prisma.lowonganMagang.create({
|
|
||||||
data: { id: 'LOW-003', posisi: 'Data Analyst', kelompok_peminatan: 'Data Science', image_path: 'https://placehold.co/600x400', jobdesk: 'Analyze dataset and create interactive dashboard', lokasi: 'Onsite', kualifikasi: 'Skills in Python, SQL, Tableau', benefit: 'Certificate, meals', durasi_awal: new Date('2026-07-01'), durasi_akhir: new Date('2026-12-31'), id_batch: batch3.id, status_lowongan: 'dibuka', paid: 'paid' }
|
|
||||||
});
|
|
||||||
|
|
||||||
// 10. Project
|
|
||||||
const proj1 = await prisma.project.create({
|
|
||||||
data: { id_admin: admin1.id, project_icon: 'code', background_color: getProjectBackgroundColor('code'), project_name: 'Internify Platform Dev', slug: slugify('Internify Platform Dev', 'Project 1 slug'), description: 'Upgrading the core Internify platform backend and web client.', start_date: new Date('2026-07-15'), end_date: new Date('2026-10-15'), status: 'active' }
|
|
||||||
});
|
|
||||||
const proj2 = await prisma.project.create({
|
|
||||||
data: { id_admin: admin2.id, project_icon: 'shield', background_color: getProjectBackgroundColor('shield'), project_name: 'Auth Gateway Module', slug: slugify('Auth Gateway Module', 'Project 2 slug'), description: 'Securing API gateway with unified OAuth2 authentication.', start_date: new Date('2026-07-15'), end_date: new Date('2026-10-15'), status: 'active' }
|
|
||||||
});
|
|
||||||
const proj3 = await prisma.project.create({
|
|
||||||
data: { id_admin: admin1.id, project_icon: 'chart', background_color: getProjectBackgroundColor('chart'), project_name: 'Recruitment Analytics Dashboard', slug: slugify('Recruitment Analytics Dashboard', 'Project 3 slug'), description: 'Developing analytical charts for recruitment metrics.', start_date: new Date('2026-07-15'), end_date: new Date('2026-10-15'), status: 'active' }
|
|
||||||
});
|
|
||||||
const proj4 = await prisma.project.create({
|
|
||||||
data: { id_admin: mentor1.id, project_icon: 'gear', background_color: getProjectBackgroundColor('gear'), project_name: 'Mentor Backend Task Management Project', slug: slugify('Mentor Backend Project', 'Project 4 slug'), description: 'Project owned by mentor for backend project and task management.', start_date: new Date('2026-07-20'), end_date: new Date('2026-10-15'), status: 'active' }
|
|
||||||
});
|
|
||||||
const proj5 = await prisma.project.create({
|
|
||||||
data: { id_admin: mentor2.id, project_icon: 'clipboard', background_color: getProjectBackgroundColor('clipboard'), project_name: 'Mentor UI UX Evaluation Project', slug: slugify('Mentor UI UX Evaluation Project', 'Project 5 slug'), description: 'Project owned by mentor for testing UI/UX mentoring workflow.', start_date: new Date('2026-07-18'), end_date: new Date('2026-10-15'), status: 'active' }
|
|
||||||
});
|
|
||||||
|
|
||||||
// 11. LamaranMagang
|
|
||||||
const lamaran1 = await prisma.lamaranMagang.create({
|
|
||||||
data: { id_mahasiswa: mhs1.id, id_lowongan_magang: lowongan1.id, status: 'diterima', batch: batch3.id, update_at: new Date() }
|
|
||||||
});
|
|
||||||
const lamaran2 = await prisma.lamaranMagang.create({
|
|
||||||
data: { id_mahasiswa: mhs2.id, id_lowongan_magang: lowongan2.id, status: 'diterima', batch: batch3.id, update_at: new Date() }
|
|
||||||
});
|
|
||||||
const lamaran3 = await prisma.lamaranMagang.create({
|
|
||||||
data: { id_mahasiswa: mhs3.id, id_lowongan_magang: lowongan3.id, status: 'diterima', batch: batch3.id, update_at: new Date() }
|
|
||||||
});
|
|
||||||
const lamaran4 = await prisma.lamaranMagang.create({
|
|
||||||
data: { id_mahasiswa: mhs4.id, id_lowongan_magang: lowongan1.id, status: 'diterima', batch: batch3.id, update_at: new Date() }
|
|
||||||
});
|
|
||||||
const lamaran5 = await prisma.lamaranMagang.create({
|
|
||||||
data: { id_mahasiswa: mhs5.id, id_lowongan_magang: lowongan1.id, status: 'diterima', batch: batch3.id, update_at: new Date() }
|
|
||||||
});
|
|
||||||
const lamaran6 = await prisma.lamaranMagang.create({
|
|
||||||
data: { id_mahasiswa: mhs6.id, id_lowongan_magang: lowongan3.id, status: 'diterima', batch: batch3.id, update_at: new Date() }
|
|
||||||
});
|
|
||||||
const lamaran7 = await prisma.lamaranMagang.create({
|
|
||||||
data: { id_mahasiswa: mhs7.id, id_lowongan_magang: lowongan2.id, status: 'diterima', batch: batch3.id, update_at: new Date() }
|
|
||||||
});
|
|
||||||
const lamaran8 = await prisma.lamaranMagang.create({
|
|
||||||
data: { id_mahasiswa: mhs8.id, id_lowongan_magang: lowongan1.id, status: 'diterima', batch: batch3.id, update_at: new Date() }
|
|
||||||
});
|
|
||||||
|
|
||||||
// 12. Task
|
|
||||||
const task1 = await prisma.task.create({
|
|
||||||
data: { id_project: proj1.id, title: 'Database Setup', slug: slugify('Database Setup', 'Task 1 slug'), description: 'Setup database schema and write initial seed script.', deadline_at: new Date('2026-08-01'), submission_type: 'url_link' }
|
|
||||||
});
|
|
||||||
const task2 = await prisma.task.create({
|
|
||||||
data: { id_project: proj1.id, title: 'API Specification', slug: slugify('API Specification', 'Task 2 slug'), description: 'Draft comprehensive swagger API document.', deadline_at: new Date('2026-08-15'), submission_type: 'file_upload' }
|
|
||||||
});
|
|
||||||
const task3 = await prisma.task.create({
|
|
||||||
data: { id_project: proj2.id, title: 'Implement JWT Validation', slug: slugify('Implement JWT Validation', 'Task 3 slug'), description: 'Setup middleware and keys for JWT validation.', deadline_at: new Date('2026-08-10'), submission_type: 'url_link' }
|
|
||||||
});
|
|
||||||
const task4 = await prisma.task.create({
|
|
||||||
data: { id_project: proj4.id, slug: slugify('Review REST API Structure', 'task'), title: 'Review REST API Structure', description: 'Review endpoint structure, response format, and service-repository separation.', deadline_at: new Date('2026-08-20'), submission_type: 'url_link' }
|
|
||||||
});
|
|
||||||
const task5 = await prisma.task.create({
|
|
||||||
data: { id_project: proj4.id, slug: slugify('Prepare Backend Progress Report', 'task'), title: 'Prepare Backend Progress Report', description: 'Prepare a short report about implemented backend features and blockers.', deadline_at: new Date('2026-08-25'), submission_type: 'file_upload'}
|
|
||||||
});
|
|
||||||
const task6 =await prisma.task.create({
|
|
||||||
data: { id_project: proj5.id, slug: slugify('Create UI Review Notes', 'task'), title: 'Create UI Review Notes', description: 'Create UI/UX review notes for dashboard, project detail, and task submission pages.', deadline_at: new Date('2026-08-22'), submission_type: 'file_upload' }
|
|
||||||
});
|
|
||||||
|
|
||||||
// 13. User
|
|
||||||
const user1 = await prisma.user.create({
|
|
||||||
data: { id_mahasiswa: mhs1.id, id_lamaran_magang: lamaran1.id, full_name: 'Rafi Athallah', email: 'rafi@student.com', password: hashedPassword, role: 'intern', is_active: true }
|
|
||||||
});
|
|
||||||
const user2 = await prisma.user.create({
|
|
||||||
data: { id_mahasiswa: mhs2.id, id_lamaran_magang: lamaran2.id, full_name: 'Alice Smith', email: 'alice@student.com', password: hashedPassword, role: 'intern', is_active: true }
|
|
||||||
});
|
|
||||||
const user3 = await prisma.user.create({
|
|
||||||
data: { id_mahasiswa: mhs3.id, id_lamaran_magang: lamaran3.id, full_name: 'Bob Johnson', email: 'bob@student.com', password: hashedPassword, role: 'intern', is_active: true }
|
|
||||||
});
|
|
||||||
const user4 = await prisma.user.create({
|
|
||||||
data: { id_mahasiswa: mhs4.id, id_lamaran_magang: lamaran4.id, full_name: 'Dina Pratama', email: 'dina@student.com', password: hashedPassword, role: 'intern', is_active: true }
|
|
||||||
});
|
|
||||||
const user5 = await prisma.user.create({
|
|
||||||
data: { id_mahasiswa: mhs5.id, id_lamaran_magang: lamaran5.id, full_name: 'Eka Saputra', email: 'eka@student.com', password: hashedPassword, role: 'intern', is_active: true }
|
|
||||||
});
|
|
||||||
const user6 = await prisma.user.create({
|
|
||||||
data: { id_mahasiswa: mhs6.id, id_lamaran_magang: lamaran6.id, full_name: 'Fajar Nugroho', email: 'fajar@student.com', password: hashedPassword, role: 'intern', is_active: true }
|
|
||||||
});
|
|
||||||
const user7 = await prisma.user.create({
|
|
||||||
data: { id_mahasiswa: mhs7.id, id_lamaran_magang: lamaran7.id, full_name: 'Gita Ramadhani', email: 'gita@student.com', password: hashedPassword, role: 'intern', is_active: true }
|
|
||||||
});
|
|
||||||
const user8 = await prisma.user.create({
|
|
||||||
data: { id_mahasiswa: mhs8.id, id_lamaran_magang: lamaran8.id, full_name: 'Hana Wijaya', email: 'hana@student.com', password: hashedPassword, role: 'intern', is_active: true }
|
|
||||||
});
|
|
||||||
|
|
||||||
// 14. ProjectMember
|
|
||||||
await prisma.projectMember.createMany({
|
|
||||||
data: [
|
|
||||||
{ id_project: proj1.id, id_user: user1.id, status: 'active' },
|
|
||||||
{ id_project: proj1.id, id_user: user2.id, status: 'active' },
|
|
||||||
{ id_project: proj2.id, id_user: user3.id, status: 'active' }
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
// 15. TaskSubmission
|
|
||||||
await prisma.taskSubmission.create({
|
|
||||||
data: {
|
|
||||||
id_task: task1.id,
|
|
||||||
id_user: user1.id,
|
|
||||||
url_link: 'https://github.com/rafiathallah3',
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await prisma.taskSubmission.create({
|
return admin;
|
||||||
data: {
|
}
|
||||||
id_task: task2.id,
|
|
||||||
id_user: user2.id,
|
|
||||||
|
|
||||||
// Backward compatibility untuk frontend lama
|
async function seedActiveBatch() {
|
||||||
file_path: '/uploads/task-submissions/alice-api-specification-part-1.pdf',
|
const batchNumber = Number(process.env.SEED_ACTIVE_BATCH_NUMBER || 7);
|
||||||
|
|
||||||
// Multi-file submission data
|
if (!Number.isInteger(batchNumber) || batchNumber < 1) {
|
||||||
files: {
|
throw new Error('SEED_ACTIVE_BATCH_NUMBER harus berupa angka positif');
|
||||||
create: [
|
}
|
||||||
{
|
|
||||||
file_path: '/uploads/task-submissions/alice-api-specification-part-1.pdf',
|
const existingBatch = await prisma.batch.findFirst({
|
||||||
original_name: 'alice-api-specification-part-1.pdf',
|
where: {
|
||||||
mime_type: 'application/pdf',
|
batch_number: batchNumber,
|
||||||
size_bytes: 204800,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
file_path: '/uploads/task-submissions/alice-api-specification-part-2.pdf',
|
|
||||||
original_name: 'alice-api-specification-part-2.pdf',
|
|
||||||
mime_type: 'application/pdf',
|
|
||||||
size_bytes: 256000,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
file_path: '/uploads/task-submissions/alice-api-specification-appendix.pdf',
|
|
||||||
original_name: 'alice-api-specification-appendix.pdf',
|
|
||||||
mime_type: 'application/pdf',
|
|
||||||
size_bytes: 128000,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await prisma.taskSubmission.create({
|
await prisma.batch.updateMany({
|
||||||
|
where: {
|
||||||
|
is_active: true,
|
||||||
|
},
|
||||||
data: {
|
data: {
|
||||||
id_task: task3.id,
|
is_active: false,
|
||||||
id_user: user3.id,
|
},
|
||||||
url_link: 'https://github.com/bob/auth-gateway',
|
});
|
||||||
|
|
||||||
|
if (existingBatch) {
|
||||||
|
return prisma.batch.update({
|
||||||
|
where: {
|
||||||
|
id: existingBatch.id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
is_active: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return prisma.batch.create({
|
||||||
|
data: {
|
||||||
|
batch_number: batchNumber,
|
||||||
|
is_active: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function slugify(value, fallback = 'item') {
|
async function main() {
|
||||||
if (!value || typeof value !== 'string') {
|
const admin = await seedAdmin();
|
||||||
return fallback;
|
const activeBatch = await seedActiveBatch();
|
||||||
}
|
|
||||||
|
|
||||||
let slug = value
|
console.log('Production seed completed successfully');
|
||||||
.toString()
|
console.log(`Admin username: ${admin.email}`);
|
||||||
.normalize('NFD')
|
console.log(`Admin password: ${process.env.SEED_ADMIN_PASSWORD}`);
|
||||||
.replace(/[\u0300-\u036f]/g, '')
|
console.log(`Active batch: ${activeBatch.batch_number}`);
|
||||||
.toLowerCase()
|
|
||||||
.trim()
|
|
||||||
.replace(/[^a-z0-9\s-]/g, '')
|
|
||||||
.replace(/\s+/g, '-')
|
|
||||||
.replace(/-+/g, '-')
|
|
||||||
.replace(/^-|-$/g, '');
|
|
||||||
|
|
||||||
if (!slug) {
|
|
||||||
slug = fallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (/^\d+$/.test(slug)) {
|
|
||||||
slug = `${fallback}-${slug}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return slug;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user