import { getPayload } from "payload"; import config from "@payload-config"; import { Faction } from "@/payload-types"; // These are the default factions as of the campaign "The World We Knew". const DEFAULT_FACTIONS: Omit[] = [ { name: "American Reclamation Project", description: null, playableFaction: true, startingFaction: true, type: "majorFaction", }, { name: "Eurasian Redevelopment Alliance", description: null, playableFaction: true, startingFaction: true, type: "majorFaction", }, { name: "Worldmark", description: null, playableFaction: true, startingFaction: true, type: "majorFaction", }, { name: "Inheritors", description: null, playableFaction: true, startingFaction: true, type: "minorFaction", }, { name: "Deepwell", description: null, playableFaction: true, startingFaction: true, type: "minorFaction", }, { name: "New Horizons", description: null, playableFaction: true, startingFaction: true, type: "minorFaction", }, ]; export const seedFactions = async () => { const payload = await getPayload({ config }); payload.logger.info("Seeding faction data..."); payload.logger.warn("Deleting all existing factions..."); await payload.delete({ collection: "factions", where: { name: { exists: true }, }, }); payload.logger.info(`Creating ${DEFAULT_FACTIONS.length} new factions...`); for (const faction of DEFAULT_FACTIONS) { const result = await payload.create({ collection: "factions", data: { ...faction, }, }); payload.logger.info(`Faction '${result.name}' created.`); } }; await seedFactions();