Files
evig/scripts/db/migrations/104_profile_column_cleanup.sql
GandClaude Opus 4.8 a69a3c22d7 refactor(profiles): nullable repairer contact + drop dead seller columns (debt #5 phase 4) (#175)
Phase 4, re-scoped after a per-field write-site audit found NO mirror duplication
— the role-profile contact/bio/avatar fields hold legitimately-distinct business
data (entered via separate forms), so the original "consolidate into user_profiles"
idea was dropped as contraindicated. Only the dead/placeholder columns are cleaned:

- Migration 104: repairer_profiles.phone/address NOT NULL → nullable; normalize
  the '' placeholders (self-service community techs, who never enter business
  contact) to NULL. Drop the dead seller_profiles.phone/address/postal_code
  columns (never written by any code path; the seller form only collects city).
- Schema: drop .notNull() on repairer phone/address; remove the seller columns.
- technician-service.upsertTechnicianProfile no longer writes the '' placeholders.

No readers of the dropped seller columns. typecheck + lint clean; full suite zero
new failures vs baseline. Docs: ARCHITECTURE_DEBT #5 Phase 4 (re-scoped, done).

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 01:33:33 +02:00

23 lines
1.3 KiB
SQL

-- Migration 104: profile column cleanup (debt #5 phase 4)
--
-- Phase 4 of the profile audit found that the role-profile "contact" fields are
-- NOT mirror-duplicates of user_profiles — they hold legitimately-distinct
-- business data (seller storefront, repairer service location/contact via the
-- application flow, team HR phone). The only real cleanup is the dead/placeholder
-- columns; the broad "consolidate contact into user_profiles" idea was dropped.
--
-- 1. repairer_profiles.phone/address were NOT NULL, which forced self-service
-- community technicians (who never enter business contact) to store ''
-- placeholders. Make them nullable and normalize the '' placeholders to NULL.
ALTER TABLE repairer_profiles ALTER COLUMN phone DROP NOT NULL;
ALTER TABLE repairer_profiles ALTER COLUMN address DROP NOT NULL;
UPDATE repairer_profiles SET phone = NULL WHERE phone = '';
UPDATE repairer_profiles SET address = NULL WHERE address = '';
-- 2. seller_profiles.phone/address/postal_code are never written by any code path
-- (always NULL) — drop the dead columns. The seller form only collects
-- city/canton; storefront contact lives elsewhere.
ALTER TABLE seller_profiles DROP COLUMN IF EXISTS phone;
ALTER TABLE seller_profiles DROP COLUMN IF EXISTS address;
ALTER TABLE seller_profiles DROP COLUMN IF EXISTS postal_code;