I am currently developing a Remix app which has a Prisma DB with SQLite in the project file. I want to make the DB persistent using a volume and i mounted it in the fly.toml. There is no problem when mounting but somehow the app could not get any entries from the db. I also changed the url in the schema.prisma to the destination of the mounted volume.
The mounts section in fly.toml
The url in schema.prisma
I’m assuming that the app can write into the dev.sqlite file because it is not empty anymore and has some data saved in there. Granted i only opened the file using fly ssh console and used cat to read the file contents. I also changed the permission for the dev.sqlite and it now looks like this but I dont think this does anything.
I have a similar issue. I followed the suggestions and created 2 VM for my app, each VM with a volume so I can persist the Prisma db, everything looks good and I see that the data is stored in the dev.sqlite file as I see the size increase when doing a list -l.
But after some time the VM goes to sleep and when I refresh the shopify page, it starts back but with the original dev.sqlite, no data stored in it.
I have it working. I don’t know if this is the cleanest way but works for now.
I want to have the app on Fly.io and also be able to run it on the test store, so I created a variable in the .env file at the root of the project (local).
DATABASE_URL=file:mydb.sqlite
and in the fly.toml file I set the same variable but with the absolute path that will have in the server after deploying the app.
[env]
DATABASE_URL=“file:/data/mydb.sqlite”
and in schema.prisma I set the url to
datasource db {
provider = “sqlite”
url = env(“DATABASE_URL”)
}
So when I run npm run dev -- --reset it takes the value from .env and places the database file under the folder /prisma
and when I run npm run deploy -- --reset and flyctl deploy --remote-only it takes the value from fly.toml and places the database file under /data folder.
You can check this by doing fly ssh console and ls -l of those folders.
Now I have to figure out how to replicate the db on both volumes so it doesn’t matter which VM is running I see the same data… If I understood well from the docs this can be achieved with LiteFS