Data management
Schema migrations change structure. Data sets change rows — the one-off UPDATE, INSERT and DELETE that support and operations apply against live data because the application does not expose them.
The path is the same idea as a migration, pointed at DML: a file is planned, reviewed, applied under row-count assertions, and written to an audit ledger. DBLift does not keep a copy of the rows a correction changes, and it does not reverse the correction. Plans and command output never contain row data, so nothing sensitive lands in git, CI logs, or review tooling.
Not a backup or disaster-recovery mechanism
DBLift does not keep the rows a correction changes and cannot reverse that correction. The ledger and the audit log live in the same database as your data, so they share its blast radius. They cannot recover from DROP TABLE, disk loss, or any change DBLift did not make. Keep your normal backups and point-in-time recovery. To change the rows again, write a new correction and review it the same way.
Versus schema migrations
Schema (V / U) | Data (D) | |
|---|---|---|
| What it changes | Tables, columns, indexes, views | Rows |
| Identity | Version | Timestamp id (D20260618143022) |
| Review artifact | The SQL file, plus plan/preflight on Enterprise | A static data plan JSON with no row data |
| Undo | A matching U file you write, run with undo | Not reversed by DBLift. Write a new correction. |
| History | Schema history table | Per-set audit ledger |
A data correction is not a substitute for a migration. If the change is structural, use a V file and, when you need a rollback, a hand-written U file. If it is a row fix that should be reviewed, asserted, and auditable, use a data set.
What each licence unlocks
| Capability | Tier |
|---|---|
data new, data plan, data apply, data status | Pro |
Governance policy on a set (policy:) and impact reporting (triggers, foreign-key children) | Pro |
Enterprise does not add a data command. snapshot, plan, preflight, and managed secret providers stay Enterprise. A Pro apply writes the ledger. Running a Pro data command without a Pro licence fails with a clear message, never a traceback.
See dblift data for the CLI.
Create a file (Pro)
dblift data new writes a correction file. It does not open a database, and it never overwrites a file that is already there.
dblift data new "activate user" --dataset corrections
The file lands in the data set's first configured directory, named D<YYYYMMDDHHMMSS>__<slug>.sql, with the -- dblift:formatted header, a default expect=>=1 onfail=halt directive, and a placeholder UPDATE. --table fills the table name. JSON output is {"success": true, "path": "...", "id": "D<timestamp>"}. An unconfigured --dataset is an error, not an empty plan.
The loop
dblift data plan --dataset billing --output plan.json# review plan.json in the PR — no row data in itdblift data apply plan.jsondblift data status --dataset billing
plan is static. It reports, per correction, the enabled triggers on the affected tables, the foreign-key children the statement reaches, and the policy violations that can be checked without running the DML. Plan JSON does not carry an undo verdict, undo reasons, or a no-undo flag. triggers, children, and introspection_errors are unchanged. An existing plan file still applies. apply re-runs the selection, checks each expect, and appends a hash-chained ledger row. It does not capture before/after row images. status lists each correction and verifies the chain.
An unconfigured --dataset is refused by plan, apply, and status. The error names the dataset and the ones that are configured. Nothing is written, and apply does not fall back to a made-up history table.
Triggers and cascades
policy.triggers and policy.cascades each take allow, warn, or reject, and default to warn. Under warn the correction still applies, and the finding is stored with the history row. Under cascades: reject, a direct foreign-key cascade is rejected on every tier.
policy.triggers and policy.cascades are applied by data apply (and --dry-run). data plan reports the impact and does not reject on those two keys. Other policy violations are recorded on the correction and set the plan's success to false. max_affected_rows stays an apply-time check, because the row count is not known until the statement runs.
To keep refusing side effects after you delete policy.undo, set triggers: reject and cascades: reject.
Row images from an earlier release
DBLift does not offer data undo and does not keep before/after row images. It does not create dblift_data_change_set and does not drop a table left by an earlier release.
If that table still holds row images:
- Nothing in the current release can read those images to reverse a correction. If you still have a build that includes
data undo, reverse any correction you may still need before you move off it. data statusprints a notice on stderr while the table holds rows. The notice is not part of--format jsonoutput.- When you are sure you need nothing from the table, drop it yourself:
DROP TABLE dblift_data_change_set;The table stays hidden from schema diff and export. A history row with status undone is listed by data status and re-applies like a pending correction.
Withdrawn settings
policy.undo: requiredis a configuration error. Delete it.policy.undo: optional,policy.restore_key_columns, a data set'skeys:map, and the-- dblift: no-undodirective are ignored, with a warning that names the setting. Do not use them in new files.
Author a correction
Files live under one of your data_sets.<name>.directories. The D token is the correction id, and corrections run in ascending timestamp order.
D20260618143022__promote_account_tier.sql
-- dblift:formatted
-- dblift: expect=1
UPDATE "app"."accounts" SET tier = 'gold' WHERE id = 7;
-- dblift: expect=>=1 onfail=warn
UPDATE "app"."audit_log" SET note = 'tier change' WHERE account_id = 7;-- dblift:formatted anywhere in the file turns on directive parsing. Without it the file still runs, but every expect is ignored and statements use the defaults (expect >=1).
| Directive | Values | Meaning |
|---|---|---|
-- dblift:formatted | header | Required. Activates directive parsing for the file. |
-- dblift: expect= | 1 · >=1 · <=5 · any | Row-count assertion for the next statement. |
onfail= | halt · skip · warn | What to do when the assertion is not met. Defaults to halt. |
See data_sets for the set and the policy that data plan checks before apply.
Related
- data — CLI reference
- data_sets — configuration
- Undo model — reversing schema migrations with a hand-written
Uscript, not rows - Editions & tiers