16ad0955f2
Deploy to route.crispygoat.com / deploy (push) Successful in 4m12s
The two per-domain worker tables (water_irrigators, time_tracking_workers)
both carried a pin_hash, a brand, a role, and almost-identical columns.
Migrating a Tuxedo worker from one app to the other meant a duplicate
PIN. Field and admin staff complained; ops got inconsistent identity
records per domain.
Unify into a single field_workers table. Cycle 10 migration
0097_field_workers.sql:
- creates field_workers (id, brand_id, name, pin_hash, role with CHECK
IN ('worker','time_admin','irrigator','water_admin'),
language_preference, phone, notes, active, last_used_at, …)
- adds brand-scoped RLS, brand index, active index
- nullable field_worker_id on downstream tables, backfilled via
UPDATE … FROM, NULL count verified with RAISE EXCEPTION before
SET NOT NULL
- drops the two old tables and renames FK columns
(irrigator_id → field_worker_id, worker_id → field_worker_id)
- reissues the one-open-clock-in partial unique index against
field_worker_id
Application surface:
- All actions/services now read/write fieldWorkers. Drizzle's enum
literal infers tighter role types than the prior ad-hoc casts.
- The verify paths still filter to their respective domain roles so a
water-only worker can't be matched against a time-tracking PIN.
- API surface preserved: action function names didn't change.
- Seed file updated so QA reseeds work post-deploy.
Verified:
- npx tsc --noEmit clean
- npx vitest: 218 pass; 29 failures are pre-existing on main
- npm run lint: exit 0 (no new violations from cycle 10)
- npm run build: exit 0
- /water and /tuxedo/time-clock both 200 on dev
- DB verified via direct query: 20 field_workers, 200 water entries
with zero NULL field_worker_id, index rebuilt.
PR-reviewer: APPROVED.
20 lines
581 B
TypeScript
20 lines
581 B
TypeScript
/**
|
|
* Schema barrel. Re-exports every Drizzle table + inferred row type.
|
|
* Source of truth: `db/migrations/0001_init.sql`.
|
|
*/
|
|
export * from "./brands";
|
|
export * from "./billing";
|
|
export * from "./products";
|
|
export * from "./stops";
|
|
export * from "./customers";
|
|
export * from "./orders";
|
|
export * from "./brand";
|
|
export * from "./wholesale";
|
|
export * from "./water-log";
|
|
export * from "./communications";
|
|
export * from "./marketing";
|
|
export * from "./time-tracking";
|
|
export * from "./field-workers";
|
|
export * from "./shipping";
|
|
export * from "./support";
|
|
export * from "./files"; |