import { MigrateDownArgs, MigrateUpArgs, sql } from "@payloadcms/db-postgres"; export async function up({ db, payload, req }: MigrateUpArgs): Promise { await db.execute(sql` CREATE TABLE "game_hard_resources" ( "id" serial PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "amount" numeric DEFAULT 0 NOT NULL, "description" jsonb NOT NULL, "updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL, "created_at" timestamp(3) with time zone DEFAULT now() NOT NULL ); ALTER TABLE "payload_locked_documents_rels" ADD COLUMN "game_hard_resources_id" integer; CREATE UNIQUE INDEX "game_hard_resources_name_idx" ON "game_hard_resources" USING btree ("name"); CREATE INDEX "game_hard_resources_updated_at_idx" ON "game_hard_resources" USING btree ("updated_at"); CREATE INDEX "game_hard_resources_created_at_idx" ON "game_hard_resources" USING btree ("created_at"); ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_game_hard_resources_fk" FOREIGN KEY ("game_hard_resources_id") REFERENCES "public"."game_hard_resources"("id") ON DELETE cascade ON UPDATE no action; CREATE INDEX "payload_locked_documents_rels_game_hard_resources_id_idx" ON "payload_locked_documents_rels" USING btree ("game_hard_resources_id");`); } export async function down({ db, payload, req }: MigrateDownArgs): Promise { await db.execute(sql` ALTER TABLE "game_hard_resources" DISABLE ROW LEVEL SECURITY; DROP TABLE "game_hard_resources" CASCADE; ALTER TABLE "payload_locked_documents_rels" DROP CONSTRAINT "payload_locked_documents_rels_game_hard_resources_fk"; DROP INDEX "payload_locked_documents_rels_game_hard_resources_id_idx"; ALTER TABLE "payload_locked_documents_rels" DROP COLUMN "game_hard_resources_id";`); }