feat(bell): add immutable event store [T-015]
This commit is contained in:
@@ -71,11 +71,33 @@ BEGIN
|
||||
OR NOT has_table_privilege('sense_app', 'sense.device_operation_outbox', 'DELETE') THEN
|
||||
RAISE EXCEPTION 'sense_app lacks access to its local audit Outbox';
|
||||
END IF;
|
||||
IF (SELECT max(version) FROM bell.schema_migrations) <> 2
|
||||
IF (SELECT max(version) FROM bell.schema_migrations) <> 3
|
||||
OR (SELECT max(version) FROM sense.schema_migrations) <> 5 THEN
|
||||
RAISE EXCEPTION 'schema migration version drift';
|
||||
END IF;
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM pg_roles
|
||||
WHERE rolname = 'bell_runtime' AND NOT rolcanlogin AND NOT rolsuper
|
||||
AND NOT rolcreatedb AND NOT rolcreaterole AND NOT rolreplication
|
||||
) THEN
|
||||
RAISE EXCEPTION 'bell_runtime role is missing or unsafe';
|
||||
END IF;
|
||||
IF NOT has_table_privilege('yovision_t015_bell', 'bell.events', 'SELECT,INSERT')
|
||||
OR NOT has_table_privilege('yovision_t015_bell', 'bell.event_outcomes', 'SELECT,INSERT')
|
||||
OR has_table_privilege('yovision_t015_bell', 'bell.events', 'UPDATE')
|
||||
OR has_table_privilege('yovision_t015_bell', 'bell.events', 'DELETE')
|
||||
OR has_table_privilege('yovision_t015_bell', 'bell.events', 'TRUNCATE')
|
||||
OR has_table_privilege('yovision_t015_bell', 'bell.event_outcomes', 'UPDATE')
|
||||
OR has_table_privilege('yovision_t015_bell', 'bell.event_outcomes', 'DELETE')
|
||||
OR has_table_privilege('yovision_t015_bell', 'bell.event_outcomes', 'TRUNCATE') THEN
|
||||
RAISE EXCEPTION 'Bell runtime violates immutable event privileges';
|
||||
END IF;
|
||||
IF has_table_privilege('public', 'bell.events', 'SELECT,INSERT,UPDATE,DELETE,TRUNCATE')
|
||||
OR has_table_privilege('public', 'bell.event_outcomes', 'SELECT,INSERT,UPDATE,DELETE,TRUNCATE') THEN
|
||||
RAISE EXCEPTION 'Bell event facts leaked to PUBLIC';
|
||||
END IF;
|
||||
|
||||
INSERT INTO bell.sites(tenant_id, id, name)
|
||||
VALUES ('assertion-tenant', 'assertion-site', 'Assertion Site')
|
||||
RETURNING max_video_channels, version INTO default_quota, initial_version;
|
||||
|
||||
Reference in New Issue
Block a user