Skip to content

CICD-402 · Preview database provisioning ​

Encyclopedia · Preview environments and developer experience · All snippets

Previous · CICD-401 · Next · CICD-403

1. Where it fits ​

  • Placement CI run step or authorized lab terminal.
  • Prerequisites trusted preview controller, disposable environment and scoped identities for external resources.
  • Platforms kubernetes, local-lab.
  • Parameters ADMIN_DSN, PR_NUMBER.

2. Copy the snippet ​

bash
[[ "${PR_NUMBER:?}" =~ ^[0-9]+$ ]]
createdb --maintenance-db="${ADMIN_DSN:?}" --template=template0 "preview_$PR_NUMBER"

3. How it works ​

The validated PR ID selects a database name. The creation command starts from template0, and owner and app-role isolation remain separate checks.

4. Verify the result ​

Provision through a guarded administrative controller and assign an isolated app role. Handle existing database as idempotent state after verifying its owner.

Validation syntax-validated (Bash parse). Status definitions.