File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { sql , type MigrateDownArgs , type MigrateUpArgs } from "@payloadcms/db-postgres"
2+
3+ export async function up ( { db } : MigrateUpArgs ) : Promise < void > {
4+ await db . execute ( sql `
5+ DO $$
6+ BEGIN
7+ CREATE TYPE "public"."enum_actions_tags" AS ENUM(
8+ 'AI',
9+ 'Analytics',
10+ 'Communication',
11+ 'Cybersecurity',
12+ 'Data & Storage',
13+ 'Developer Tools',
14+ 'Development',
15+ 'Finance & Accounting',
16+ 'HITL',
17+ 'Marketing',
18+ 'Miscellaneous',
19+ 'Productivity',
20+ 'Sales',
21+ 'Utility'
22+ );
23+ EXCEPTION
24+ WHEN duplicate_object THEN NULL;
25+ END
26+ $$;
27+
28+ CREATE TABLE IF NOT EXISTS "actions_tags" (
29+ "order" integer NOT NULL,
30+ "parent_id" integer NOT NULL,
31+ "value" "enum_actions_tags",
32+ "id" serial PRIMARY KEY NOT NULL
33+ );
34+
35+ DO $$
36+ BEGIN
37+ IF NOT EXISTS (
38+ SELECT 1
39+ FROM "pg_constraint"
40+ WHERE "conname" = 'actions_tags_parent_fk'
41+ AND "conrelid" = '"public"."actions_tags"'::regclass
42+ ) THEN
43+ ALTER TABLE "actions_tags"
44+ ADD CONSTRAINT "actions_tags_parent_fk"
45+ FOREIGN KEY ("parent_id")
46+ REFERENCES "public"."actions"("id")
47+ ON DELETE cascade;
48+ END IF;
49+ END
50+ $$;
51+
52+ CREATE INDEX IF NOT EXISTS "actions_tags_order_idx" ON "actions_tags" ("order");
53+ CREATE INDEX IF NOT EXISTS "actions_tags_parent_idx" ON "actions_tags" ("parent_id");
54+ ` )
55+ }
56+
57+ export async function down ( { db } : MigrateDownArgs ) : Promise < void > {
58+ await db . execute ( sql `
59+ DROP TABLE IF EXISTS "actions_tags";
60+ DROP TYPE IF EXISTS "public"."enum_actions_tags";
61+ ` )
62+ }
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ import * as migration_20260727_193000_small_pricing_block from "./20260727_19300
7070import * as migration_20260727_200000_small_pricing_package_config from "./20260727_200000_small_pricing_package_config"
7171import * as migration_20260727_203000_pricing_block_rename from "./20260727_203000_pricing_block_rename"
7272import * as migration_20260727_210000_small_pricing_block from "./20260727_210000_small_pricing_block"
73+ import * as migration_20260727_220000_repair_actions_tags from "./20260727_220000_repair_actions_tags"
7374
7475export const migrations = [
7576 {
@@ -432,4 +433,9 @@ export const migrations = [
432433 down : migration_20260727_210000_small_pricing_block . down ,
433434 name : "20260727_210000_small_pricing_block" ,
434435 } ,
436+ {
437+ up : migration_20260727_220000_repair_actions_tags . up ,
438+ down : migration_20260727_220000_repair_actions_tags . down ,
439+ name : "20260727_220000_repair_actions_tags" ,
440+ } ,
435441]
You can’t perform that action at this time.
0 commit comments