Migrate Lakebase bundle examples to Postgres projects#161
Merged
Conversation
Update both knowledge_base Lakebase examples from the legacy
database_instances / database_catalogs resources to the Lakebase
Autoscaling postgres_projects / postgres_catalogs resources, and refresh
their READMEs (terminology, `databricks psql --project`, CLI v1.0.0).
In app_with_database, declare the Postgres database explicitly via a
postgres_databases resource (with an owner postgres_roles) so the app can
reference it by a stable id. Relying on the catalog's
create_database_if_missing creates a database with an auto-generated
database_id that the app cannot address by path, so the app's postgres
resource now points at ${resources.postgres_databases.my_database.id}.
Verified end-to-end on staging: the bundle deploys, the app starts and
provisions its schema and demo data, and `databricks bundle destroy`
tears everything down.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
The postgres_databases and postgres_roles resources this example now uses first shipped in Databricks CLI v1.4.0 (databricks/cli#5467 and databricks/cli#5627), so v1.0.0 is too low. database_with_catalog keeps v1.0.0, since postgres_catalogs shipped in v1.0.0. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
pietern
approved these changes
Jul 1, 2026
|
|
||
| # Declare the database explicitly so it has a stable id that the app can | ||
| # reference. Relying on the catalog's create_database_if_missing would create a | ||
| # database with an auto-generated id, which the app cannot reference by path. |
Contributor
There was a problem hiding this comment.
Doesn't create_database_if_missing produce a stable name?
Contributor
There was a problem hiding this comment.
Btw, there is also an auto-created database called databricks_postgres (or with dash for the API name).
Contributor
Author
There was a problem hiding this comment.
name is stable, but the app attaches to the database by its resource path:
projects//branches//databases/<database_id>
with create_database_if_missing the resource isn't addressable
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.
What
Migrate both
knowledge_baseLakebase examples from the legacydatabase_instances/database_catalogsbundle resources to the Lakebase Autoscalingpostgres_projects/postgres_catalogsresources.database_with_catalog— switchdatabricks.ymltopostgres_projects+postgres_catalogs; refresh the README (terminology,databricks psql --project ..., CLI v1.0.0).app_with_database— replacemydb.database.ymlwithmydb.postgres.yml; wire the app to the new resources; refresh the README.The
app_with_databasefixThe app attaches to the Postgres database by its resource path
projects/<id>/branches/<branch>/databases/<database_id>. Relying on the catalog'screate_database_if_missing: truecreates the database with an auto-generated, unstabledatabase_id, so the app has no stable path to reference — deploy fails repeatably with:Fix: declare the database explicitly as a
postgres_databasesresource (with an ownerpostgres_roles, which the CreateDatabase API requires) so it has a stabledatabase_id, and point the app'spostgresresource at${resources.postgres_databases.my_database.id}. Note thatdatabase_idmust be hyphenated (^[a-z][a-z0-9-]*) whilepostgres_databaseis the underscore-friendly Postgres database name.database_with_catalogintentionally keepscreate_database_if_missing— it has no app that needs a stable reference and is queried viapsqlby database name.Verification
Deployed
app_with_databaseend-to-end on staging: the bundle deploys all resources,databricks bundle run my_appreaches "App started successfully" (the app provisions itsholidays.holiday_requestsschema + demo data at import time), anddatabricks bundle destroytears everything down. Confirmed no Lakebase projects left running afterward.🤖 Generated with Claude Code