BE-M0-37 · Vehicles: inactive, plates and temporary plates, two GPS devices
ID BE-M0-37 · Level L0 · Pack Pack G1 · The review's schema changes · Run order row 22b · Issue #150
A car that leaves the fleet becomes inactive and is never deleted; vehicle:delete is gone (D39, R-VEH-13). A plate is unique among the cars that aren't inactive, except a plate on the temporary plates list, which several cars may carry (R-VEH-02, R-VEH-21, R-TEN-04). Bringing a car back is refused with vehicle.plate_in_use when its plate is now on another car (R-VEH-24). A car has at most one primary and one backup GPS device; the backup starts on standby, and v_vehicle_position reads only the active device (R-VEH-11, R-VEH-23).
This step changes no file: the code arrived with pack G1's pull request. It proves the change on your Mac's local stack.
Before
Section titled “Before”- BE-M0-36 is Done, or you run this step on its own after the same block 1.
- You are in ~/opleet-v2/opleet on main and the local stack is running.
1 · Main, rebuilt from nothing
Section titled “1 · Main, rebuilt from nothing”The migration files were edited in place (D11), so the local database is rebuilt, never migrated.
git switch main && git pullpnpm supabase db reset2 · This part's tests
Section titled “2 · This part's tests”pnpm supabase test db supabase/tests/database/15_vehicles.test.sqlExpect
Section titled “Expect”- Block 1: "Finished supabase db reset".
- Block 2:
okon every line, thenFiles=1, Tests=28andResult: PASS.
pnpm supabase db query --local "select indexdef from pg_indexes where indexname = 'vehicles_plate_unique'"One line ending in WHERE ((status <> 'inactive'::vehicle_status) AND (NOT plate_is_temporary)).
If it fails
Section titled “If it fails”supabase db resetstops on a migration: paste the file name and the error into #150. Don't edit the file.- A test fails: paste the
not okline and the lines under it that start with#. The test's description starts with the rule it proves. - "permission denied" or "must be owner" on auth.sessions: stop and paste it. That means a migration can't end sessions on this stack (D37); BE says so on the issue before changing anything.
Nothing to undo: the step changes no file. pnpm supabase db reset rebuilds the local database from main at any time. Never run any part of it against staging or production.
Log each run as a comment on #150: the date, the last lines of block 2, and the check's output.