010_tenants_fields.up.sql 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. -- 010_tenants_fields.up.sql
  2. -- M13b W1: Tenant (company) operational fields.
  3. --
  4. -- Adds the per-tenant knobs the admin UI needs to manage:
  5. --
  6. -- rate_limit_per_sec INTEGER
  7. -- Cap on ingest events/sec for this tenant. Default 10000 (the
  8. -- value used in v1 everywhere). Enforced by the ingestion
  9. -- pipeline per-tenant (the per-tenant key is a known pattern;
  10. -- the existing M1/M4 ingest uses company_id from the event).
  11. --
  12. -- fcm_shared BOOLEAN
  13. -- When true, this tenant's FCM traffic uses the shared HTTP/2
  14. -- pool (the default in M8+). When false, future code can pin
  15. -- this tenant to a dedicated sender ID. Read by deliverd-fcm
  16. -- when picking a sender. W1 only persists the flag; the
  17. -- read-side is wired in M13b W3 (Telegram) where the same
  18. -- multi-tenant pool isolation story lives.
  19. --
  20. -- The migration is safe to apply to a populated DB — both columns
  21. -- have defaults that match what M13a W1-W5 code already expected
  22. -- (no behavior change for existing rows).
  23. SET search_path TO auth, public;
  24. ALTER TABLE auth.tenants
  25. ADD COLUMN IF NOT EXISTS rate_limit_per_sec INTEGER NOT NULL DEFAULT 10000
  26. CHECK (rate_limit_per_sec > 0 AND rate_limit_per_sec <= 1000000);
  27. ALTER TABLE auth.tenants
  28. ADD COLUMN IF NOT EXISTS fcm_shared BOOLEAN NOT NULL DEFAULT TRUE;