← back to Ventura Corridor

db/migrations/016_btrc_match.sql

15 lines

-- has_btrc_match: TRUE if this non-la_btrc business has a corresponding LA City
-- business-tax registrant at the same street_number on Ventura Blvd. FALSE if
-- the matching la_btrc rows at this address are empty → "POSSIBLY NO BUSINESS LICENSE".
-- Set by src/enrich/btrc_match.ts after every ingest.

ALTER TABLE businesses
  ADD COLUMN IF NOT EXISTS has_btrc_match   BOOLEAN,
  ADD COLUMN IF NOT EXISTS btrc_match_score REAL,
  ADD COLUMN IF NOT EXISTS btrc_matched_id  BIGINT REFERENCES businesses(id) ON DELETE SET NULL,
  ADD COLUMN IF NOT EXISTS btrc_match_at    TIMESTAMPTZ;

CREATE INDEX IF NOT EXISTS idx_businesses_btrc_match
  ON businesses (has_btrc_match)
  WHERE on_corridor AND source != 'la_btrc';