type
concept
created
Mon Apr 06 2026 02:00:00 GMT+0200 (Central European Summer Time)
updated
Mon Apr 06 2026 02:00:00 GMT+0200 (Central European Summer Time)
sources
raw/notes/systemPatterns, raw/notes/techContext
tags
pattern django database architecture

Companion Table Pattern

abstract
A Django pattern for extending Yardi-synced `managed=False` tables without altering them. Creates a new `managed=True` table with a OneToOne FK pointing to the Yardi model.

How It Works

  1. Yardi tables are read-only (managed=False in Django Meta) — Django NEVER creates, alters, or drops them
  2. To add custom fields (e.g., AI scores, lifecycle states), create a new table with managed=True
  3. New table has a OneToOneField FK pointing to the Yardi model
  4. Migrations for new tables require superuser: sudo -u postgres ... migrate
  5. The propintel user can only do DML (SELECT/INSERT/UPDATE/DELETE), not DDL

Example

tenant_lease_lifecycle is a companion table that extends Yardi's TenantLease with lifecycle state data.

Why This Matters

Sources

Related