Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions migrations/0014_fix_properties.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
-- ChittyCommand Property Data Corrections
-- Migration: 0014_fix_properties
-- Date: 2026-03-24
-- Fixes wrong PINs, wrong addresses, and wrong properties from 0004/0007.
-- Authoritative source: project_entity_property_structure.md

BEGIN;

-- ── Fix PINs for existing properties ──────────────────────────

-- Addison: wrong PIN 14-21-307-032-1006 → correct 14-21-111-008-1006
UPDATE cc_properties SET tax_pin = '14-21-111-008-1006'
WHERE address = '541 W Addison St' AND unit = '#3S';

-- Surf 504: wrong PIN 14-28-200-011-1042 → correct 14-28-122-017-1091
-- Also fix address: 550 → 559 W Surf St per deed
UPDATE cc_properties
SET tax_pin = '14-28-122-017-1091',
address = '559 W Surf St',
unit = '#C504',
property_name = '559 W Surf St #C504',
hoa_payee = 'Commodore/Greenbrier Landmark Condo Association',
metadata = metadata || '{"pin": "14-28-122-017-1091", "condo_declaration": "26911238"}'::jsonb
WHERE address = '550 W Surf St' AND unit = '#504';

-- Backfill Addison metadata
UPDATE cc_properties
SET metadata = metadata || '{"pin": "14-21-111-008-1006", "condo_declaration": "25024798", "condo_association": "Addition Lake Shore West Condominium"}'::jsonb
WHERE address = '541 W Addison St' AND unit = '#3S';

-- ── Remove wrong properties from 0007 ────────────────────────

-- "211 E Surf St, Park Forest" was wrong — Surf 211 is actually 550 W Surf St #C211
DELETE FROM cc_properties WHERE tax_pin = '31-25-301-019-0000';

-- "Clarendon Hills" was wrong — should be 4343 N Clarendon Ave #1610
DELETE FROM cc_properties WHERE tax_pin = '09-12-307-023-0000';

-- ── Insert correct properties ─────────────────────────────────

-- Surf 211: 550 W Surf St #C211 (Commodore/Greenbriar Landmark)
INSERT INTO cc_properties (property_name, address, unit, tax_pin, property_type, hoa_payee, metadata)
VALUES (
'Surf 211',
'550 W Surf St',
'#C211',
'14-28-122-017-1180',
'condo',
'Commodore/Greenbriar Landmark Condo Association',
'{"purchase_price": 100000, "purchase_date": "2022-07-01", "pin": "14-28-122-017-1180", "condo_declaration": "26911238", "owner_entity": "ARIBIA LLC - CITY STUDIO"}'::jsonb
)
ON CONFLICT (tax_pin) DO NOTHING;
Comment on lines +42 to +52
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

HOA payee name spelling inconsistency.

Line 49 uses 'Commodore/Greenbriar Landmark Condo Association' (with "ia") but line 22 uses 'Commodore/Greenbrier Landmark Condo Association' (with "ie"). This inconsistency could cause data quality issues and confusion when querying or displaying HOA information.

Suggested fix: Align spelling (verify correct spelling first)
   'Surf 211',
   '550 W Surf St',
   '#C211',
   '14-28-122-017-1180',
   'condo',
-  'Commodore/Greenbriar Landmark Condo Association',
+  'Commodore/Greenbrier Landmark Condo Association',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
INSERT INTO cc_properties (property_name, address, unit, tax_pin, property_type, hoa_payee, metadata)
VALUES (
'Surf 211',
'550 W Surf St',
'#C211',
'14-28-122-017-1180',
'condo',
'Commodore/Greenbriar Landmark Condo Association',
'{"purchase_price": 100000, "purchase_date": "2022-07-01", "pin": "14-28-122-017-1180", "condo_declaration": "26911238", "owner_entity": "ARIBIA LLC - CITY STUDIO"}'::jsonb
)
ON CONFLICT (tax_pin) DO NOTHING;
INSERT INTO cc_properties (property_name, address, unit, tax_pin, property_type, hoa_payee, metadata)
VALUES (
'Surf 211',
'550 W Surf St',
'#C211',
'14-28-122-017-1180',
'condo',
'Commodore/Greenbrier Landmark Condo Association',
'{"purchase_price": 100000, "purchase_date": "2022-07-01", "pin": "14-28-122-017-1180", "condo_declaration": "26911238", "owner_entity": "ARIBIA LLC - CITY STUDIO"}'::jsonb
)
ON CONFLICT (tax_pin) DO NOTHING;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@migrations/0014_fix_properties.sql` around lines 42 - 52, The HOA payee
spelling is inconsistent between cc_properties inserts (the INSERT for
property_name 'Surf 211' sets hoa_payee to 'Commodore/Greenbriar Landmark Condo
Association' while another record uses 'Commodore/Greenbrier Landmark Condo
Association'); verify the authoritative spelling and update the hoa_payee value
in this INSERT statement (and any other cc_properties rows) so the hoa_payee
field is identical across records to avoid data-quality issues when
querying/displaying HOA information.


-- Clarendon: 4343 N Clarendon Ave #1610
INSERT INTO cc_properties (property_name, address, unit, tax_pin, property_type, metadata)
VALUES (
'Clarendon',
'4343 N Clarendon Ave',
'#1610',
'14-16-300-032-1238',
'condo',
'{"pin": "14-16-300-032-1238", "owner_entity": "ARIBIA LLC - APT ARLENE"}'::jsonb
)
ON CONFLICT (tax_pin) DO NOTHING;

-- Medellín: International property held by ARIBIA LLC
INSERT INTO cc_properties (property_name, address, unit, property_type, metadata)
VALUES (
'Medellín',
'Urbanización Plaza De Colores, Carrera 76, Medellín, Colombia',
'Apt 53 (215 Int. 1112)',
'international',
'{"country": "Colombia", "city": "Medellín", "apartment": "215 Int. 1112", "parking": "215 Int. 0226", "owner_entity": "ARIBIA LLC"}'::jsonb
);
Comment on lines +66 to +74
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Non-idempotent INSERT may create duplicates on re-run.

Unlike the other property inserts, this INSERT lacks an ON CONFLICT clause. Since tax_pin is NULL for this international property, and PostgreSQL's UNIQUE constraint allows multiple NULL values, re-running this migration will insert duplicate Medellín rows.

Consider one of these approaches:

Option 1: Add a guard with NOT EXISTS
 -- Medellín: International property held by ARIBIA LLC
-INSERT INTO cc_properties (property_name, address, unit, property_type, metadata)
-VALUES (
+INSERT INTO cc_properties (property_name, address, unit, property_type, metadata)
+SELECT
   'Medellín',
   'Urbanización Plaza De Colores, Carrera 76, Medellín, Colombia',
   'Apt 53 (215 Int. 1112)',
   'international',
   '{"country": "Colombia", "city": "Medellín", "apartment": "215 Int. 1112", "parking": "215 Int. 0226", "owner_entity": "ARIBIA LLC"}'::jsonb
-);
+WHERE NOT EXISTS (
+  SELECT 1 FROM cc_properties WHERE property_name = 'Medellín'
+);
Option 2: Add a unique constraint on property_name (if appropriate for the schema)
-- If property_name should be unique, add constraint first
ALTER TABLE cc_properties ADD CONSTRAINT uq_cc_properties_property_name UNIQUE (property_name);

-- Then use ON CONFLICT
INSERT INTO cc_properties (...)
VALUES (...)
ON CONFLICT (property_name) DO NOTHING;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
-- Medellín: International property held by ARIBIA LLC
INSERT INTO cc_properties (property_name, address, unit, property_type, metadata)
VALUES (
'Medellín',
'Urbanización Plaza De Colores, Carrera 76, Medellín, Colombia',
'Apt 53 (215 Int. 1112)',
'international',
'{"country": "Colombia", "city": "Medellín", "apartment": "215 Int. 1112", "parking": "215 Int. 0226", "owner_entity": "ARIBIA LLC"}'::jsonb
);
-- Medellín: International property held by ARIBIA LLC
INSERT INTO cc_properties (property_name, address, unit, property_type, metadata)
SELECT
'Medellín',
'Urbanización Plaza De Colores, Carrera 76, Medellín, Colombia',
'Apt 53 (215 Int. 1112)',
'international',
'{"country": "Colombia", "city": "Medellín", "apartment": "215 Int. 1112", "parking": "215 Int. 0226", "owner_entity": "ARIBIA LLC"}'::jsonb
WHERE NOT EXISTS (
SELECT 1 FROM cc_properties WHERE property_name = 'Medellín'
);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@migrations/0014_fix_properties.sql` around lines 66 - 74, The INSERT into
cc_properties for 'Medellín' is non-idempotent (tax_pin is NULL so unique
constraints won’t prevent duplicates); make it idempotent by either adding a NOT
EXISTS guard around the insert (check cc_properties for property_name =
'Medellín') or by adding a UNIQUE constraint on property_name and converting the
INSERT into an ON CONFLICT DO NOTHING using property_name as the conflict
target; update the migration to use one of these approaches so repeated runs do
not create duplicate Medellín rows.


-- ── Fix mortgage account metadata ─────────────────────────────

-- Update the Surf mortgage account to reflect correct address
UPDATE cc_accounts
SET metadata = '{"property": "559 W Surf St #C504"}'::jsonb
WHERE source = 'mr_cooper' AND account_name = '550 W Surf Mortgage';

-- ── Fix obligation metadata ───────────────────────────────────

UPDATE cc_obligations
SET metadata = metadata || '{"pin": "14-21-111-008-1006"}'::jsonb
WHERE category = 'mortgage' AND payee ILIKE '%Addison%';

UPDATE cc_obligations
SET metadata = '{"property": "559 W Surf St #C504", "pin": "14-28-122-017-1091"}'::jsonb
WHERE category = 'mortgage' AND payee ILIKE '%Surf%';

UPDATE cc_obligations
SET metadata = metadata || '{"pin": "14-21-111-008-1006"}'::jsonb
WHERE category = 'hoa' AND payee ILIKE '%Addison%';

UPDATE cc_obligations
SET metadata = metadata || '{"property": "559 W Surf St #C504", "pin": "14-28-122-017-1091"}'::jsonb
WHERE category = 'hoa' AND payee ILIKE '%Commodore%';

UPDATE cc_obligations
SET metadata = metadata || '{"pin": "14-21-111-008-1006"}'::jsonb
WHERE category = 'property_tax' AND payee ILIKE '%Addison%';

UPDATE cc_obligations
SET metadata = '{"property": "559 W Surf St #C504", "pin": "14-28-122-017-1091", "installments": "June + September"}'::jsonb
WHERE category = 'property_tax' AND payee ILIKE '%Surf%';

COMMIT;
Loading