Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
16 lines
945 B
TypeScript
16 lines
945 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_structures" ADD COLUMN "parent_structure_id" integer;
|
|
ALTER TABLE "game_structures" ADD CONSTRAINT "game_structures_parent_structure_id_game_structures_id_fk" FOREIGN KEY ("parent_structure_id") REFERENCES "public"."game_structures"("id") ON DELETE set null ON UPDATE no action;
|
|
CREATE INDEX "game_structures_parent_structure_idx" ON "game_structures" USING btree ("parent_structure_id");`)
|
|
}
|
|
|
|
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
|
|
await db.execute(sql`
|
|
ALTER TABLE "game_structures" DROP CONSTRAINT "game_structures_parent_structure_id_game_structures_id_fk";
|
|
|
|
DROP INDEX "game_structures_parent_structure_idx";
|
|
ALTER TABLE "game_structures" DROP COLUMN "parent_structure_id";`)
|
|
}
|