[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:
@@ -2,7 +2,7 @@ import "dotenv/config";
|
||||
import { PrismaClient } from "../generated/prisma";
|
||||
|
||||
// Import all seeders
|
||||
import { seedAdminUser, seedDemoUsers } from "./seeders/seed-auth";
|
||||
import { seedAdminUser, seedDemoUsers, seedApiKeys } from "./seeders/seed-auth";
|
||||
import { seedBanjars, seedResidents, getBanjarIds } from "./seeders/seed-demographics";
|
||||
import { seedDivisions, seedActivities, getDivisionIds } from "./seeders/seed-division-performance";
|
||||
import {
|
||||
@@ -10,8 +10,12 @@ import {
|
||||
seedServiceLetters,
|
||||
seedEvents,
|
||||
seedInnovationIdeas,
|
||||
seedComplaintUpdates,
|
||||
getComplaintIds,
|
||||
} from "./seeders/seed-public-services";
|
||||
import { seedDocuments, seedDiscussions, seedDivisionMetrics } from "./seeders/seed-discussions";
|
||||
import { seedDashboardMetrics } from "./seeders/seed-dashboard-metrics";
|
||||
import { seedPhase2 } from "./seeders/seed-phase2";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
@@ -23,38 +27,53 @@ export async function runSeed() {
|
||||
console.log("🌱 Starting seed...\n");
|
||||
|
||||
// 1. Seed Authentication (Admin & Demo Users)
|
||||
console.log("📁 [1/6] Authentication & Users");
|
||||
console.log("📁 [1/7] Authentication & Users");
|
||||
const adminId = await seedAdminUser();
|
||||
await seedDemoUsers();
|
||||
await seedApiKeys(adminId);
|
||||
console.log();
|
||||
|
||||
// 2. Seed Demographics (Banjars & Residents)
|
||||
console.log("📁 [2/6] Demographics & Population");
|
||||
console.log("📁 [2/7] Demographics & Population");
|
||||
await seedBanjars();
|
||||
const banjarIds = await getBanjarIds();
|
||||
await seedResidents(banjarIds);
|
||||
console.log();
|
||||
|
||||
// 3. Seed Division Performance (Divisions & Activities)
|
||||
console.log("📁 [3/6] Division Performance");
|
||||
console.log("📁 [3/7] Division Performance");
|
||||
const divisions = await seedDivisions();
|
||||
const divisionIds = divisions.map((d) => d.id);
|
||||
await seedActivities(divisionIds);
|
||||
await seedDivisionMetrics(divisionIds);
|
||||
console.log();
|
||||
|
||||
// 4. Seed Public Services (Complaints, Service Letters, Events, Innovation)
|
||||
console.log("📁 [4/6] Public Services");
|
||||
console.log("📁 [4/7] Public Services");
|
||||
await seedComplaints(adminId);
|
||||
await seedServiceLetters(adminId);
|
||||
await seedEvents(adminId);
|
||||
await seedInnovationIdeas(adminId);
|
||||
const complaintIds = await getComplaintIds();
|
||||
await seedComplaintUpdates(complaintIds, adminId);
|
||||
console.log();
|
||||
|
||||
// 5. Seed Dashboard Metrics (Budget, SDGs, Satisfaction)
|
||||
console.log("📁 [5/6] Dashboard Metrics");
|
||||
// 5. Seed Documents & Discussions
|
||||
console.log("📁 [5/7] Documents & Discussions");
|
||||
await seedDocuments(divisionIds, adminId);
|
||||
await seedDiscussions(divisionIds, adminId);
|
||||
console.log();
|
||||
|
||||
// 6. Seed Dashboard Metrics (Budget, SDGs, Satisfaction)
|
||||
console.log("📁 [6/7] Dashboard Metrics");
|
||||
await seedDashboardMetrics();
|
||||
console.log();
|
||||
|
||||
// 7. Seed Phase 2+ Features (UMKM, Posyandu, Security, etc.)
|
||||
console.log("📁 [7/7] Phase 2+ Features");
|
||||
await seedPhase2(banjarIds, adminId);
|
||||
console.log();
|
||||
|
||||
console.log("✅ Seed finished successfully!\n");
|
||||
}
|
||||
|
||||
@@ -69,8 +88,9 @@ export async function runSpecificSeeder(name: string) {
|
||||
case "auth":
|
||||
case "users":
|
||||
console.log("📁 Authentication & Users");
|
||||
await seedAdminUser();
|
||||
const adminId = await seedAdminUser();
|
||||
await seedDemoUsers();
|
||||
await seedApiKeys(adminId);
|
||||
break;
|
||||
|
||||
case "demographics":
|
||||
@@ -87,17 +107,30 @@ export async function runSpecificSeeder(name: string) {
|
||||
const divisions = await seedDivisions();
|
||||
const divisionIds = divisions.map((d) => d.id);
|
||||
await seedActivities(divisionIds);
|
||||
await seedDivisionMetrics(divisionIds);
|
||||
break;
|
||||
|
||||
case "complaints":
|
||||
case "services":
|
||||
case "public":
|
||||
console.log("📁 Public Services");
|
||||
const adminId = await seedAdminUser();
|
||||
await seedComplaints(adminId);
|
||||
await seedServiceLetters(adminId);
|
||||
await seedEvents(adminId);
|
||||
await seedInnovationIdeas(adminId);
|
||||
const pubAdminId = await seedAdminUser();
|
||||
await seedComplaints(pubAdminId);
|
||||
await seedServiceLetters(pubAdminId);
|
||||
await seedEvents(pubAdminId);
|
||||
await seedInnovationIdeas(pubAdminId);
|
||||
const compIds = await getComplaintIds();
|
||||
await seedComplaintUpdates(compIds, pubAdminId);
|
||||
break;
|
||||
|
||||
case "documents":
|
||||
case "discussions":
|
||||
console.log("📁 Documents & Discussions");
|
||||
const docAdminId = await seedAdminUser();
|
||||
const divs = await seedDivisions();
|
||||
const divIds = divs.map((d) => d.id);
|
||||
await seedDocuments(divIds, docAdminId);
|
||||
await seedDiscussions(divIds, docAdminId);
|
||||
break;
|
||||
|
||||
case "dashboard":
|
||||
@@ -106,9 +139,18 @@ export async function runSpecificSeeder(name: string) {
|
||||
await seedDashboardMetrics();
|
||||
break;
|
||||
|
||||
case "phase2":
|
||||
case "features":
|
||||
console.log("📁 Phase 2+ Features");
|
||||
const p2AdminId = await seedAdminUser();
|
||||
await seedBanjars();
|
||||
const p2BanjarIds = await getBanjarIds();
|
||||
await seedPhase2(p2BanjarIds, p2AdminId);
|
||||
break;
|
||||
|
||||
default:
|
||||
console.error(`❌ Unknown seeder: ${name}`);
|
||||
console.log("Available seeders: auth, demographics, divisions, complaints, dashboard");
|
||||
console.log("Available seeders: auth, demographics, divisions, complaints, documents, dashboard, phase2");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user