Files
2026-09-15 20:28:07 -06:00

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, and maintenance_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.active with default true.
  • 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 name to 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.md to reflect that bin/ci runs RSpec.
  • Updated DESIGN.md for 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_interval stores integer days; display conversion can happen later.
  • MaintenanceEntry#name is structured and must match a scheduled maintenance type; notes stores 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 rspec and bin/rubocop failed because spec/models/maintenance_entry_spec.rb had an extra end.
  • After fixing the syntax error, bundle exec rspec failed because the maintenance_entry factory created matching schedules during negative validation specs.
  • Updated the factory with an ensure_matching_schedule transient option and disabled it in negative specs.
  • Passed: bundle exec rspec
  • Passed: bin/rubocop
  • Passed: bin/ci