1
0
Fork 0
polaris-task-force/src/migrations/20260905_195456_labor_headcount.ts
Z8MB1E b2718b3633 feat(base): add npc staffing and labor classification collections
Adds the npc-staffing and labor-classifications collections, a shared staffing field factory applied to both structure blueprints (Staffing Defaults group) and game structure instances, blueprint-derived staffing defaults on game structure create, staff-hiring toggles on Game Rules, and their database migrations.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-09-06 01:24:08 -04:00

17 lines
928 B
TypeScript

import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
await db.execute(sql`
CREATE TYPE "public"."enum_npc_staffing_labor_classification" AS ENUM('general', 'doctor', 'mechanic', 'engineer', 'security', 'other');
ALTER TABLE "npc_staffing" ALTER COLUMN "npc_id" DROP NOT NULL;
ALTER TABLE "npc_staffing" ADD COLUMN "headcount" numeric DEFAULT 1;
ALTER TABLE "npc_staffing" ADD COLUMN "labor_classification" "enum_npc_staffing_labor_classification";`)
}
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "npc_staffing" ALTER COLUMN "npc_id" SET NOT NULL;
ALTER TABLE "npc_staffing" DROP COLUMN "headcount";
ALTER TABLE "npc_staffing" DROP COLUMN "labor_classification";
DROP TYPE "public"."enum_npc_staffing_labor_classification";`)
}