1
0
Fork 0
polaris-task-force/src/migrations/_archived/20260817_053752.ts
Z8MB1E feccbc0ced chore(migrations): archive superseded migrations and add consolidated migration
Move old migrations (20260109 through 20260817) to _archived/ and add a
single consolidated migration (20260818_024510). Update the migrations
index to reference only the new migration.
2026-08-18 02:05:56 -04:00

33 lines
1.3 KiB
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_shims_shims_type" AS ENUM('css', 'js');
CREATE TABLE "shims_shims" (
"_order" integer NOT NULL,
"_parent_id" integer NOT NULL,
"id" varchar PRIMARY KEY NOT NULL,
"name" varchar NOT NULL,
"summary" varchar,
"content" varchar NOT NULL,
"type" "enum_shims_shims_type" DEFAULT 'css' NOT NULL
);
CREATE TABLE "shims" (
"id" serial PRIMARY KEY NOT NULL,
"updated_at" timestamp(3) with time zone,
"created_at" timestamp(3) with time zone
);
ALTER TABLE "shims_shims" ADD CONSTRAINT "shims_shims_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."shims"("id") ON DELETE cascade ON UPDATE no action;
CREATE INDEX "shims_shims_order_idx" ON "shims_shims" USING btree ("_order");
CREATE INDEX "shims_shims_parent_id_idx" ON "shims_shims" USING btree ("_parent_id");
CREATE UNIQUE INDEX "shims_shims_name_idx" ON "shims_shims" USING btree ("name");`)
}
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
await db.execute(sql`
DROP TABLE "shims_shims" CASCADE;
DROP TABLE "shims" CASCADE;
DROP TYPE "public"."enum_shims_shims_type";`)
}