-- Settings that belong to the instance rather than to anything in it. -- -- One row, forever. Steid is single tenant, so "which organisation is the home page" -- is a fact about the installation and not about any organisation in it — and a -- `home_org_id` column on `orgs` would be null on every row but one, turning a read -- into a scan and inviting two rows that claim it. -- -- The single row is the `check (id = 1)`: a second insert fails on the primary key, -- and an insert with any other id fails the check. It is seeded here so every caller -- can read rather than upsert. -- -- `home_org_id` is nullable and stays nullable. Null means nobody has chosen, and the -- root falls back to the sole owner's handle — which is exactly how every instance -- behaved before this table existed, so an upgrade changes nothing until someone picks. -- `on delete set null` rather than cascade: deleting the home organisation must not -- delete the instance's settings, it must leave the instance without a home. create table instance_settings ( id integer primary key check (id = 1), home_org_id text references orgs (id) on delete set null ); insert into instance_settings (id, home_org_id) values (1, null);