2.4 KiB
2.4 KiB
Phase 002 Execution
Scope
- Added the core relational data model for users, vehicles, maintenance schedules, fuel entries, and maintenance entries.
- Added validations, factories, and model specs for the new models.
- Updated project documentation for confirmed Phase 002 decisions.
Changes
- Added migrations for
users,vehicles,maintenance_schedules,fuel_entries, andmaintenance_entries. - Added required fields and foreign keys for all Phase 002 tables.
- Added unique indexes for user email, vehicle VIN, vehicle licence plate, and per-vehicle maintenance schedule type.
- Added
vehicles.activewith defaulttrue. - Added ActiveRecord models and associations.
- Restricted deletion of users and vehicles when historical entries reference them.
- Added model validations for presence, uniqueness, numeric bounds, realistic vehicle years, and future-date rejection.
- Added VIN normalization to uppercase.
- Added maintenance entry validation requiring
nameto match a vehicle maintenance schedule case-insensitively. - Added factories for all new models.
- Added model specs for factories, validations, uniqueness, normalization, schedule matching, and restricted deletion.
- Updated
AGENTS.mdto reflect thatbin/ciruns RSpec. - Updated
DESIGN.mdfor corrected names and confirmed data-model rules.
Decisions
- All Phase 002 table fields are required with
null: false. - Email and licence plate uniqueness are case-insensitive.
- VIN is normalized to uppercase before validation and storage.
MaintenanceSchedule#time_intervalstores integer days; display conversion can happen later.MaintenanceEntry#nameis structured and must match a scheduled maintenance type;notesstores free-form details.- Fuel price must be greater than zero; maintenance cost may be zero.
- Fuel and maintenance entry dates cannot be in the future.
- Vehicles are not deleted; they can be marked inactive later.
Verification
- Passed:
bundle exec rails db:migrate - Initial
bundle exec rspecandbin/rubocopfailed becausespec/models/maintenance_entry_spec.rbhad an extraend. - After fixing the syntax error,
bundle exec rspecfailed because themaintenance_entryfactory created matching schedules during negative validation specs. - Updated the factory with an
ensure_matching_scheduletransient option and disabled it in negative specs. - Passed:
bundle exec rspec - Passed:
bin/rubocop - Passed:
bin/ci