pub async fn upgrade_data_lake_schema_v7(
tr: &mut Transaction<'_, Postgres>,
) -> Result<(), Error>Expand description
Upgrades the data lake schema to version 7.
Adds audience_grants: the DB-backed audience grant store, a 1:1
stand-in for the long-term model’s group_read_grants/group_mint_grants tables. One table
with an axis column ('read'/'mint') rather than two, mirroring today’s single env-var
grant map ({prefix}_AUDIENCE_GRANTS); (audience, axis, selector) is the row’s own natural
key, so there is no surrogate grant_id the way ingestion_api_keys.key_id has one (a grant
carries no secret to keep unlinkable from its own identity). No revoked_at/revoked_by
either – grants are hard-DELETEd, since a removed grant has no ongoing artifact whose
provenance a caller might later need. The shape CHECK constraints declared here (audience
name and axis) were dropped in v14: AudienceGrants::from_rows (rust/auth/src/policy.rs)
validates in Rust and skips a malformed row, so a row inserted by any means other than the
admin API (a manual psql fix, a future migration) is inert rather than a hazard.