Files

31 lines
955 B
SQL
Raw Permalink Normal View History

-- Contract-only reference for the Bell -> Sense Area admission projection.
-- The executable migration is deploy/postgres/005_area_policy.sql.
CREATE OR REPLACE VIEW bell.area_policy_v1 (
tenant_id,
site_id,
area_id,
capture_policy,
source_version,
source_updated_at
) AS
SELECT
area.tenant_id,
area.site_id,
area.id,
area.capture_policy,
area.version,
area.updated_at
FROM bell.areas AS area
JOIN bell.sites AS site
ON site.tenant_id = area.tenant_id AND site.id = area.site_id
WHERE area.deleted_at IS NULL AND site.deleted_at IS NULL;
COMMENT ON VIEW bell.area_policy_v1 IS
'v1 read-only Area capture-policy projection owned by Bell and consumed by Sense';
ALTER VIEW bell.area_policy_v1 OWNER TO bell_app;
REVOKE ALL PRIVILEGES ON TABLE bell.area_policy_v1 FROM PUBLIC;
REVOKE ALL PRIVILEGES ON TABLE bell.area_policy_v1 FROM sense_app;
GRANT SELECT ON TABLE bell.area_policy_v1 TO sense_app;