feat(berths): full NocoDB field parity, numeric types, sales edit access
Aligns the berths schema with the 117 production rows in NocoDB and exposes
every field for editing via the BerthForm sheet.
Schema (migration 0020):
- power_capacity / voltage / nominal_boat_size / nominal_boat_size_m: text -> numeric
(NocoDB stores plain numbers; text was wrong shape and broke filter/sort)
- ADD status_override_mode text (1/117 legacy rows have a value; carried
forward for parity but not yet wired into the UI)
- USING NULLIF(TRIM(...), '')::numeric so legacy whitespace and empty
strings convert cleanly
Validator + service:
- updateBerthSchema / createBerthSchema use z.coerce.number() for the
four numeric fields
- berths.service stringifies numeric values for Drizzle's numeric type
Form (src/components/berths/berth-form.tsx):
- adds: nominal boat size (ft/m), water depth (ft/m) + "is minimum" flag,
side pontoon, cleat type/capacity, bollard type/capacity, bow facing
- converts to typed selects (with NocoDB option lists in src/lib/constants):
area, side pontoon, mooring type, cleat type/capacity, bollard type/capacity,
access
- power capacity / voltage become numeric inputs (with kW / V hints)
Permissions (seed.ts + dev DB):
- sales_manager and sales_agent: berths.edit false -> true
("sales will sometimes have to update these and I cannot be the only one")
- super_admin / director already had it; viewer stays read-only
- dev DB updated in-place via UPDATE roles ... jsonb_set
Verification:
- pnpm exec vitest run: 858/858 passing
- pnpm exec tsc --noEmit: same 36 errors as baseline (all pre-existing
on feat/mobile-foundation, none introduced)
- lint clean
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
15
src/lib/db/migrations/0020_medical_betty_brant.sql
Normal file
15
src/lib/db/migrations/0020_medical_betty_brant.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
-- Convert text columns to numeric. NULLs survive; empty strings become NULL;
|
||||
-- whitespace is trimmed before casting so legacy data with stray spaces converts cleanly.
|
||||
ALTER TABLE "berths"
|
||||
ALTER COLUMN "nominal_boat_size" SET DATA TYPE numeric
|
||||
USING NULLIF(TRIM("nominal_boat_size"), '')::numeric;--> statement-breakpoint
|
||||
ALTER TABLE "berths"
|
||||
ALTER COLUMN "nominal_boat_size_m" SET DATA TYPE numeric
|
||||
USING NULLIF(TRIM("nominal_boat_size_m"), '')::numeric;--> statement-breakpoint
|
||||
ALTER TABLE "berths"
|
||||
ALTER COLUMN "power_capacity" SET DATA TYPE numeric
|
||||
USING NULLIF(TRIM("power_capacity"), '')::numeric;--> statement-breakpoint
|
||||
ALTER TABLE "berths"
|
||||
ALTER COLUMN "voltage" SET DATA TYPE numeric
|
||||
USING NULLIF(TRIM("voltage"), '')::numeric;--> statement-breakpoint
|
||||
ALTER TABLE "berths" ADD COLUMN "status_override_mode" text;
|
||||
Reference in New Issue
Block a user