Database
Choose between PostgreSQL, Turso with Embedded Replicas, or SQLite
Configuration
This choice can be made using the GoFast CLI or by modifying the docker-compose.yml
file.
via CLI
Possible options are SQLite
, Turso with Embedded Replicas
, PostgreSQL (local)
and PostgreSQL (remote)
.
The PostgreSQL (local)
will add a PostgreSQL instance to your Docker Compose file.
via Docker Compose
Possible options are sqlite
, turso
, postgres
and memory
.
Database Configuration
Depending on the provider, you need to set the following environment variables in the docker-compose.yml
file:
- for
sqlite
, setSQLITE_FILE
to the file location. - for
turso
, setTURSO_URL
andTURSO_TOKEN
. - for
postgres
, setPOSTGRES_HOST
,POSTGRES_PORT
,POSTGRES_DB
,POSTGRES_USER
andPOSTGRES_PASS
. - for
memory
, no configuration is needed.
Implementation Details
SQLite
The only environment variable required here is SQLITE_FILE
, which points to the file location of the database.
This is also the default configuration when building the base project, with a modern setup:
This is more than enough for 90% of applications. For backups, you can use:
PostgreSQL
When using the CLI, you can choose between a local or remote PostgreSQL instance. The local option will add a PostgreSQL instance to your Docker Compose file:
For the remote option, you need to set the following environment variables:
Turso with Embedded Replicas
For Turso, first log in and create a database:
You need two environment variables, TURSO_URL
and TURSO_TOKEN
, both of which can be found here:
After setting up the database, you can use the Turso provider:
Adding a new provider
To add a new provider, follow these steps in the /storage.go
file:
- Add the new provider to the
Provider
constant.
- Create a new provider function that returns database driver and cleanup functions.
- Return the new provider in the
NewStorage
function:
-
Add any new secrets in the
env.go
file. -
Fill in the
docker-compose.yml
file with the new provider configuration.
Troubleshooting
- When running Docker on WSL2, the SQLite file may not work. In that case, you probably need to exclude it from volumes:
Need help?
Visit our discord server to ask any questions, make suggestions and give feedback :).