- You can only have a single writer at a time on a SQLite database. This may not be an issue from a performance perspective as dozens of small writes may still complete faster than dozens of concurrent writes using other databases.
- You are effectively limited to a single machine. Machines can scale quite large these days, but requests from around the world will need to make the transit and back to this machine. LiteFS can provide read replicas.
- There will be momentary site unavailability when you deploy a new version. For most applications this will be a few hundred milliseconds.
fly launch will provide for you.
Dockerfile
If your application does not have aDockerfile, fly launch will create a Dockerfile for you. Determination of the
database provider and location of the database will be done by parsing your prisma/schema.prisma file:
Dockerfile, the CMD to start your application will be overridden in your fly.toml in order to run a startup script (as described below). These lines will look like:
Dockerfile, you can do so by running:
Volume
In order to survive restarts and deploys, your database will be placed on a volume. This is controlled by the mounts section in yourfly.toml:
fly deploy to make the new values effective.
Migrations and seeds
prisma migrate will be run every time your server starts, applying the migrations found in yourprisma/migrations directory against your production database.
If a seed command is found in your package.json, it will be run once, at fly launch time,
immediately after the first migration.
Backing up
Because SQLite runs on a single machine, it is susceptible to host and volume failures. For this reason LiteStream is automatically configured duringfly launch for Prisma applications that use SQLite, if you confirm that you want Tigris configured:
AWS_ACCESS_KEY_ID,
AWS_ENDPOINT_URL_S3,
AWS_REGION,
AWS_SECRET_ACCESS_KEY, and
BUCKET_NAME
And a litestream.yml file to be created:
Dockerfile for you, installation of Litestream will be included in the Dockerfile. Otherwise, @flydotio/litestream will be added to your package.json as a dependency.
In the event of a catastrophic failure, simply delete your machine and volume and run fly deploy. Your database will be automatically restored from backup.
If you decide later you don’t want LiteStream backups, delete the storage and secrets:
Setup Script
Depending on whether or not we generate aDockerfile for you, an ENTRYPOINT script named docker-entrypoint.js or a setup script named dbsetup.js will be created. This script will perform the following functions:
- Create a symbolic link from your database location to the volume. This will enable you to continue to develop and test on your local machine and still retain persistence of your database in production.
- Restore your database from LiteStream if it doesn’t currently exist.
- Run database migrations
- Run your seed command if the database doesn’t exist
- Run
litestream replicateto monitor & continuously replicate SQLite database. - Launch your application