Skip to content

Policies Overview

dbward uses four policy types to control what happens when a database operation is requested. Each policy type answers a different question.

PolicyQuestion it answersConfigured in
WorkflowWho must approve this operation?[[workflows]]
Execution PolicyWhat constraints apply during execution?[[execution_policies]]
Result PolicyHow long are results kept and who can access them?[[result_policies]]
Notification PolicyWhich webhooks fire for which events?[[notification_policies]]

All policies are scoped by database × environment × operation:

[[workflows]]
database = "app" # or "*" for all databases
environment = "production" # or "*" for all environments
operations = ["execute_dml"] # optional filter

When multiple policies could match a request, dbward uses this priority:

  1. Exact database + exact environment
  2. Wildcard database + exact environment
  3. Exact database + wildcard environment
  4. Wildcard database + wildcard environment

Within the same specificity, policies with operations filter take priority over those without.

If no workflow matches a request, it is rejected.

This means every (database, environment) pair that should accept operations must have at least one matching workflow — even if that workflow auto-approves everything.

# Allow all operations on development (no approval needed)
[[workflows]]
database = "*"
environment = "development"
# steps = [] means auto-approve

The five operation types that policies can filter on:

OperationTriggered by
execute_selectSELECT, SHOW, EXPLAIN queries
execute_dmlINSERT, UPDATE, DELETE, DDL
migrate_updbward migrate up
migrate_downdbward migrate down
migrate_statusdbward migrate status

When a request arrives:

1. SQL classification → Determine operation type (execute_select / execute_dml)
2. Workflow matching → Find approval requirements
3. Auto-approve check → Skip approval if risk is low enough
4. Execution policy → Apply timeout, row limit, retry constraints
5. Result policy → Determine retention and access rules
6. Notification policy → Fire webhooks for relevant events