feat: make Drizzle ORM the default for Lakebase plugin#388
Draft
pkosiec wants to merge 1 commit into
Draft
Conversation
- Add `appkit.lakebase.drizzle(schema)` SDK helper with dynamic import (drizzle-orm as optional peerDep, zero cost if unused) - Rewrite template todo example to use Drizzle query builder - Add template files: db/schema.ts, db/index.ts, drizzle.config.ts - Add conditional drizzle-orm + drizzle-kit deps to template package.json - Add drizzle-kit scripts (db:push, db:generate, db:migrate) - Update Lakebase plugin docs with Drizzle section (schema, queries, migrations, OBO) - Update @databricks/lakebase README with expanded Drizzle example Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com>
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.
Summary
Makes Drizzle ORM the default experience when scaffolding apps with the Lakebase plugin.
SDK
appkit.lakebase.drizzle(schema)helper using dynamicimport()— zero cost if unused, fullNodePgDatabase<TSchema>types when drizzle-orm is installeddrizzle-ormadded as optional peerDep (no impact on users who don't use it)Template
server/db/schema.ts(pgSchema + table definition + inferred types)server/db/index.ts(ensureSchema + initDb via SDK helper)drizzle.config.tsfor drizzle-kit migrationsdrizzle-orm+drizzle-kitdeps (only when lakebase feature is selected)db:push,db:generate,db:migratenpm scriptsDocs
@databricks/lakebaseREADME Drizzle exampleKey design decisions
drizzle()method lives in the SDK (not template) because template code is frozen at scaffold time — SDK code stays current withnpm updatedrizzle-ormis loaded lazily viaawait import()so there's zero runtime cost for users who don't call.drizzle()import("drizzle-orm/node-postgres").NodePgDatabase<TSchema>in.d.ts— resolved only when the method is calledconstructor.name.includes('Pool')for transactions — RoutingPool passes this, so OBO routing works transparentlydrizzle-ormanddrizzle-kituse Go template conditionals ({{if .plugins.lakebase}}) in package.json — only installed when lakebase is selectedTest plan
databricks apps init --template