[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:
2026-03-27 14:05:15 +08:00
parent 44b6b158ef
commit c216fa074d
10 changed files with 762 additions and 33 deletions

View File

@@ -117,3 +117,45 @@ export async function seedDemoUsers() {
console.log(`✅ Demo user created: ${demo.email}`);
}
}
/**
* Seed API Keys
* Creates sample API keys for testing API access
*/
export async function seedApiKeys(adminId: string) {
console.log("Seeding API Keys...");
const existingKeys = await prisma.apiKey.findMany({
where: { userId: adminId },
});
if (existingKeys.length > 0) {
console.log("⏭️ API keys already exist, skipping");
return;
}
const apiKeys = [
{
name: "Development Key",
key: "dev_key_" + generateId(),
userId: adminId,
isActive: true,
expiresAt: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000), // 1 year
},
{
name: "Production Key",
key: "prod_key_" + generateId(),
userId: adminId,
isActive: true,
expiresAt: null,
},
];
for (const apiKey of apiKeys) {
await prisma.apiKey.create({
data: apiKey,
});
}
console.log("✅ API Keys seeded successfully");
}