ghostguild-org/scripts/seed-all.js
Jennie Robinson Faber fb25e72215
Some checks failed
Test / vitest (push) Successful in 10m36s
Test / playwright (push) Failing after 9m23s
Test / visual (push) Failing after 9m13s
Test / Notify on failure (push) Successful in 2s
Huge bunch of UI/UX improvements and tweaks!
2026-04-06 16:17:12 +01:00

53 lines
1.6 KiB
JavaScript

import mongoose from "mongoose";
import { connectDB } from "../server/utils/mongoose.js";
import dotenv from "dotenv";
// Load environment variables
dotenv.config();
// Import seed functions
import { execSync } from "child_process";
async function seedAll() {
try {
console.log("🌱 Starting database seeding...\n");
// Seed members
console.log("👥 Seeding members...");
execSync("node scripts/seed-members.js", { stdio: "inherit" });
console.log("\n🎉 Seeding events...");
execSync("node scripts/seed-events.js", { stdio: "inherit" });
console.log("\n📅 Seeding series events...");
execSync("node scripts/seed-series-events.js", { stdio: "inherit" });
console.log("\n📋 Seeding pre-registrants...");
execSync("node scripts/seed-pre-registrants.js", { stdio: "inherit" });
console.log("\n✅ All data seeded successfully!");
console.log("\n📊 Database Summary:");
// Connect and show final counts
await connectDB();
const Member = (await import("../server/models/member.js")).default;
const Event = (await import("../server/models/event.js")).default;
const PreRegistration = (await import("../server/models/preRegistration.js")).default;
const memberCount = await Member.countDocuments();
const eventCount = await Event.countDocuments();
const preRegCount = await PreRegistration.countDocuments();
console.log(` Members: ${memberCount}`);
console.log(` Events: ${eventCount}`);
console.log(` Pre-registrants: ${preRegCount}`);
process.exit(0);
} catch (error) {
console.error("❌ Error seeding database:", error);
process.exit(1);
}
}
seedAll();