Skip to content

Commit

Permalink
docs: clarify location of the database
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Oct 6, 2023
1 parent b48be8d commit 200932f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/components/progress-bar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useNavigation } from '@remix-run/react'
import React, { useEffect, useRef, useState } from 'react'
import { useEffect, useRef, useState } from 'react'
import { useSpinDelay } from 'spin-delay'
import { cn } from '#app/utils/misc.tsx'
import { Icon } from './ui/icon.tsx'
Expand Down
26 changes: 20 additions & 6 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,20 @@ Find instructions for this optional step in

### Optional: Connecting to your production database

The sqlite database lives at `/data/sqlite.db` in the deployed application.
Because it is SQLite, you cannot connect to it unless you're running a
command-line session on the machine. You can do this using `fly ssh console`.
The Dockerfile simplifies this further by adding a `database-cli` command. You
can connect to the live database by running `fly ssh console -C database-cli`.
The location of the sqlite database is kinda funny. The real location is in
`/data/litefs/dbs/sqlite.db`. However, during development you connect to it via
the fake filesystem managed by LiteFS so it can propagate any changes to your
database to all replicas.

So to connect to your database, you'll want to connect to it at
`/litefs/sqlite.db` in the deployed application. Because it is SQLite, you
cannot connect to it unless you're running a command-line session on the
machine. You can do this using `fly ssh console`. The Dockerfile simplifies this
further by adding a `database-cli` command. You can connect to the live database
by running `fly ssh console -C database-cli`.

To connect to the deployed database from your local machine using Prisma Studio,
you can utilize Fly's `ssh` and `proxy` commands.
you can utilize Fly's `ssh` and `proxy` commands.

- Run in one terminal the command to start Prisma Studio on your desired Fly app
```sh
Expand All @@ -136,6 +142,14 @@ you can utilize Fly's `ssh` and `proxy` commands.
To work with Prisma Studio and your deployed app's database, simply open
`http://localhost:5556` in your browser.

> **Note**: You may want to add `--select` to the `fly ssh console` command to
> select the instance you want to connect to if you have multiple instances
> running. Otherwise you could connect to a non-primary instance. The easiest
> way to determine the primary instance (because it can change) is to open your
> deployed application and check the request headers. One of them will be
> `Fly-Primary-Instance` which will tell you the instance ID of the primary
> instance.
## Seeding Production

Let's say you're building an application that allows users to lookup the nearest
Expand Down

0 comments on commit 200932f

Please sign in to comment.