mirror of
https://github.com/renee-png/acmcc.git
synced 2026-06-21 01:40:01 +00:00
183fe0a93c
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
11 lines
614 B
SQL
11 lines
614 B
SQL
|
|
-- Add a unique constraint on owners for Buildium sync upserts
|
|
-- Using association_id + first_name + last_name + property_address to handle multiple owners at same address
|
|
CREATE UNIQUE INDEX IF NOT EXISTS owners_buildium_sync_key
|
|
ON public.owners (association_id, first_name, last_name, property_address)
|
|
WHERE property_address IS NOT NULL;
|
|
|
|
-- Add buildium_owner_id column for future direct ID mapping
|
|
ALTER TABLE public.owners ADD COLUMN IF NOT EXISTS buildium_owner_id text;
|
|
CREATE UNIQUE INDEX IF NOT EXISTS owners_buildium_id_key ON public.owners (buildium_owner_id) WHERE buildium_owner_id IS NOT NULL;
|