PostgreSQL

PostgreSQL is a safe choice for production. Determination of the database provider and location of the database will be done by parsing your prisma/schema.prisma file:

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

fly launch will create a PostgreSQL database suitable for development. For production, see our list of recommended providers.

Fly.io has an upcoming managed databases product built it on top of Percona but availability dates and pricing have yet to be announced.

Dockerfile

If your application does not have a Dockerfile, fly launch will create a Dockerfile for you. If at a later time you would like to replace your Dockerfile, you can do so by running:

npx dockerfile

See fly-apps/dockerfile-node for a list of available options.

Migrations and seeds

prisma migrate will be run on every deploy, applying the migrations found in your prisma/migrations directory against your production database. The command to be run is controlled by your fly.toml:

[deploy]
  release_command = 'npx prisma migrate deploy'

If a seed command is found in your package.json, it will be run once, at fly launch time, immediately after the first migration.

Conversion from SQLite

Converting from SQLite starts by updating your prisma/schema.prisma to match what you see at the top of this post. Next, remove all your existing migrations in your prisma/migrations directory and recreate them:

rm -rf prisma/migrations
export DATABASE_URL=postgres://$USER@localhost/localdb
npx prisma migrate dev --name init

Remove the [processes] and [mounts] sections from the fly.toml and add the [deploy] section you see above.

Download your existing SQLite database and use pgloader to covert it to to postgres:

fly sftp get /data/dev.db
pgloader sqlite:./dev.db pgsql://$USER@localhost/localdb

Import the resulting database. For Fly Postgres use fly postgres import.

Set the DATABASE_URL secret using fly secrets set.

Run fly deploy.

Once you are up and running, you can delete your volume using fly volumes destroy.