Skip to content

Projects and environments

Each project is described in projects/<project>/project.yaml inside the control repository. Create it with project init, then edit and commit it.

sql2devops project init finance -d postgres --envs DEV,HML,PROD
sql2devops project check finance
project: finance
environments:                       # in promotion order
  - name: DEV                       # approval: none (default)
    targets:
      finance-db: { driver: postgres, dsn_env: FINANCE_DEV_DSN }

  - name: HML                       # requires DEV (the previous one)
    approval: automatic             # a pipeline approves, with evidence
    targets:
      finance-db: { driver: postgres, dsn_env: FINANCE_HML_DSN }

  - name: PROD
    approval: human
    approvers: [github:alice, github:bob]
    min_approvals: 1
    allow_self_approval: false      # default: the submitter cannot approve
    rerun_after_failure: false      # default: true
    variables:
      api_password: FINANCE_PROD_API_PASSWORD
    targets:
      finance-db: { driver: postgres, dsn_env: FINANCE_PROD_DSN }

emergency:                          # optional
  allowed: [github:oncall]
  require_ticket: true
  reviewers: [github:boss]

Environment fields

Field Default Meaning
name Environment name (DEV, HML, PROD…)
approval none none, automatic or human
approvers Who may approve (github:<login> or an OS user)
min_approvals 1 Approvals needed
allow_self_approval false Whether the submitter may approve their own package
rerun_after_failure true Whether a failed version may run again
variables For each variable, the environment variable that holds its value
targets Databases: driver, dsn_env, and for SQLite functions

Promoting

sql2devops promote CHG-1001 --project finance          # next environment
sql2devops deploy  CHG-1001 --project finance --env HML # a specific one
sql2devops approve CHG-1001 --project finance --env HML --automatic --evidence "$TEST_RUN_URL"
sql2devops approve CHG-1001 --project finance --env PROD
sql2devops status  --project finance

--force overrides the "already applied" and divergence checks, never the approval rules.