Skip to content

Adopt a live database

llms.txtlists every page for an agent

For a team whose database already exists: read it into declarations and a baseline migration, then change it only through migrations.

Works

  • yodel init --from <env> reads the live database into src/ and plans it back to no change before it writes anything
  • A baseline migration recorded as applied, with none of its statements run
  • Access adopted with the tables when the environment manages it: policies and grants, and on ClickHouse users and roles
  • yodel init --baseline for another environment that holds the same schema

Differs

By database

  • A project owns ClickHouse databases (yodel create <dir> --clickhouse --database <name>).
  • A rebuild keeps the old table until yodel cleanup drops it, and lint flags mutations and rebuilds (ch-mutation, ch-rebuild).

By forge

  • The writer's secrets are secrets of a GitHub environment limited to main.
  • The plan comment and the drift issue use the job's own token.

First step

Terminal window
YODEL_ROLE=writer npx yodel init --from <env> --force

Adopting an existing database

Proof

Each claim runs what this room relies on against a real server, once plain (it passes) and once with the behaviour broken (the claim catches it). Claims status lists every claim.

ClaimWhat it saysPlain, broken
declarativethe declarative path: yodel plan shows the change against the live server and yodel apply makes it behind the plan-bound gate, for src/ declarations (on Postgres, functions, procedures and triggers, and access control: a role, a policy and grants, with a grant made by hand revoked; on ClickHouse, a dictionary, a function, and access control: a role, a user, a row policy and grants, with a grant made by hand revoked) and for an ORM's exported DDL; a pull request on that path gets lint over the planned changes and the plan comment with them, and a policy rule at the base commit that denies the plan refuses yodel apply before the gate; yodel drift reports a declared object changed out of band, naming the property, a column added to it by hand, and one dropped; on the versioned path it compares with the newest applied migration's recorded schema, so a pending migration is not drift; yodel init --from adopts a live database without touching it, and yodel plan then shows no change; on Postgres its policies, row-level security and grants too, on ClickHouse its dictionaries, functions, roles, users, row policies and grants; it refuses a database holding an object of a kind it cannot declare, naming it; yodel init --baseline records the baseline, behind the gate, in a second environment that holds the same schema, and refuses one that differsClickHouse: pass, caughtPostgres: pass, caught

Then read

Tasks
Starting a projectSetting up each forge
Background
The two workflowsAccess control
Reference
The commandsInstalling and configuring

SQL Yodeler