33 lines
1.1 KiB
SQL
33 lines
1.1 KiB
SQL
-- YoVision Bell -> Sense site quota projection contract v1.
|
|||
|
|
--
|
||
|
|
-- This file freezes the PostgreSQL object signature and privileges. It is not a
|
||
|
|
-- migration: Bell must create the source table and install this view in a later
|
||
|
|
-- implementation task. The source table must enforce a default of 16 and a
|
||
|
|
-- CHECK constraint that keeps max_video_channels between 1 and 128 inclusive.
|
||
|
|
-- source_version must increase monotonically for each logical site whenever a
|
||
|
|
-- projected value changes.
|
||
|
|
|
||
|
|
CREATE VIEW bell.site_quota_v1 (
|
||
|
|
tenant_id,
|
||
|
|
site_id,
|
||
|
|
max_video_channels,
|
||
|
|
source_version,
|
||
|
|
source_updated_at
|
||
|
|
) AS
|
||
|
|
SELECT
|
||
|
|
site.tenant_id,
|
||
|
|
site.id,
|
||
|
|
site.max_video_channels,
|
||
|
|
site.version,
|
||
|
|
site.updated_at
|
||
|
|
FROM bell.sites AS site
|
||
|
|
WHERE site.deleted_at IS NULL;
|
||
|
|
|
||
|
|
COMMENT ON VIEW bell.site_quota_v1 IS
|
||
|
|
'v1 read-only site video quota projection owned by Bell and consumed by Sense';
|
||
|
|
|
||
|
|
ALTER VIEW bell.site_quota_v1 OWNER TO bell_app;
|
||
|
|
REVOKE ALL PRIVILEGES ON TABLE bell.site_quota_v1 FROM PUBLIC;
|
||
|
|
GRANT USAGE ON SCHEMA bell TO sense_app;
|
||
|
|
GRANT SELECT ON TABLE bell.site_quota_v1 TO sense_app;
|