@workflow/world-postgres 4.2.0 → 4.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@workflow/world-postgres",
3
- "version": "4.2.0",
3
+ "version": "4.3.1",
4
4
  "description": "A reference World implementation based on PostgreSQL",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "bin": {
8
- "workflow-postgres-setup": "./bin/setup.js"
8
+ "bootstrap": "./bin/setup.js",
9
+ "workflow-postgres-setup": "./bin/setup-deprecated.js"
9
10
  },
10
11
  "files": [
11
12
  "dist",
@@ -44,26 +45,26 @@
44
45
  "graphile-worker": "0.16.6",
45
46
  "pg": "8.20.0",
46
47
  "ulid": "~3.0.1",
47
- "zod": "4.3.6",
48
- "@workflow/errors": "4.1.4",
49
- "@workflow/utils": "4.1.3",
50
- "@workflow/world-local": "4.2.0",
51
- "@workflow/world": "4.2.0"
48
+ "zod": "~4.3.6",
49
+ "@workflow/errors": "4.1.5",
50
+ "@workflow/utils": "4.1.4",
51
+ "@workflow/world": "4.2.1",
52
+ "@workflow/world-local": "4.2.2"
52
53
  },
53
54
  "devDependencies": {
54
55
  "@testcontainers/postgresql": "11.12.0",
55
56
  "@types/node": "22.19.0",
56
57
  "@types/pg": "8.20.0",
57
58
  "drizzle-kit": "0.31.9",
58
- "vitest": "^4.0.18",
59
- "@workflow/errors": "4.1.4",
59
+ "vitest": "^4.1.10",
60
+ "@workflow/errors": "4.1.5",
60
61
  "@workflow/tsconfig": "4.0.1",
61
- "@workflow/world-testing": "4.1.10"
62
+ "@workflow/world-testing": "4.1.12"
62
63
  },
63
64
  "keywords": [],
64
65
  "author": "",
65
66
  "scripts": {
66
- "build": "tsc && chmod +x bin/setup.js",
67
+ "build": "tsc && chmod +x bin/setup.js bin/setup-deprecated.js",
67
68
  "dev": "tsc --watch",
68
69
  "clean": "tsc --build --clean && rm -rf dist",
69
70
  "test": "vitest run",
@@ -0,0 +1,75 @@
1
+ DO $$
2
+ DECLARE
3
+ enum_name text;
4
+ public_enum regtype;
5
+ workflow_enum regtype;
6
+ is_used_by_workflow_columns boolean;
7
+ has_dependents_outside_workflow_tables boolean;
8
+ BEGIN
9
+ FOREACH enum_name IN ARRAY ARRAY['status', 'step_status', 'wait_status'] LOOP
10
+ public_enum := to_regtype(format('public.%I', enum_name));
11
+ workflow_enum := to_regtype(format('workflow.%I', enum_name));
12
+
13
+ -- Nothing to migrate when the legacy public enum does not exist, or when
14
+ -- the enum has already been moved to the workflow schema.
15
+ IF public_enum IS NULL OR workflow_enum IS NOT NULL THEN
16
+ CONTINUE;
17
+ END IF;
18
+
19
+ -- Only move enums that are actually used by workflow table columns.
20
+ -- pg_depend has an index on referenced objects, so this lookup is based
21
+ -- on the enum type OID instead of scanning user data or workflow rows.
22
+ SELECT EXISTS (
23
+ SELECT 1
24
+ FROM pg_depend dependency
25
+ JOIN pg_class dependent_table
26
+ ON dependency.classid = 'pg_class'::regclass AND dependency.objid = dependent_table.oid
27
+ JOIN pg_namespace dependent_table_schema
28
+ ON dependent_table_schema.oid = dependent_table.relnamespace
29
+ WHERE dependency.refclassid = 'pg_type'::regclass
30
+ AND dependency.refobjid = public_enum::oid
31
+ AND dependency.objsubid > 0
32
+ AND dependency.deptype != 'i'
33
+ AND dependent_table_schema.nspname = 'workflow'
34
+ ) INTO is_used_by_workflow_columns;
35
+
36
+ IF NOT is_used_by_workflow_columns THEN
37
+ CONTINUE;
38
+ END IF;
39
+
40
+ /*
41
+ pg_depend is Postgres' dependency graph.
42
+
43
+ We use it here as a safety check before moving the enum object itself.
44
+ A normal workflow-owned enum has only workflow table-column dependents,
45
+ so ALTER TYPE ... SET SCHEMA is a fast metadata change.
46
+
47
+ If anything outside workflow tables also depends on this enum, moving it
48
+ would silently rename that user's public enum to workflow.<enum_name>.
49
+ In that case, leave the enum in public, warn, and continue so this cleanup
50
+ migration does not block later migrations.
51
+ */
52
+ SELECT EXISTS (
53
+ SELECT 1
54
+ FROM pg_depend dependency
55
+ LEFT JOIN pg_class dependent_table
56
+ ON dependency.classid = 'pg_class'::regclass AND dependency.objid = dependent_table.oid
57
+ LEFT JOIN pg_namespace dependent_table_schema
58
+ ON dependent_table_schema.oid = dependent_table.relnamespace
59
+ WHERE dependency.refclassid = 'pg_type'::regclass
60
+ AND dependency.refobjid = public_enum::oid
61
+ AND dependency.deptype != 'i'
62
+ AND NOT (
63
+ dependency.classid = 'pg_class'::regclass
64
+ AND dependent_table_schema.nspname = 'workflow'
65
+ )
66
+ ) INTO has_dependents_outside_workflow_tables;
67
+
68
+ IF has_dependents_outside_workflow_tables THEN
69
+ RAISE WARNING 'Skipping move of public.% to workflow schema because objects outside workflow tables depend on it', enum_name;
70
+ CONTINUE;
71
+ END IF;
72
+
73
+ EXECUTE format('ALTER TYPE public.%I SET SCHEMA workflow', enum_name);
74
+ END LOOP;
75
+ END $$;
@@ -78,6 +78,13 @@
78
78
  "when": 1771000000000,
79
79
  "tag": "0010_add_events_entity_creation_unique_index",
80
80
  "breakpoints": true
81
+ },
82
+ {
83
+ "idx": 15,
84
+ "version": "7",
85
+ "when": 1782691200000,
86
+ "tag": "0015_move_enums_to_workflow_schema",
87
+ "breakpoints": true
81
88
  }
82
89
  ]
83
90
  }