Redeploying a BlitzJS app always auto-deletes the sqlite database

I have a running Blitz app on render. It uses sqlite and the database file is located at db/db.sqlite. Every time I trigger a new deploy, the db.sqlite file is always deleted. I understand that I need to create a disk to make it persist. So I create a new disk space and set the mount path as /db. The DATABASE_URL variable is file:./db/db.sqlite. But when the redeployment finishes the data in db.sqlite is wiped out again.

To sum up, here are my configs:

DATABASE_URL=file:./db/db.sqlite
Build command: yarn --frozen-lockfile --prod=false && blitz build
Disk mount path: /db

Outcome:

500 Error querying the database: unable to open database file: ./db/db.sqlite.

Anybody knows how to deploy a blitz app with sqlite on render? Any help would be appreciated.

Hey @laubonghaudoi,

It sounds like you have attached the disk at the root of your filesystem /db, while your database is using a relative path from your project root ./db/db.sqlite which will resolve to /opt/render/project/src/db/db.sqlite. You will want to persist your data to the root /db path where you attached your disk.

@jake Thank you so much! I set DATABASE_URL=file:/db/db.sqlite and the mount path /db. Everything is working fine now.

1 Like