Files
craftvia/prisma/migrations/20260915120000_planung/migration.sql
T
msolarczekandClaude Opus 5 604f2bfdc5 L13 Planung: Datenmodell (Kolonnenkapazität, Dauer, Geocoding-Cache) und Planungsregeln
Migration 20260915120000_planung (nur Spalten): Team.dailyCapacityMinutes/workingDays, OrderType.defaultDurationMinutes (+ Backfill Standardarten), WorkOrder.plannedDurationMinutes, Site.geocodedAt/geocodeStatus/geocodeQuery. Client-sichere Regeln: Haversine, Tage/Werktage, Dauer, Kolonnenkapazität, Konflikte inkl. Hinweis crew_incomplete, Vereinigung von Arbeitssegmenten, Fahrzeitschätzung.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 10:13:18 +02:00

33 lines
1.3 KiB
SQL

-- L13 Planung: capacity planning + geocoding cache. Columns only (no new table → RLS unchanged,
-- no TENANT_MODELS change). No personal references (no DSGVO pii-fields change).
-- AlterTable
ALTER TABLE "order_types" ADD COLUMN "default_duration_minutes" INTEGER;
-- AlterTable
ALTER TABLE "sites" ADD COLUMN "geocode_query" TEXT,
ADD COLUMN "geocode_status" TEXT,
ADD COLUMN "geocoded_at" TIMESTAMP(3);
-- AlterTable
-- Team = crew (Kolonne): capacity is the crew's working day in minutes, not person-hours.
ALTER TABLE "teams" ADD COLUMN "daily_capacity_minutes" INTEGER NOT NULL DEFAULT 480,
ADD COLUMN "working_days" INTEGER NOT NULL DEFAULT 31;
-- AlterTable
ALTER TABLE "work_orders" ADD COLUMN "planned_duration_minutes" INTEGER;
-- Backfill: default durations of the standard order types (spec §10.2) for existing tenants.
UPDATE "order_types" SET "default_duration_minutes" = CASE "key"
WHEN 'montage' THEN 480
WHEN 'reparatur' THEN 180
WHEN 'wartung' THEN 120
WHEN 'stoerung' THEN 120
WHEN 'notdienst' THEN 120
WHEN 'besichtigung' THEN 60
WHEN 'abnahme' THEN 60
WHEN 'nacharbeit' THEN 120
END
WHERE "default_duration_minutes" IS NULL
AND "key" IN ('montage', 'reparatur', 'wartung', 'stoerung', 'notdienst', 'besichtigung', 'abnahme', 'nacharbeit');