import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres' export async function up({ db, payload, req }: MigrateUpArgs): Promise { await db.execute(sql` CREATE TABLE "technologies_research_costs_resources" ( "_order" integer NOT NULL, "_parent_id" integer NOT NULL, "id" varchar PRIMARY KEY NOT NULL, "resource_id" integer NOT NULL, "amount" numeric DEFAULT 1 NOT NULL ); ALTER TABLE "technologies_research_costs_resources" ADD CONSTRAINT "technologies_research_costs_resources_resource_id_resources_id_fk" FOREIGN KEY ("resource_id") REFERENCES "public"."resources"("id") ON DELETE set null ON UPDATE no action; ALTER TABLE "technologies_research_costs_resources" ADD CONSTRAINT "technologies_research_costs_resources_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."technologies"("id") ON DELETE cascade ON UPDATE no action; CREATE INDEX "technologies_research_costs_resources_order_idx" ON "technologies_research_costs_resources" USING btree ("_order"); CREATE INDEX "technologies_research_costs_resources_parent_id_idx" ON "technologies_research_costs_resources" USING btree ("_parent_id"); CREATE INDEX "technologies_research_costs_resources_resource_idx" ON "technologies_research_costs_resources" USING btree ("resource_id"); ALTER TABLE "technologies" DROP COLUMN "requirements_intelligence_points";`) } export async function down({ db, payload, req }: MigrateDownArgs): Promise { await db.execute(sql` DROP TABLE "technologies_research_costs_resources" CASCADE; ALTER TABLE "technologies" ADD COLUMN "requirements_intelligence_points" numeric;`) }