Persist the SQLite database instead of losing it on every restart - #918
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
|
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
The app ran on
:memory:in dev and on a different copy ofinit.jsin Docker, so all data died on restart and the two schemas had silently drifted. This makes the realinit.jsthe single source of truth, gives itDATABASE_PATHsupport, and adds a volume so the file actually survives.The drift was a latent outage.
docker/overrides/database/init.jswas copied overbackend/src/database/init.jsat image build time, and itsclientstable had nodepartment/emailcolumns (and itsuserstable nopassword_hash) — columnsroutes/clients.jsand password auth both use.CREATE TABLE IF NOT EXISTSmasked it, and in-memory DBs died before it mattered; the first persisted run would have failed withno such column: department. Deleting the override eliminates the class of bug, not just this instance.WAL/
busy_timeoutare deliberately file-only (meaningless for:memory:);foreign_keysis now on everywhere, which previously only the Docker override did. The in-memory connect log message is unchanged because__tests__/database/init.test.jsasserts it verbatim.Persistence itself is infra: new root
docker-compose.ymlmounts named volumetimesheet-dataat/app/data(without it,DATABASE_PATHbuys nothing since/app/datadies with the container) and requiresJWT_SECRETfrom the environment via${JWT_SECRET:?...}rather than baking one in.docker/overrides/server.jsis untouched — it carries real production-only concerns (static frontend serving, CSP), unlike the DB override which existed only to swap:memory:for a path.Verification
backend— 8 suites / 172 tests pass;frontendlint passes.DATABASE_PATH, created user + client + work entry over HTTP, restarted the process, confirmed the rows (includingdepartment/email) came back.docker compose configresolves; build context matches the Dockerfile'sCOPYpaths.Not included (deliberately)
Still needed before this is truly "productionized": a migration strategy (
CREATE TABLE IF NOT EXISTScannot alter a column once data is real), backups (sqlite3 .backup, nevercpa live WAL DB), and a decision on SQLite-on-a-volume vs Postgres — the volume approach pins you to one container, so no horizontal scaling or zero-downtime deploys.Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/098a84db1e184eed97edde7d65e000e3
Requested by: @bsmitches