@pgflow/core 0.0.0-array-map-steps-cd94242a-20251008042921 → 0.0.0-array-map-steps-fixed-types-38a198ae-20251011160533

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/dist/CHANGELOG.md CHANGED
@@ -1,29 +1,48 @@
1
1
  # @pgflow/core
2
2
 
3
- ## 0.0.0-array-map-steps-cd94242a-20251008042921
3
+ ## 0.0.0-array-map-steps-fixed-types-38a198ae-20251011160533
4
4
 
5
5
  ### Minor Changes
6
6
 
7
7
  - 524db03: Add map step type infrastructure in SQL core
8
8
 
9
- ## 🚨🚨🚨 CRITICAL MIGRATION WARNING 🚨🚨🚨
9
+ ⚠️ **This migration includes automatic data migration**
10
10
 
11
- **THIS MIGRATION REQUIRES MANUAL DATA UPDATE BEFORE DEPLOYMENT!**
11
+ The migration will automatically update existing `step_states` rows to satisfy new constraints. This should complete without issues due to strict check constraints enforced in previous versions.
12
12
 
13
- The migration adds a new constraint `remaining_tasks_state_consistency` that will **FAIL ON EXISTING DATA** if not handled properly.
13
+ 💡 **Recommended: Verify before deploying to production**
14
14
 
15
- ### Required Data Migration:
15
+ If you have existing production data and want to verify the migration will succeed cleanly, run this **read-only check query** (does not modify data) in **Supabase Studio** against your **production database**:
16
16
 
17
- Before applying this migration to any environment with existing data, you MUST include:
17
+ 1. Open Supabase Studio SQL Editor
18
+ 2. Copy contents of `pkgs/core/queries/PRE_MIGRATION_CHECK_20251006073122.sql`
19
+ 3. Execute against your production database (not local dev!)
20
+ 4. Review results
18
21
 
19
- ```sql
20
- -- CRITICAL: Update existing step_states to satisfy new constraint
21
- UPDATE pgflow.step_states
22
- SET remaining_tasks = NULL
23
- WHERE status = 'created';
22
+ **Expected output for successful migration:**
23
+
24
+ ```
25
+ type | identifier | details
26
+ ---------------------------|---------------------------|------------------------------------------
27
+ DATA_BACKFILL_STARTED | run=def67890 step=process | initial_tasks will be set to 1 (...)
28
+ DATA_BACKFILL_COMPLETED | Found 100 completed steps | initial_tasks will be set to 1 (...)
29
+ INFO_SUMMARY | total_step_states=114 | created=0 started=1 completed=113 failed=0
24
30
  ```
25
31
 
26
- **Without this update, the migration WILL FAIL in production!** The new constraint requires that `remaining_tasks` can only be set when `status != 'created'`.
32
+ **Interpretation:**
33
+
34
+ - ✅ Only `DATA_BACKFILL_*` and `INFO_SUMMARY` rows? **Safe to migrate**
35
+ - ⚠️ These are expected data migrations handled automatically by the migration
36
+ - 🆘 Unexpected rows or errors? Copy output and share on Discord for help
37
+
38
+ 📝 **Note:** This check identifies data that needs migration but does not modify anything. Only useful for production databases with existing runs.
39
+
40
+ **Automatic data updates:**
41
+
42
+ - Sets `initial_tasks = 1` for all existing steps (correct for pre-map-step schema)
43
+ - Sets `remaining_tasks = NULL` for 'created' status steps (new semantics)
44
+
45
+ No manual intervention required.
27
46
 
28
47
  ***
29
48
 
@@ -66,7 +85,7 @@
66
85
 
67
86
  - Updated dependencies [524db03]
68
87
  - Updated dependencies [524db03]
69
- - @pgflow/dsl@0.0.0-array-map-steps-cd94242a-20251008042921
88
+ - @pgflow/dsl@0.0.0-array-map-steps-fixed-types-38a198ae-20251011160533
70
89
 
71
90
  ## 0.6.1
72
91
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgflow/core",
3
- "version": "0.0.0-array-map-steps-cd94242a-20251008042921",
3
+ "version": "0.0.0-array-map-steps-fixed-types-38a198ae-20251011160533",
4
4
  "license": "AGPL-3.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,14 +1,31 @@
1
1
  -- Modify "step_task_record" composite type
2
2
  ALTER TYPE "pgflow"."step_task_record" ADD ATTRIBUTE "task_index" integer;
3
- -- MANUAL DATA MIGRATION: Prepare existing data for new constraint
4
- -- This UPDATE must run BEFORE the new constraint is added to avoid failures
5
- -- The new constraint "remaining_tasks_state_consistency" requires that
6
- -- remaining_tasks is NULL when status = 'created'
3
+ -- Modify "step_states" table - Step 1: Drop old constraint and NOT NULL
4
+ ALTER TABLE "pgflow"."step_states"
5
+ DROP CONSTRAINT "step_states_remaining_tasks_check",
6
+ ALTER COLUMN "remaining_tasks" DROP NOT NULL,
7
+ ALTER COLUMN "remaining_tasks" DROP DEFAULT,
8
+ ADD COLUMN "initial_tasks" integer NULL;
9
+ -- AUTOMATIC DATA MIGRATION: Prepare existing data for new constraints
10
+ -- This runs AFTER dropping NOT NULL but BEFORE adding new constraints
11
+ -- All old steps had exactly 1 task (enforced by old only_single_task_per_step constraint)
12
+
13
+ -- Backfill initial_tasks = 1 for all existing steps
14
+ -- (Old schema enforced exactly 1 task per step, so all steps had initial_tasks=1)
15
+ UPDATE "pgflow"."step_states"
16
+ SET "initial_tasks" = 1
17
+ WHERE "initial_tasks" IS NULL;
18
+
19
+ -- Set remaining_tasks to NULL for 'created' status
20
+ -- (New semantics: NULL = not started, old semantics: 1 = not started)
7
21
  UPDATE "pgflow"."step_states"
8
22
  SET "remaining_tasks" = NULL
9
- WHERE "status" = 'created';
10
- -- Modify "step_states" table
11
- ALTER TABLE "pgflow"."step_states" DROP CONSTRAINT "step_states_remaining_tasks_check", ADD CONSTRAINT "initial_tasks_known_when_started" CHECK ((status <> 'started'::text) OR (initial_tasks IS NOT NULL)), ADD CONSTRAINT "remaining_tasks_state_consistency" CHECK ((remaining_tasks IS NULL) OR (status <> 'created'::text)), ADD CONSTRAINT "step_states_initial_tasks_check" CHECK ((initial_tasks IS NULL) OR (initial_tasks >= 0)), ALTER COLUMN "remaining_tasks" DROP NOT NULL, ALTER COLUMN "remaining_tasks" DROP DEFAULT, ADD COLUMN "initial_tasks" integer NULL;
23
+ WHERE "status" = 'created' AND "remaining_tasks" IS NOT NULL;
24
+ -- Modify "step_states" table - Step 2: Add new constraints
25
+ ALTER TABLE "pgflow"."step_states"
26
+ ADD CONSTRAINT "initial_tasks_known_when_started" CHECK ((status <> 'started'::text) OR (initial_tasks IS NOT NULL)),
27
+ ADD CONSTRAINT "remaining_tasks_state_consistency" CHECK ((remaining_tasks IS NULL) OR (status <> 'created'::text)),
28
+ ADD CONSTRAINT "step_states_initial_tasks_check" CHECK ((initial_tasks IS NULL) OR (initial_tasks >= 0));
12
29
  -- Modify "step_tasks" table
13
30
  ALTER TABLE "pgflow"."step_tasks" DROP CONSTRAINT "only_single_task_per_step", DROP CONSTRAINT "output_valid_only_for_completed", ADD CONSTRAINT "output_valid_only_for_completed" CHECK ((output IS NULL) OR (status = ANY (ARRAY['completed'::text, 'failed'::text])));
14
31
  -- Modify "steps" table
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgflow/core",
3
- "version": "0.0.0-array-map-steps-cd94242a-20251008042921",
3
+ "version": "0.0.0-array-map-steps-fixed-types-38a198ae-20251011160533",
4
4
  "license": "AGPL-3.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "postgres": "^3.4.5",
27
- "@pgflow/dsl": "0.0.0-array-map-steps-cd94242a-20251008042921"
27
+ "@pgflow/dsl": "0.0.0-array-map-steps-fixed-types-38a198ae-20251011160533"
28
28
  },
29
29
  "publishConfig": {
30
30
  "access": "public"