Game NPCs gain an image upload and a Lexical rich-text bio (with data migration that wraps existing plain text in a paragraph). NPC profile, card and directory surface the portrait, a status-chip row and initials fallback; contacts list and detail pages adopt the redesigned cards.
16 lines
773 B
TypeScript
16 lines
773 B
TypeScript
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
|
|
|
|
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
|
await db.execute(sql`
|
|
ALTER TABLE "game_npcs" ADD COLUMN "image_id" integer;
|
|
ALTER TABLE "game_npcs" ADD CONSTRAINT "game_npcs_image_id_media_id_fk" FOREIGN KEY ("image_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;
|
|
CREATE INDEX "game_npcs_image_idx" ON "game_npcs" USING btree ("image_id");`)
|
|
}
|
|
|
|
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
|
|
await db.execute(sql`
|
|
ALTER TABLE "game_npcs" DROP CONSTRAINT "game_npcs_image_id_media_id_fk";
|
|
|
|
DROP INDEX "game_npcs_image_idx";
|
|
ALTER TABLE "game_npcs" DROP COLUMN "image_id";`)
|
|
}
|