Skip to content

feat(appkit): add appkit db check - #678

Draft
ditadi wants to merge 1 commit into
stack/database-dev-flow/07-apps-initfrom
stack/database-dev-flow/08-db-check
Draft

ditadi wants to merge 1 commit into
stack/database-dev-flow/07-apps-initfrom
stack/database-dev-flow/08-db-check

Conversation

@ditadi

@ditadi ditadi commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🥞 Stacked PR (generated by Stack)

Use this link to review incremental changes.


Stacked on #675.

Summary

Adds appkit db check, an offline check of the committed migrations for CI. It reads only the checkout, so a pull request can run it without Databricks or Lakebase credentials. It fails when:

  • config/database/schema.ts changed and no committed migration has the change;
  • the journal lists a migration generated before the one ahead of it, which a branch that ran the newer one never runs;
  • a snapshot does not follow the one before it, which happens when two migrations were generated from one snapshot on parallel git branches;
  • a migration's .sql or snapshot is not committed, or a .sql is not in the journal.

Each finding names its fix, and the command exits 1 on any of them.

Details

  • The schema comparison reuses the diff appkit db migrate runs against the latest snapshot, now diffSchema in migrations.ts. So check fails exactly when migrate would write a migration. An ambiguous rename counts as a change, and nothing prompts.
  • The journal check also fails an entry whose idx is not its position, since drizzle-kit names snapshots by idx.
  • The schema is compared only when the latest snapshot is committed. Without it, the missing snapshot is the finding.
  • Two pull requests that both add 0001_migration conflict in git first. The check catches a resolution that keeps both. The fix it names takes the base branch's migrations, then runs appkit db clean and appkit db migrate. The clean is there because the developer's branch already ran the old migration.
  • Docs: db check joins the commands table. The CI section runs it on every pull request and explains the conflict. The template README names it.

Tests

  • The runCheck tests generate real migration history with drizzle-kit and a real schema.ts, with every Databricks and Lakebase call throwing. They cover:
    • a sound history, and no migrations with no tables;
    • a schema.ts change without its migration, with and without committed migrations, and an ambiguous column rename;
    • a merge that keeps two migrations generated from one snapshot;
    • a when out of order, and an idx that is not its position;
    • an uncommitted .sql and snapshot, and an unlisted .sql.
  • The CLI tests cover the pass and fail output, the exit code, and errors.
  • Against the dev-playground, which declares tables and commits no migration, check fails with the schema finding.
  • Build, typecheck, lint and format, and knip pass. The database tests pass against a local Postgres 14: 879 in appkit and 635 in the shared CLI.

`appkit db check` checks the committed migrations against
config/database/schema.ts without Databricks or Lakebase access, so CI can
run it on every pull request. It fails when:
- schema.ts changed and no committed migration has the change;
- the journal lists a migration generated before the one ahead of it,
  which a branch that ran the newer one never runs, or an entry whose idx
  is not its position;
- a snapshot does not follow the one before it, which happens when two
  migrations were generated from one snapshot on parallel git branches;
- a migration's .sql or snapshot is not committed, or a .sql is not in
  the journal.

Each finding names its fix. Parallel migrations are fixed by taking the
base branch's migrations, then `appkit db clean` and `appkit db migrate`.

The schema comparison reuses the diff `appkit db migrate` runs, so check
fails exactly when migrate would write a migration, and an ambiguous
rename counts as a change instead of prompting. The plugin docs' CI
section runs `appkit db check` on every pull request, and the template
README names it.

Signed-off-by: ditadi <victordperd@gmail.com>
@ditadi
ditadi force-pushed the stack/database-dev-flow/07-apps-init branch from 7db9fa1 to 81e2e8f Compare October 20, 2026 12:22
@ditadi
ditadi force-pushed the stack/database-dev-flow/08-db-check branch from 8ef366e to 0d6a48a Compare October 20, 2026 12:22
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AppKit PR bot

🔬 Run evals

Start an eval for this PR from the evals-monitor app: Go to Evals Monitor →

📦 Try this PR's app template

Scaffolds a new app from this PR's SDK build. Run it in any folder (requires the GitHub CLI — gh auth login — and the Databricks CLI):

gh run download 39421984615 -R databricks/appkit -n appkit-template-0.89.0-pr.fc69bde-stack-database-dev-flow-08-db-check-678 -D appkit-pr-678 \
  && unzip -o "appkit-pr-678/appkit-template-0.89.0-pr.fc69bde-stack-database-dev-flow-08-db-check-678.zip" -d "appkit-pr-678" \
  && databricks apps init --template "appkit-pr-678"

The template pins @databricks/appkit and @databricks/appkit-ui to tarballs built from this branch, so the scaffolded app runs against this PR's code.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant