Skip to content

feat(appkit): render the database development flow in the app template - #675

Draft
ditadi wants to merge 3 commits into
stack/database-dev-flow/03-db-migratefrom
stack/database-dev-flow/07-apps-init
Draft

ditadi wants to merge 3 commits into
stack/database-dev-flow/03-db-migratefrom
stack/database-dev-flow/07-apps-init

Conversation

@ditadi

@ditadi ditadi commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #666. The design is #677.

This PR absorbs no other PR. It is the template half of the old #675. The rest of #675 moved to #654 (the ownership recovery hint) and #666 (the verify warning and the development-flow docs).

What did you change, and why?

Before databricks apps init can offer the database plugin, a scaffolded app has to come with what the flow needs, so a developer can follow its README from appkit db init to a deploy that applies the migrations. This PR adds that to the template, still behind the hidden plugin.

For an app that selects the plugin, the template now renders:

  • app.yaml with APPKIT_DB_MIGRATE_ON_START=true in env, so the deployed app applies its committed migrations on start (feat(appkit): apply committed database migrations on deploy start, in schema app by default #654).
  • A README section that walks through appkit db init, migrate and verify, committing the migrations, what the deploy waits for, adopting existing tables with init --schema introspect, clean and seed, and the appkit db check step in CI. After the production deploy it adds npx appkit db verify --deployed -t prod.
  • config/database/schema.ts without main's comment that says to create the tables before you declare them. The README and the plugin docs now cover the file.

For every app, server/server.ts calls process.exit(1) when createApp fails, so a failed migration stops the app instead of leaving it up without routes.

This PR also changes these files:

  • The manifest's Lakebase project field sets bundleIgnore, so the project goes to .env and gets no databricks.yml variable. bundle-size-baseline.json records the 27 bytes it adds.
  • tools/smoke-test-template.ts keeps the content of an {{- if or ...}} block that names a plugin under --all-plugins. Before, it dropped the env: key and left the flag under health_check, which is not valid YAML. Its three copies of the conditional-stripping code are now one table run by one loop.
  • The plugin docs' Basic usage says what a scaffolded app includes, and Migrations on deploy says scaffolded apps set the flag.
  • The design doc's Rollout Plan and PR Stack describe the three PRs, and its Background and Flag Strategy cite them.

What this PR does not do:

  • It does not offer the plugin. The manifest keeps hidden: true, template/appkit.plugins.json does not list it, and beta.ts still exports database by hand. So apps init scaffolds no app with the database blocks yet, and only the process.exit(1) change reaches new apps. Offering the plugin is a later, separate change.
  • appkit db stays hidden from appkit --help.
  • drizzle-kit is not a template dependency, because appkit db init installs it.

How do you know it works?

  • tools/smoke-test-template.test.ts scaffolds the real template and parses app.yaml. With --all-plugins, env has APPKIT_DB_MIGRATE_ON_START, and without plugins there is no env. Before the fix, the --all-plugins case failed with YAMLParseError: A block sequence may not be used as an implicit map key at line 8.
  • The old and the new smoke script scaffold byte-identical trees (61 files), with and without --all-plugins.
  • On this branch, with Postgres 17, pnpm build, pnpm -r typecheck, pnpm check, pnpm test (386 files and 7219 tests passed, 1 skipped, the 2 new tests included), CI=1 pnpm exec vitest run packages/shared/src/cli/commands/db (5 files, 66 tests) and pnpm docs:build passed. The template smoke scaffolded with and without --all-plugins. They ran one commit before a two-line fix to the design doc's Flag Strategy table and PR Stack, and the head differs from that commit only in those lines.
  • I ran the smoke without --run, which installs the published appkit and so would not test this tree. CI runs the smoke with --run, with and without --all-plugins.
  • Before the comment cleanup, the tree with all three PRs equaled the old feat(appkit): add appkit db check #678 tip merged with current main, except the rewritten PR Stack and Rollout sections and the regenerated bundle baseline.
  • The cleanup commit removes three comments and folds the smoke script's conditionals into one table. A script listed every string literal the diff changes, and no text in a throw, warn, info, ok or fail call changed.
  • Two GPT reviewers read the consolidation. The split reviewer found one doc issue, how the design doc described which branches appkit db changes, and those lines are fixed. The cleanup reviewer found nothing.

This revision was not run against a real Lakebase workspace, and app.yaml.tmpl was not rendered with Go text/template. The smoke script renders the conditionals with regular expressions. The design's done criterion for this PR, a throwaway app that follows only its README from appkit db init to a deploy that applies the migration, is still open.

This pull request and its description were written by Isaac.

@ditadi
ditadi force-pushed the stack/database-dev-flow/07-apps-init branch from 07b1748 to 7db9fa1 Compare October 20, 2026 09:20
@ditadi
ditadi force-pushed the stack/database-dev-flow/07-apps-init branch from 7db9fa1 to 81e2e8f 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 45843180927 -R databricks/appkit -n appkit-template-0.105.0-pr.734b8dd-stack-database-dev-flow-07-apps-init-675 -D appkit-pr-675 \
  && unzip -o "appkit-pr-675/appkit-template-0.105.0-pr.734b8dd-stack-database-dev-flow-07-apps-init-675.zip" -d "appkit-pr-675" \
  && databricks apps init --template "appkit-pr-675"

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.

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

📦 Bundle size report

Compared against bundle-size-baseline.json (main).

@databricks/appkit

npm tarball (packed): 1.5 MB (-35 KB) — gzipped download (dist + bin; excludes release-only docs/NOTICE).

dist raw gzip
JS (runtime) 1.6 MB (-30 KB) 575 KB (-12 KB)
Type declarations 495 KB (-8.6 KB) 179 KB (-3.8 KB)
Source maps 3.1 MB (-56 KB) 1.0 MB (-21 KB)
Other 11 KB 3.7 KB
Total 5.2 MB (-95 KB) 1.8 MB (-37 KB)
Per-entry composition (own code — deps external (as shipped))
Entry Initial (gz) Lazy (gz) Total (gz) node_modules (min) Own code (min)
. 118 KB (+5 B) 2.4 KB 121 KB (+5 B) external 378 KB (+7 B)
./beta 127 KB (+252 B) 4.6 KB (+5 B) 132 KB (+257 B) external 383 KB (+821 B)
./beta/database-tooling 62 KB (+243 B) 0 B 62 KB (+243 B) external 187 KB (+1.0 KB)
./testing 47 KB (+3 B) 38 KB (+4 B) 85 KB (+7 B) external 246 KB (+7 B)
./tsdown 630 B 0 B 630 B external 1.0 KB
./type-generator 31 KB (+5 B) 0 B 31 KB (+5 B) external 89 KB (+7 B)

Chunks:

Entry Chunk Load Size (gz)
. index.js initial 114 KB
. utils.js initial 4.6 KB
. remote-tunnel-manager.js lazy 2.4 KB
./beta beta.js initial 101 KB
./beta stream-manager.js initial 5.9 KB
./beta define-schema.js initial 5.9 KB
./beta service-context.js initial 4.3 KB
./beta modular.js initial 3.6 KB
./beta databricks.js initial 3.3 KB
./beta wide-event-emitter.js initial 2.8 KB
./beta client.js initial 645 B
./beta index.js initial 20 B
./beta index.js lazy 4.1 KB
./beta supervisor-api.js lazy 201 B
./beta databricks.js lazy 188 B
./beta index.js lazy 124 B
./beta/database-tooling index.js initial 62 KB
./testing manifest.js initial 33 KB
./testing index.js initial 10 KB
./testing wide-event-emitter.js initial 2.9 KB
./testing index.js lazy 34 KB
./testing remote-tunnel-manager.js lazy 2.4 KB
./testing utils.js lazy 1.8 KB
./tsdown index.js initial 630 B
./type-generator index.js initial 31 KB

@databricks/appkit-ui

npm tarball (packed): 393 KB — gzipped download (dist + bin; excludes release-only docs/NOTICE).

dist raw gzip
JS (runtime) 430 KB 146 KB
Type declarations 250 KB 93 KB
Source maps 837 KB 281 KB
CSS 16 KB 3.2 KB
Total 1.5 MB 522 KB
Per-entry composition (consumer bundle — deps bundled, peerDeps external)
Entry Initial (gz) Lazy (gz) Total (gz) node_modules (min) Own code (min)
./js 5.3 KB 49 KB 55 KB 208 KB 14 KB
./js/beta 2.4 KB 0 B 2.4 KB 0 B 5.3 KB
./react 441 KB 49 KB 489 KB 1.4 MB 180 KB
./react/beta 13 KB 0 B 13 KB 25 KB 13 KB

Chunks:

Entry Chunk Load Size (gz)
./js index.js initial 5.2 KB
./js chunk initial 120 B
./js apache-arrow lazy 49 KB
./js/beta beta.js initial 2.4 KB
./react index.js initial 439 KB
./react tslib initial 2.1 KB
./react apache-arrow lazy 49 KB
./react/beta beta.js initial 13 KB

ditadi added a commit that referenced this pull request Oct 30, 2026
The design doc promised behavior the corrected stack does not ship. It
now describes what the code does:

- The tooling export is @databricks/appkit/beta/database-tooling, beta
  and internal to the AppKit CLI.
- migrate, introspect, clean and init hold config/database/.appkit-db.lock.
  init holds one lock for its whole run, and init --schema none, seed,
  verify and clean --delete-branch take none. The doc says how to
  recover a stale lock file.
- init --schema none hands off nothing, and schema public is never
  handed off.
- Values in variable-overrides.json count for the deploy boundary, and
  an unresolved branch or database reference refuses every write.
- Introspect keeps .private() on declared columns, writes new columns
  private, and refuses a schema.ts that does not load or a foreign key
  it does not declare.
- verify --deployed compares the committed migrations with the source
  snapshot of the active deployment, and fails when it cannot read it.
- Migrations log one line per run. There is no span and no metric.
- #675 keeps the plugin and appkit db hidden. A reveal is a later,
  separate change.

The appkit db check section stays as it is until #678 settles.

Signed-off-by: ditadi <victordperd@gmail.com>
@ditadi ditadi changed the title feat(appkit): offer the database plugin in databricks apps init feat(appkit): add template and docs for the database development flow Oct 30, 2026
ditadi and others added 3 commits November 26, 2026 15:36
Apps scaffolded with the database plugin get what the flow needs to deploy
their migrations. The plugin stays hidden: the manifest keeps hidden: true,
template/appkit.plugins.json does not list it, and `appkit db` stays hidden
from `appkit --help`.

What ships:

- APPKIT_DB_MIGRATE_ON_START=true in app.yaml for apps that select the
  plugin, and a comment that keeps the /health check.
- process.exit(1) when createApp fails, for every app the template renders,
  so a failed start stops the app instead of serving without its routes.
- A schema.ts comment that points at `appkit db migrate`, and a README that
  walks through `appkit db init`, `migrate`, `verify`, deploy and the
  `appkit db check` CI step, and works before the CLI release.
- bundleIgnore on the plugin's Lakebase project field, and the smoke test's
  handling of `{{- if or ...}}` blocks.
- The plugin docs' note on what a scaffolded app includes.
- The design doc's Rollout Plan and PR Stack for the three PRs that ship
  the flow.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: ditadi <victordperd@gmail.com>
…ery plugin

tools/smoke-test-template.ts stripped every `{{- if or .appEnv .plugins.*}}`
block before its `.plugins.*` pass, even under --all-plugins. The rendered
app.yaml then put `- name: APPKIT_DB_MIGRATE_ON_START` under health_check
with no env key, which is not valid YAML.

Under --all-plugins, an `if or` that names a plugin now keeps its content.
A tools test scaffolds the template both ways and parses app.yaml: with
--all-plugins it has env with APPKIT_DB_MIGRATE_ON_START, without it has
no env.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: ditadi <victordperd@gmail.com>
…ionals from one table

The health-check note in app.yaml.tmpl and the usage note in the scaffolded
schema.ts are gone. README.md.tmpl and the plugin doc carry the same content,
and the app.yaml note rendered into every app, with or without the plugin.

The smoke test's three copies of the strip-a-conditional block are one table
of named patterns run by one loop. It scaffolds byte-identical output with
and without --all-plugins.

The design doc's Background and Flag Strategy name the three PRs, #654, #666
and #675, instead of the closed ones. Migrations on deploy says again that
scaffolded apps set APPKIT_DB_MIGRATE_ON_START, which holds once this PR
ships the template.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: ditadi <victordperd@gmail.com>
@ditadi
ditadi removed this pull request from stack #667 November 26, 2026 14:50
@ditadi
ditadi changed the base branch from stack/database-dev-flow/06-db-verify to stack/database-dev-flow/03-db-migrate November 26, 2026 14:51
@ditadi
ditadi force-pushed the stack/database-dev-flow/07-apps-init branch from 7aa8416 to 2032d58 Compare November 26, 2026 14:51
@ditadi ditadi changed the title feat(appkit): add template and docs for the database development flow feat(appkit): render the database development flow in the app template Nov 26, 2026
@ditadi
ditadi added this pull request to stack #752 November 26, 2026 14:52

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