Allow framework to boot without a database (HQ-30)#4
Closed
kobeindemans wants to merge 1 commit into
Closed
Conversation
Make the db connection pool lazy (behind a Proxy) so importing `db` no longer requires DATABASE_URL at module load, and gate migrateAllApps behind SKIP_MIGRATIONS=true. This lets the customer-facing portal deployment run the framework with no database of its own (HQ-30). The DATABASE_URL check now fires on first real db access, so existing consumers are unchanged and a genuine misconfiguration still throws.
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
Proxy) soimport { db }no longer requiresDATABASE_URLat module load.migrateAllAppsbehindSKIP_MIGRATIONS=true.Why
Prerequisite for the API-only customer portal (HQ-30). The portal is a separate deployment that holds no database and talks to HQ over HTTP. Today the framework throws at boot if
DATABASE_URLis unset (db/index.tstop-level check, reached viamigrateAllApps→dbimport). This change lets a deployment run the framework with no DB of its own.Behaviour
DATABASE_URLset (HQ, all existing deploys): unchanged — pool created on first db access.SKIP_MIGRATIONS=true+ noDATABASE_URL(portal): boots fine; never touches the DB.DATABASE_URLbut db actually used: still throws the original clear error, just on first access instead of at import.Verification
bun run tsc --noEmitinpackages/framework: clean.dbwith emptyDATABASE_URLsucceeds; callingdb.select()throwsDATABASE_URL is not set.🤖 Generated with Claude Code