1.2 KiB
1.2 KiB
SQLite Migration and Rollback Procedure
Rules
- Read the current schema version before application startup writes new data.
- Create a verified pre-migration backup of the database and required companion state.
- Apply sequential idempotent migrations in one exclusive transaction where SQLite permits.
- Record the new version only after all statements and validation checks succeed.
- On failure, roll back the transaction, preserve the original database and record a redacted error.
- Never downgrade destructively. Restore the pre-migration backup when rollback requires an older application version.
Validation
- Fresh database reaches the latest version.
- Each supported previous version upgrades exactly once.
- Re-running the migration is a no-op.
- Interrupted/failed migration leaves a usable prior database or verified recovery copy.
- Existing users, sessions, audit history, licensing state, settings and supported customer data remain readable.
- Backup compatibility is checked before any restore mutation.
Rollback Evidence
Record source and target schema versions, backup path/checksum, start/end time, result, correlation ID, validation outcome, and recovery action without storing secrets or customer content.