Trigger icon
Get icon
Query icon
OutputValues icon
If icon
Set icon
SlackIncomingWebhook icon
Pause icon
Fail icon

Dolt Reference Data Promotion with Drift Check, Approval and Revert

Promote Dolt reference data safely. Merge the reviewed commit by hash after approval, verify lineage and row counts, and revert automatically on a mismatch.

Categories
Data

Reference data in Dolt, such as price lists, routing rules or feature tables, is edited on a staging branch and promoted to main. The risks are quiet: a commit pushed to staging while a review waits, a table that loses half its rows, a hotfix committed straight to main, a merge that does not change what was reviewed. This blueprint promotes by commit hash, keeps state in Kestra KV, asks a person, verifies the merge against the review and reverts it when they differ.

How it works

  1. The staging_ahead trigger (io.kestra.plugin.jdbc.mysql.Trigger, shipped disabled) fires when dolt_log('main..staging') has commits. KV supplies the main head left by the last promotion and what was already done with this exact staging commit.
  2. inspect reads both heads, uncommitted tables, merge conflicts (dolt_preview_merge_conflicts_summary) and the diff. It uses the three-dot form main...staging, the changes a merge applies. The two-dot form also shows the reverse of commits that reached main after staging branched.
  3. check_drift counts commits on main after the head this flow left, which are changes made outside it. evaluate_invariants runs your SELECTs AS OF the inspected staging commit.
  4. findings and verdict classify the run. Conflicts, uncommitted work on main or an invariant violation block it. Schema changes, large deletes or rewrites, or outside commits need a person. Blocked and declined plans are remembered, so the trigger does not repeat them.
  5. approve_promotion (io.kestra.plugin.core.flow.Pause) waits for Approve. The default is false, so a timeout merges nothing. recheck_heads aborts if either branch moved in the meantime.
  6. promote runs DOLT_MERGE('--no-ff', ..., '<reviewed hash>'). verify_promotion and verify_invariants_after check that the new head merges exactly the two reviewed heads, that the rows added, deleted and modified equal the review and that the invariants hold. Otherwise revert_promotion runs DOLT_REVERT and verify_revert proves main equals the head it had before the merge.

What you get

  • A merge of the reviewed commit, not whatever the branch name points at when Approve is clicked.
  • Detection of commits that bypassed the flow.
  • Verification against the review, and a one-commit revert when it fails.
  • KV markers with a time to live: pending ones expire with the approval window.

Who it's for

  • Data and platform teams that keep reference or configuration tables in Dolt.

Why orchestrate this with Kestra

Dolt gives branches, diffs and revert, but no trigger, no approval step and no memory of what the last run saw. Kestra polls for new staging commits, keeps state in KV, pauses for a person and reports each outcome.

Prerequisites

  • A Dolt SQL server (dolthub/dolt-sql-server 1.x or 2.x) with the target branch as its default and a staging branch.
  • A SQL user that can read both branches and run DOLT_MERGE and DOLT_REVERT on the target.

Secrets

  • DOLT_JDBC_URL: JDBC URL of the database, for example jdbc:mysql://dolt:3306/pricing.
  • DOLT_USER: SQL user.
  • DOLT_PASSWORD: its password.
  • SLACK_WEBHOOK_URL: Slack incoming webhook for plans, outcomes and failures.

Quick start

  1. Start a server: docker run -d --name dolt -p 3306:3306 -e DOLT_ROOT_PASSWORD=secret -e DOLT_ROOT_HOST=% -e DOLT_DATABASE=pricing dolthub/dolt-sql-server:2.5.0.
  2. On pricing create price_list (sku, price, currency), insert rows, then CALL DOLT_COMMIT('-A', '-m', 'initial') and CALL DOLT_BRANCH('staging').
  3. On database pricing/staging change some rows and CALL DOLT_COMMIT('-A', '-m', 'price review').
  4. Add the four secrets and run the flow with dry_run: true to read the plan.
  5. Run with dry_run: false, tick Approve and watch the merge and its verification. Then enable staging_ahead. Triggered runs use the input defaults, so change the dry_run default to false once the plans look right.

How to extend

  • Add CALL DOLT_PUSH('origin', 'main') after a verified promotion to feed replicas or DoltHub.
  • Add invariants that join tables, for example every sku in price_list exists in products.
  • Run one flow per database by changing state_scope and the branch variables.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.