36 lines
2.3 KiB
Markdown
36 lines
2.3 KiB
Markdown
# Phase 008 Execution
|
|
|
|
## Scope
|
|
- Add compressed YAML backup export and restore for portable application data.
|
|
- Support merge and replace restore modes.
|
|
- Exclude authentication and runtime data from backups.
|
|
|
|
## Changes
|
|
- Added `BackupExport` to produce versioned YAML containing vehicles, users referenced by entries, maintenance schedules, fuel entries, and maintenance entries.
|
|
- Added `BackupImport` to restore versioned YAML in merge or replace mode.
|
|
- Added gzip download and upload handling without adding gem dependencies.
|
|
- Added top-level backup routes and `BackupsController` actions for show, download, and restore.
|
|
- Added a backup/restore page with download, upload, merge, and replace controls.
|
|
- Added a `Backup / Restore` action to the vehicle dashboard.
|
|
- Added request specs for authentication, dashboard visibility, gzip YAML export, merge restore, duplicate prevention, replace restore, invalid gzip uploads, and unsupported backup versions.
|
|
|
|
## Decisions
|
|
- Backup files are gzip-compressed YAML files with a `.yml.gz` filename.
|
|
- Backups include app data only and exclude access keys and user sessions.
|
|
- Replace mode clears user sessions before replacing app data so users can be deleted without foreign-key failures.
|
|
- Replace mode preserves access keys because authentication configuration is outside backup scope.
|
|
- Merge mode updates matched users, vehicles, and maintenance schedules, and creates unmatched records.
|
|
- Users are matched by normalized email.
|
|
- Vehicles are matched by VIN.
|
|
- Maintenance schedules are matched by vehicle and maintenance type.
|
|
- Fuel and maintenance entries are deduplicated with natural keys using vehicle, user, date, odometer, and entry-specific values.
|
|
- Import uses direct inserts for historical entries so UI-specific validations do not block valid restored history.
|
|
- Vehicle current odometers are recalculated after import from incoming vehicle data and all fuel/maintenance entry odometers.
|
|
- Unknown newer versions and older versions without an explicit migration path are rejected.
|
|
|
|
## Verification
|
|
- Passed: `bundle exec rspec spec/requests/backups_spec.rb`
|
|
- Passed: `bundle exec rspec`
|
|
- Passed: `bin/rubocop app/controllers/backups_controller.rb app/services/backup_export.rb app/services/backup_import.rb spec/requests/backups_spec.rb`
|
|
- Passed: `bin/ci`
|