[darmasaba-dashboard][2026-03-27] feat: complete all seeders and update Phase 2 schema
Schema Updates: - Added fields to Umkm model (name, owner, productType, description, timestamps) - Added fields to Posyandu model (name, location, schedule, type, timestamps) - Added fields to SecurityReport model (reportNumber, title, description, location, reportedBy, status, timestamps) - Added fields to EmploymentRecord model (companyName, position, startDate, endDate, isActive, timestamps) - Added fields to PopulationDynamic model (type, residentName, eventDate, description, timestamps) - Added fields to BudgetTransaction model (transactionNumber, type, category, amount, description, date, timestamps) - Added fields to HealthRecord model (type, notes, timestamps) New Seeders: - seed-discussions.ts: Documents, Discussions, DivisionMetrics - seed-phase2.ts: UMKM, Posyandu, SecurityReports, EmploymentRecords, PopulationDynamics, BudgetTransactions Enhanced Seeders: - seed-auth.ts: Added seedApiKeys() function - seed-public-services.ts: Added seedComplaintUpdates() and getComplaintIds() New NPM Scripts: - seed:documents - Seed documents and discussions - seed:phase2 - Seed Phase 2+ features All 33 Prisma models now have seeder coverage (82% direct, 12% stubs, 6% auto-managed) Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -8,6 +8,15 @@ import {
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
/**
|
||||
* Get Complaint IDs
|
||||
* Helper function to retrieve complaint IDs for other seeders
|
||||
*/
|
||||
export async function getComplaintIds(): Promise<string[]> {
|
||||
const complaints = await prisma.complaint.findMany();
|
||||
return complaints.map((c) => c.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Seed Complaints
|
||||
* Creates sample citizen complaints for testing
|
||||
@@ -172,3 +181,39 @@ export async function seedInnovationIdeas(adminId: string) {
|
||||
|
||||
console.log("✅ Innovation Ideas seeded successfully");
|
||||
}
|
||||
|
||||
/**
|
||||
* Seed Complaint Updates
|
||||
* Creates status update history for complaints
|
||||
*/
|
||||
export async function seedComplaintUpdates(complaintIds: string[], userId: string) {
|
||||
console.log("Seeding Complaint Updates...");
|
||||
|
||||
if (complaintIds.length === 0) {
|
||||
console.log("⏭️ No complaints found, skipping updates");
|
||||
return;
|
||||
}
|
||||
|
||||
const updates = [
|
||||
{
|
||||
complaintId: complaintIds[0],
|
||||
message: "Laporan diterima, akan segera ditindaklanjuti",
|
||||
status: ComplaintStatus.BARU,
|
||||
updatedBy: userId,
|
||||
},
|
||||
{
|
||||
complaintId: complaintIds[1],
|
||||
message: "Tim kebersihan telah dikirim ke lokasi",
|
||||
status: ComplaintStatus.DIPROSES,
|
||||
updatedBy: userId,
|
||||
},
|
||||
];
|
||||
|
||||
for (const update of updates) {
|
||||
await prisma.complaintUpdate.create({
|
||||
data: update,
|
||||
});
|
||||
}
|
||||
|
||||
console.log("✅ Complaint Updates seeded successfully");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user