You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix: Improve pre-migration check clarity and accuracy (#243)
## Summary
Updates the pre-migration check script (`PRE_MIGRATION_CHECK_20251006073122.sql`) to provide clearer, more accurate messaging about data migrations. Also updates the changeset documentation to match.
## Problem
The original pre-migration check output was misleading:
- Used vague labels like `ISSUE_1_AUTO_FIXED` and `ISSUE_2_AUTO_FIXED`
- Didn't clearly communicate that these are **expected** data migrations
- Missing reporting for completed steps that need backfilling
- Could give false confidence that everything is "auto-fixed" without explaining the criticality
## Changes
### Pre-migration Check Script
- ✅ Renamed output types from `ISSUE_*_AUTO_FIXED` to descriptive `DATA_*` labels
- ✅ Added `DATA_BACKFILL_COMPLETED` row to report completed steps needing backfill
- ✅ Improved detail messages to clearly state what will happen during migration
- ✅ Added critical warning about packaged migration version bug
- ✅ Better documentation explaining how to interpret results
**Before:**
```
type | identifier | details
----------------------|-------------------------|---------------------------
ISSUE_2_AUTO_FIXED | run=8805ef09 step=embed | status=started → will set initial_tasks=1
INFO_SUMMARY | total_step_states=114 | created=0 started=1 completed=113 failed=0
```
**After:**
```
type | identifier | details
---------------------------|---------------------------|------------------------------------------
DATA_BACKFILL_STARTED | run=8805ef09 step=embed | initial_tasks will be set to 1 (inferred from remaining_tasks=1)
DATA_BACKFILL_COMPLETED | Found 113 completed steps | initial_tasks will be set to 1 (old schema enforced single-task)
INFO_SUMMARY | total_step_states=114 | created=0 started=1 completed=113 failed=0
```
### Changeset Documentation
- ✅ Updated example output to match new check format
- ✅ Replaced markdown callouts with emojis (⚠️ 💡 📝)
- ✅ Clarified interpretation guidance
## Testing
Verified against real production-like data:
1. ✅ Created test database with pgmq extension
2. ✅ Imported schema and data dump (114 step_states: 1 started, 113 completed)
3. ✅ Ran pre-migration check - output is clear and accurate
4. ✅ Ran full migration - completed successfully
5. ✅ Verified all data properly migrated (initial_tasks backfilled correctly)
6. ✅ Verified constraints enforce correctness post-migration
## Migration Verification Note
During testing, we confirmed:
- **Local migration file** (`20251006073122_pgflow_add_map_step_type.sql`) is **CORRECT** ✅
- Properly splits ALTER TABLE statements
- Backfills data between schema changes
- Handles started steps correctly
- **Packaged migration** (from published npm package) is **BROKEN** ❌
- Combines column addition and constraint addition in single ALTER TABLE
- Will FAIL on databases with started steps
- Package needs rebuild before next release
## Files Changed
- `pkgs/core/queries/PRE_MIGRATION_CHECK_20251006073122.sql` - Improved clarity and accuracy
- `.changeset/add-map-step-type-infrastructure.md` - Updated documentation and examples
## Related
- Original migration PR: #234
- Issue: Misleading pre-migration check output
Copy file name to clipboardExpand all lines: .changeset/add-map-step-type-infrastructure.md
+35-30Lines changed: 35 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,37 +4,39 @@
4
4
5
5
Add map step type infrastructure in SQL core
6
6
7
-
> [!WARNING]
8
-
> **This migration includes automatic data migration**
9
-
>
10
-
> 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.
11
-
12
-
> [!TIP]
13
-
> **Optional: Verify before deploying to production**
14
-
>
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
-
>
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!)
> - ✅ Only `ISSUE_1_AUTO_FIXED`, `ISSUE_2_AUTO_FIXED`, and `INFO_SUMMARY` rows? **Safe to migrate**
33
-
> - 🆘 Unexpected issues or errors? Copy output and share on Discord for help
34
-
>
35
-
> **Note:** This check only returns results indicating correctness or problems - it does not modify any data. Only useful for production databases with existing runs.
7
+
⚠️ **This migration includes automatic data migration**
8
+
9
+
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.
10
+
11
+
💡 **Recommended: Verify before deploying to production**
12
+
13
+
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**:
14
+
15
+
1. Open Supabase Studio → SQL Editor
16
+
2. Copy contents of `pkgs/core/queries/PRE_MIGRATION_CHECK_20251006073122.sql`
17
+
3. Execute against your production database (not local dev!)
0 commit comments