Repository navigation
docs: design 001, database development flow - #677
Conversation
Signed-off-by: ditadi <victordperd@gmail.com>
… 001 Signed-off-by: ditadi <victordperd@gmail.com>
🤖 AppKit PR bot🔬 Run evalsStart an eval for this PR from the evals-monitor app: Go to Evals Monitor → 📦 Try this PR's app templateScaffolds a new app from this PR's SDK build. Run it in any folder (requires the GitHub CLI — gh run download 45620681805 -R databricks/appkit -n appkit-template-0.104.1-pr.64df09f-stack-database-dev-flow-00-design-677 -D appkit-pr-677 \
&& unzip -o "appkit-pr-677/appkit-template-0.104.1-pr.64df09f-stack-database-dev-flow-00-design-677.zip" -d "appkit-pr-677" \
&& databricks apps init --template "appkit-pr-677"The template pins |
Signed-off-by: ditadi <victordperd@gmail.com>
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>
…he stack code Signed-off-by: ditadi <victordperd@gmail.com>
… and prompts Apply the review of the design doc. The pooler refusal belongs to migrate on start, the migrator reconciles without the lock before it takes it, the deploy guard reads each target with and without variable-overrides.json, and init asks only for --schema clean and an ambiguous rename. The reveal also moves the database export into the generated barrel, check refuses a file that is not a drizzle-kit snapshot, and the project is not a databricks.yml variable. Signed-off-by: ditadi <victordperd@gmail.com>
Signed-off-by: ditadi <victordperd@gmail.com>
… database dev flow design Record the review decisions: the app's service principal owns the deploy branch's objects with manual recovery, a new fork starts without copied app rows, and the stack ships on drizzle-kit 0.31's journal. Renumber the open questions and point the doc at them by number. Add a runbook for a migration that fails on deploy, separate lock acquisition from lock holding, and give the procedure for a stuck start. Narrow the claims about clean, branch guards, baselines and verify --deployed, and describe the behavior this fix round adds across the stack. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: ditadi <victordperd@gmail.com>
fjakobs
left a comment
There was a problem hiding this comment.
This is an AI-generated review (Claude Code). Treat each comment as a lead to check, not a verdict.
This PR only adds the design doc, so each inline comment marks a place where the doc contradicts itself, design 002 on main, or the code at the top of the two stacks: stack/database-stable/06-serve-operations for operations and stack/database-dev-flow/08-db-check for migrations. Comments marked "checked" are backed by reading that code; the four marked "from reasoning" come from how Postgres and the platform behave and weren't reproduced. Nothing was run: no CLI, no deploy.
Two comments point at code bugs, not just doc drift:
init.tsinstalls drizzle-kit only for themigrateandintrospectstarts, butcleanis now the default for a new fork, so a new app's firstappkit db migratefails.--schema noneon a new fork skips the rebuild but still clearsAPPKIT_DB_NEW_BRANCH, so the copied production rows stay on the branch.
Smaller items without inline comments:
databricks apps run-localwith exported M2M credentials migrates as an identity other than the app.- The journal-ownership rule as written would refuse the service principal's own journal in
public. - The production registry claims ignore the Jiti source fallback.
- The v0.87/v0.88 references are stale;
mainis at v0.91. - The "preserves existing beta startup behavior" heading is wrong: an upgrade without
schemaNamefails the startup check. - The operation sections repeat design 002 and have already drifted from it; linking to design 002 would avoid that.
- The
listNotesexample has no limit, andgetNotelets any caller read any note. - The
pg_cancel_backendrunbook doesn't name a role with the rights it needs. - The branch-limit message lists only your own branches, so a new developer has nothing to delete.
Thanks for the review. Replies to the items in the summary:
|
Replace the operation sections with a summary that links to design 002, and describe the behavior the stack has after this fix round: init decides from the branch instead of the APPKIT_DB_NEW_BRANCH marker, forks the default target's branch and installs drizzle-kit for every start except none; migrate on start runs only as the app's own service principal and refuses dev- or session-shaped branches; a deploy start refuses edited migrations and diverged histories; the failure runbook repairs data with a DATABRICKS_SUPERUSER role instead of editing the migration; and the deploy section states what Apps does with health checks, classic and no-downtime compute, crashes and scale to zero. Also drop the release numbers, rename the upgrade section, correct the journal trust rule and the ownership recovery, name the role for a stuck start, and record the answered open questions. Signed-off-by: ditadi <victordperd@gmail.com> Co-authored-by: Isaac <no-reply@databricks.com>
…ll ownership inventory in design 001 Migrate on start now requires PGUSER to be set and equal to DATABRICKS_CLIENT_ID, so the doc states it as an identity check rather than deployment detection, and names the gap before init writes PGUSER. The fork-copy rule adds a branch the same init run created, the tag written only into a journal the migrator trusts with a warning when it cannot be, migrate, introspect and seed refusing an untouched copy, and --schema clean after keeping copied rows. The remaining windows are listed as they stand. The ownership recovery takes the hand-off's full inventory across databases before delete-role, and says the delete drops the role's memberships and grants. Clean lists what CASCADE drops before it asks; init's rebuild reports it after. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: ditadi <victordperd@gmail.com>
…foreign key refusal Introspect keeps the old schema.ts's .private() and writes every other column and foreign key as the catalog has it. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: ditadi <victordperd@gmail.com>
MarioCadenas
left a comment
There was a problem hiding this comment.
One gap inline. Reviewed at fde70db.
Introspect leaves out what the builder cannot express, such as generated columns, unsupported types and defaults, identity columns other than the primary key, and composite, cross-schema, self-referencing or cycle-closing foreign keys. The design said every column and foreign key was written as the catalog has it. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: ditadi <victordperd@gmail.com>
A foreign key on a column introspect cannot write goes with that column, and the column's skip comment covers both. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: ditadi <victordperd@gmail.com>
CHECK and EXCLUDE constraints and indexes get a warning, not a skip comment, and a branch rebuilt from the migrations lacks them. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: ditadi <victordperd@gmail.com>
🥞 Stacked PR (generated by Stack)
Use this link to review incremental changes.
What did you change, and why?
Design 001 (
designs/001_DatabaseDevelopmentFlow.md) describes database branch ownership, committed migrations, and deployment. This revision updates the application development flow to match the named-operation design and experience fixes in #687–#692.database()discovery,routes: false, and an explicit custom registry. Covers committed registry/contracts, development reloads for shared schemas and policies, first/last route changes, and source-less production builds.skipToken, operation/session-scoped state, late responses, refresh after writes, and safe field feedback that preserves failed drafts.The migration decisions remain: opt-in startup migrations, per-migration transactions, bounded advisory/history locks, branch guards, ownership handoff, private-column preservation, deployed verification and offline history checks. The tooling remains internal at
@databricks/appkit/beta/database-tooling, and revealing the hidden plugin/commands remains a separate change.The document explicitly distinguishes the migration chain (#654–#678) from the operation chain (#687–#692). Combined startup/deployment validation is a release integration step; the separate chains' checks do not establish that integration. PR #677 targets
mainindependently, and the implementation chain begins at #654 onmain.The linked Google Doc remains available for comments and edits. This PR updates the Markdown design copy.
Review round, 2026-11-09:
initforks starts with no copied app rows, and--schema migrateopts in to keeping them (Q5); the stack ships on drizzle-kit 0.31's journal v7 (Q9). The remaining questions are renumbered.lock_timeout) from how long it holds one (unbounded), with the procedure for a stuck start.verify --deployedproves the deployed source rather than applied migrations, clean leaves SP-owned tables inpublicand cascades into dependents, and init's drizzle-kit install runs lifecycle scripts. Names the gap of a local start against the deploy branch beforeappkit db initruns, and spells out the branch-naming rules.Fix round for fjakobs's review of #677, 2026-11-15:
appkit db initdecides from the branch itself instead of an.envmarker. Migrate on start is an identity check:PGUSERmust be set and equalDATABRICKS_CLIENT_ID.editedand a diverged history refuse a deploy start.delete-role --reassign-owned-toafter a full inventory, and long backfills run as a batched DML job between an expand and a contract migration.client_connection_check_intervalis allowed, no permission is narrower than CAN MANAGE, schema-only branches are not in the public API, and the facts about Genie App Builder..private()the oldschema.tsdeclares, and every other column it writes is public. The private-by-default and the foreign key refusal existed only for the AutoCRUD routes, which the operation stack removes.Review round for MarioCadenas's review, 2026-11-25:
Skippedline, a warning with no comment, andApproximatedinformation. CHECK and EXCLUDE constraints and indexes get a warning (feat(appkit): add appkit db introspect #670), and a branch rebuilt from the migrations lacks them while the deploy branch keeps them.How do you know it works?
Documentation only. Checked the changed contracts against the current #687–#692 implementation and plugin guidelines; validated the syntax of all three TypeScript/TSX examples, balanced fenced blocks, operation PR references, and
git diff --check. The branch's pre-existing Knip findings (one unused CLI file and three dev dependencies) also occur with the unchanged design; they are unrelated to this Markdown-only edit. No runtime or app files are included.Review round, 2026-11-09: each fix has a failing-then-passing test in its PR, and every layer's appkit and shared tests ran against Postgres 14 after the sync. At the top of the stack,
pnpm build,pnpm test(6502 passed, 1 skipped),pnpm -r typecheck,pnpm check,pnpm knipandpnpm docs:buildpass.Fix round for fjakobs's review, 2026-11-15: each fix has a failing-then-passing test in its PR, and every layer's database, plugin and CLI tests ran against Postgres 17 after the sync. A throwaway Lakebase fork confirmed that the developer role can write the service principal's rows but cannot alter its tables. At the top of the stack,
pnpm test(6602 passed, 1 skipped),pnpm -r typecheck,pnpm buildandpnpm docs:buildpass, and oxlint and oxfmt are clean on every changed file.