66 lines
4.5 KiB
PL/PgSQL
66 lines
4.5 KiB
PL/PgSQL
-- =============================================================================
|
|
-- P0 ARCHITECTURE CLEANUP: Ghost Column Removal Script
|
|
-- Generated: 2026-07-01
|
|
--
|
|
-- ⚠️ WARNING: Run this script ONLY after verifying that ALL code references
|
|
-- to these ghost columns have been removed from the codebase.
|
|
--
|
|
-- These columns were previously on fleet.organizations but have been
|
|
-- replaced by the unified address system (system.addresses FK via
|
|
-- address_id, billing_address_id, notification_address_id).
|
|
--
|
|
-- The Organization model now uses Python properties that delegate to
|
|
-- the `address` relationship (Address → GeoPostalCode).
|
|
--
|
|
-- Audit reference: docs/p0_address_manager_usage_audit_2026-07-01.md
|
|
-- =============================================================================
|
|
|
|
BEGIN;
|
|
|
|
-- ═════════════════════════════════════════════════════════════════════════════
|
|
-- fleet.organizations — Primary Address Ghost Columns
|
|
-- ═════════════════════════════════════════════════════════════════════════════
|
|
|
|
ALTER TABLE fleet.organizations DROP COLUMN IF EXISTS address_city;
|
|
ALTER TABLE fleet.organizations DROP COLUMN IF EXISTS address_zip;
|
|
ALTER TABLE fleet.organizations DROP COLUMN IF EXISTS address_street_name;
|
|
ALTER TABLE fleet.organizations DROP COLUMN IF EXISTS address_street_type;
|
|
ALTER TABLE fleet.organizations DROP COLUMN IF EXISTS address_house_number;
|
|
|
|
-- ═════════════════════════════════════════════════════════════════════════════
|
|
-- fleet.organizations — Billing Address Ghost Columns
|
|
-- ═════════════════════════════════════════════════════════════════════════════
|
|
|
|
ALTER TABLE fleet.organizations DROP COLUMN IF EXISTS billing_zip;
|
|
ALTER TABLE fleet.organizations DROP COLUMN IF EXISTS billing_city;
|
|
ALTER TABLE fleet.organizations DROP COLUMN IF EXISTS billing_street_name;
|
|
ALTER TABLE fleet.organizations DROP COLUMN IF EXISTS billing_street_type;
|
|
ALTER TABLE fleet.organizations DROP COLUMN IF EXISTS billing_house_number;
|
|
|
|
-- ═════════════════════════════════════════════════════════════════════════════
|
|
-- fleet.organizations — Notification Address Ghost Columns
|
|
-- ═════════════════════════════════════════════════════════════════════════════
|
|
|
|
ALTER TABLE fleet.organizations DROP COLUMN IF EXISTS notification_zip;
|
|
ALTER TABLE fleet.organizations DROP COLUMN IF EXISTS notification_city;
|
|
ALTER TABLE fleet.organizations DROP COLUMN IF EXISTS notification_street_name;
|
|
ALTER TABLE fleet.organizations DROP COLUMN IF EXISTS notification_street_type;
|
|
ALTER TABLE fleet.organizations DROP COLUMN IF EXISTS notification_house_number;
|
|
|
|
-- ═════════════════════════════════════════════════════════════════════════════
|
|
-- Verification Queries (run after migration to confirm cleanup)
|
|
-- ═════════════════════════════════════════════════════════════════════════════
|
|
|
|
-- Should return 0 rows (all ghost columns removed):
|
|
-- SELECT column_name
|
|
-- FROM information_schema.columns
|
|
-- WHERE table_schema = 'fleet'
|
|
-- AND table_name = 'organizations'
|
|
-- AND column_name IN (
|
|
-- 'address_city', 'address_zip', 'address_street_name', 'address_street_type', 'address_house_number',
|
|
-- 'billing_zip', 'billing_city', 'billing_street_name', 'billing_street_type', 'billing_house_number',
|
|
-- 'notification_zip', 'notification_city', 'notification_street_name', 'notification_street_type', 'notification_house_number'
|
|
-- );
|
|
|
|
COMMIT;
|