Repository navigation
Conversation
This was referenced Oct 16, 2026
ditadi
force-pushed
the
stack/database-dev-flow/04-db-introspect
branch
from
October 19, 2026 15:02
a2522e5 to
c3e1172
Compare
`appkit db init` gives a checkout its own Lakebase branch, forked from the project's default branch: your dev branch, or with --session a branch for this checkout that expires after 7 days (or --ttl). It asks nothing. It refuses the default branch, protected branches and branches databricks.yml deploys to before any change, and when the project is at its branch limit it lists your branches to delete. It makes sure the branch has a read-write endpoint that suspends after 5 idle minutes and a Postgres role for you, points .env at it with an atomic 0600 write, hands you the app schema when the fork copied it owned by another Lakebase role, installs drizzle-kit when the app lacks it, then starts the schema by migrating, introspecting or cleaning. `appkit db clean` drops the app schema (only your objects in public) and lists what outside it went along; --delete-branch deletes this checkout's session branch instead. `appkit db seed` runs config/database/seed.sql in one transaction with the app schema on the search_path. Both run only on a branch created for you or this checkout. Signed-off-by: ditadi <victordperd@gmail.com>
ditadi
force-pushed
the
stack/database-dev-flow/05-db-init
branch
from
October 19, 2026 20:35
960b211 to
c56de21
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #670.
Summary
Adds
appkit db init,appkit db cleanandappkit db seed, which give a checkout its own Lakebase branch for local development.initasks nothing, so an agent or a script can run it as is.appkit db init:dev-<you>-<hash>branch (no expiry), or with--sessionasession-<hash>-<id>branch for this checkout (7 days, or--ttl 1h), forked from the project's default branch;DATABRICKS_SUPERUSER;.envat the branch;schema.ts), introspect (the default without), clean and then apply, or leave it.It refuses the project's default branch, protected branches and any branch
databricks.ymldeploys to, before changing anything. Those belong to the deployed app, which applies its own migrations on start (#654).Details
--sessionor--dev, init keeps the session branch.envpoints at, and otherwise uses your dev branch. The session hash comes from your user name, so a session id copied from someone else's.envis refused.databricks.ymldeploys to is refused before any API call. An existing branch that became the default or protected is refused after one read.databricks postgres delete-branchcommand. If none are yours, it says to ask a project owner..envbefore the branch is created, so a rerun after a failure reuses it.reassign_owned_to. When the delete fails, it lists the objects and privileges that block it, per database, frompg_shdepend. The default branch keeps its roles..envis refused when it is a symbolic link, before any API call. It is written to a temporary file with mode 0600 and renamed into place. Comments, order, other keys,exportand CRLF stay. A multi-line quoted value is one entry. A missing.envgets only the keys init writes, never.env.example's placeholders. When.envnames neitherDATABRICKS_CONFIG_PROFILEnorDATABRICKS_HOST, init adds the one it authenticated with.cleandrops the app schema, migration journal included, in one transaction.publiccannot be dropped, so there it drops the relations, types, functions, procedures, aggregates and window functions you own, and leaves extension members alone. Objects outside the schema that depend on it are dropped with it and listed. On a TTY the confirmation lists them first. Without a TTY it needs--yes.clean --delete-branchdeletes this checkout's session branch, for the end of a CI job. It refuses your dev branch.init --schema cleanasks on a TTY and needs--yeswithout one. A cancelled confirmation exits 1.seedrunsconfig/database/seed.sqlin one transaction, with the app schema first on thesearch_path.cleanandseedrun only on your dev or session branch, and check that before connecting.dbcommands stay hidden until the PR that adds them todatabricks apps init.Tests
runInitagainst an in-memory Lakebase covers:--ttl, and the session id kept on rerun;.envunchanged;.envrefused with no API call;.envcontents with the profile or host, and project resolution.env-filetests cover the symlink refusal, a failed write leaving the old file and no temporary file, multi-line values and an unclosed quote.--sessionagainst--dev, no prompts, the clean confirmation with its dependents,--delete-branch, exit code 1 on cancel and the output.clean.pg.test.tschecks that an app schema clean reports and drops only what CASCADE takes outside it, and that apublicclean drops a role's own objects and keeps extension members and other roles' objects.hand-off.pg.test.tschecks that the blockers list other databases' objects, a database the role owns, and grants.