I’d like to use sqlite as my database for a simple Django app without LiteFS (for now). I have created an app with a single machine, and created the volume with fly volumes create blog_data. I’ve also added to fly.toml:
Good question. I am able to create that file manually by sshing into the app machine. I thought maybe by creating the file first that it might solve the problem, but rerunning fly deploy with the database set to "sqlite:////data/db.sqlite3" still fails with the same error.
I wonder if it’s a timing issue and the volume isn’t attached when that command is initially run.
I’ve commented out the migration in the deploy step:
That seems to fix the issue. I then run migrate manually after the deployment and it works. I can add a post to the database and when I deploy again, the post is still there.
I feel like this should be easier and documented somewhere. I’m going to write this up for my blog, and I’ll try to submit a new page for the docs.
So I looked into it a bit more, and release_command’s don’t have access to volumes, since they’re ephermereal and can’t attach the same volume as the main machine. I recommend running your migration script either somewhere in your Dockerfile ENTRY, or running it before starting your main application.
Thanks for confirming that. I was planning to look into where to run it so that I don’t have to do it manually. When you say ’ running it before starting your main application’, do you have any recommendations for where/how to do that? I’m wondering if there is a configuration in fly.toml that would run it after the machine has access to the volume, or if there is some other way you are thinking of.