feat(GRO-2152): route optimization schema migration #164
Reference in New Issue
Block a user
Delete Branch "feat/gro-2152-route-optimization-schema-dev"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
GRO-2152 — [Phase 1.1] Route Optimization: Schema migration
Database foundation for mobile groomer route optimization (plan: GRO-1164, "Database Schema Changes" section).
Changes (
packages/db)clients:latitude/longitude(double precision, null),geocoded_at(timestamp, null)groomer_routes(new):id,staff_idFK→staff (cascade),route_date(date),status(route_statusenum: draft/optimized/in_progress/completed),total_travel_mins,total_distance_kmnumeric(8,2),optimized_at, timestamps — UNIQUE(staff_id, route_date)route_stops(new):id,route_idFK→groomer_routes (cascade),appointment_idFK→appointments (cascade),stop_order,latitude/longitude(NOT NULL),travel_mins_from_prev,travel_distance_km_from_prevnumeric(8,2),buffer_minsdefault 15, timestamps — UNIQUE(route_id, appointment_id) and UNIQUE(route_id, stop_order)business_settings:default_travel_buffer_mins(int, NOT NULL, default 15),route_optimization_provider(text, defaultnominatim),google_maps_api_key(text, null — encrypted at rest at the app layer, mirroringauth_provider_configs.client_secret)0041_route_optimization.sql— hand-authored, idempotent (IF NOT EXISTS/DO $$ … duplicate_object), matching the established0031_buffer_rulesstyle; journal entry registered withwhen = max(existing)+1so drizzle-kit applies it last.factories.tsbuildClientupdated for the new nullable client columns.Why
packages/dbonlyThe deployed schema + migration source is
packages/db(the Dockerfilemigratestage runspnpm --filter @groombook/db migrate; the image only COPYspackages/+src/).apps/api/src/dbis a legacy CI-only copy frozen at migration 0030 — the last 10 migrations (0031–0040) all landed inpackages/dbonly, anddevis actively deleting the staleapps/apiduplicates (GRO-2129). This change follows that precedent.Verification
pnpm --filter @groombook/db typecheck✅pnpm --filter @groombook/db build✅Closes GRO-2152.
🤖 Generated with Claude Code
cc @cpfarhood