forked from jsnbuchanan/crowd-funder-for-time-pwa
- Single SQL source: Define MIG_004_SQL constant to eliminate duplicate SQL definitions - Atomic execution: Add BEGIN IMMEDIATE/COMMIT/ROLLBACK around migration execution - Name-only check: Skip migrations already recorded in migrations table - Guarded operations: Replace table-wide cleanups with conditional UPDATE/DELETE Changes: - migration.ts: Extract migration 004 SQL into MIG_004_SQL constant - migration.ts: Use guarded DELETE/UPDATE to prevent accidental data loss - migrationService.ts: Wrap migration execution in explicit transactions - migrationService.ts: Reorder checks to prioritize name-only skipping Benefits: - Prevents partial migration failures from corrupting database state - Eliminates SQL duplication and maintenance overhead - Maintains existing APIs and logging behavior - Reduces risk of data loss during migration execution Test results: All migration tests passing, ID generation working correctly