Skip to main content

Module schema

Module schema 

Source
Expand description

The tables a workflow engine keeps, as SQL.

The schema generator writes the same statements into a module’s migration; this function is the framework’s own copy, for tests and for a service that creates the tables itself.

Constants§

STATUSES
The statuses an instance moves through.

Functions§

drop_and_create_policies
The statements that replace both policies, for a test that creates the tables more than once.
migration_sql
The statements that create bb_workflow_instances and bb_workflow_steps in schema, fence them by company_id with row-level security. The outbox and inbox tables the engine stages events in and dedups resumes with are backbone_core::write_hooks::migrate_outbox‘s (a module that stages events runs it already). Run it as the table owner. Not idempotent for the policies’ sake: run it once, as a migration does; drop_and_create_policies is for a test that re-creates them.
org_fence_sql
The statements that fence both tables by org unit instead of by company (ADR-0029), for a module whose tables are org-scoped: the <table>_org_unit_isolation policy (the entitlement union, plus the read-only sweep clause) replaces the company policy, and a trigger fills a NULL org_unit_id from the acting unit. A row with no org unit is then refused loudly. The generated migration adds the kind guard over organization.org_units to this.
valid_schema
Whether schema is a plain lowercase identifier, safe to put in a statement.