fix: Migration 003 - dynamic column restore to handle missing updated_at #42
Reference in New Issue
Block a user
Delete Branch "fix/migration-003-dynamic-columns"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Migration 003 hardcoded
updated_atin theINSERT ... SELECTrestore statement. The oldhealth_recordstable never had anupdated_atcolumn (it was only added in newer schema versions viaALTER TABLE), so the migration crashed with:Fix
Instead of hardcoding the column list, Migration 003 now:
PRAGMA table_info(health_records_migration_backup)after creating the backupNew columns added in the fresh table (
updated_at) will receive theirDEFAULT (datetime('now'))value automatically for any restored rows.Result
Migration 003 is now resilient to any column additions that happened via
ALTER TABLEon old installs.