BE-DP-03 · Rental chains, the new driver stages, VIN, supply_status, the queue form and due days, from main
ID BE-DP-03 · Level L0 · Pack Pack G2 · The schema the data phase maps v1 onto · Run order row 0a, after pack G2's pull request is merged · Issue #162
Main holds the schema the data phase maps v1 onto:
- Rental chains (D38): when a pricing group's driver daily rate changes, each active rental in it ends that day and a new row at the new rate starts the next day, pointing to the one before (
rentals.previous_rental_id, R-RNT-10). A booked or pending rental takes the new rate in place, with no new row; a pending one is found through its driver's preferred model (R-RNT-22, D67). The rows of a chain count as one rental for the checkpoint due date and "one live rental per car" (R-RNT-17). A contract states no daily rate (contracts.daily_rateis gone, R-RNT-11). - Driver stages (D43):
availableandinactive(R-DRV-19), andmax_queue_miss, 3 by default, which a pool may set (R-SET-08). - VIN (D47):
vehicles.vin, unique within the organization when there is one (R-VEH-26). - supply_status (D56):
vehicles.contract_statusand its enum are nowsupply_status, with the same values. - The queue form (D55): the emergency contact's name, phone and relationship, education and birth date on
queue_tickets(R-QUE-09). - Due days (D57):
charge_types.default_due_days, 3 by default (R-MD-16; the function that changes it comes with M6).
This step changes no file: the code arrived with pack G2's pull request. It proves the change from main on your Mac's local stack.
Before
Section titled “Before”- Pack G2's pull request is merged into main, after BE-DP-02.
- You are in ~/opleet-v2/opleet, the local stack is running, and
git status --shortprints nothing.
1 · Main, rebuilt from nothing
Section titled “1 · Main, rebuilt from nothing”git switch main && git pullpnpm supabase db reset2 · Every test
Section titled “2 · Every test”pnpm supabase test dbExpect
Section titled “Expect”- Block 1: "Finished supabase db reset".
- Block 2:
All tests successful.,Files=15, Tests=393andResult: PASS. (394 on a main from before #231, which removed R-NUM-03's check.)
pnpm supabase db query --local "select table_name, column_name from information_schema.columns where table_schema = 'public' and (table_name, column_name) in (('rentals', 'previous_rental_id'), ('contracts', 'daily_rate'), ('vehicles', 'vin'), ('vehicles', 'supply_status'), ('vehicles', 'contract_status'), ('queue_tickets', 'emergency_contact_name'), ('queue_tickets', 'emergency_contact_phone'), ('queue_tickets', 'emergency_contact_relationship'), ('queue_tickets', 'education'), ('queue_tickets', 'birth_date'), ('charge_types', 'default_due_days'), ('organization_settings', 'max_queue_miss'), ('pool_settings', 'max_queue_miss')) order by 1, 2"pnpm supabase db query --local "select enum_range(null::public.driver_stage)::text as stages, (select tgname from pg_trigger where tgrelid = 'public.pricing_groups'::regclass and tgname = 'change_pricing_group_rate') as rate_trigger"- The first query: 11 rows:
charge_types.default_due_days,organization_settings.max_queue_miss,pool_settings.max_queue_miss, the fivequeue_ticketscolumns,rentals.previous_rental_id,vehicles.supply_statusandvehicles.vin. Neithercontracts.daily_ratenorvehicles.contract_statusis listed. - The second query: one row, whose stages read
{lead,screening,rejected,on_process,approved,booked,listed,available,on_leave,suspended,resigned,inactive,blacklisted}, andchange_pricing_group_rateas the trigger.
If it fails
Section titled “If it fails”supabase db resetstops on a migration: paste the file name and the error into #162. Don't edit the file.- A test fails: paste the
not okline and the lines under it that start with#. - The first query lists
contracts.daily_rateorvehicles.contract_status: main isn't at pack G2. Rungit log -1 --onelineand paste it.
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.
Afterwards: staging
Section titled “Afterwards: staging”Staging still holds the schema from before pack G2. Once this step's run and BE-DP-04's are logged clean, rebuild staging from main with BE-M0-33 and log that run on #22. BE-M0-33 wipes staging and is zuki's alone. Staging's auth settings are set in its Dashboard, not from config.toml (D51).
Log each run as a comment on #162: date · who · result · notes, with the last lines of block 2 and the two queries' output.