Added the ability to switch database volumes locally without losing data, with docs

This commit is contained in:
Matt Aitken
2024-11-06 10:55:19 +00:00
parent ceac10b098
commit e422fb5e4d
2 changed files with 20 additions and 1 deletions
+2 -1
View File
@@ -2,6 +2,7 @@ version: "3"
volumes:
database-data:
database-data-alt:
pgadmin-data:
redis-data:
@@ -15,7 +16,7 @@ services:
image: postgres:14
restart: always
volumes:
- database-data:/var/lib/postgresql/data/
- ${DB_VOLUME:-database-data}:/var/lib/postgresql/data/
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
+18
View File
@@ -2,6 +2,24 @@
This is the internal database package for the Trigger.dev project. It exports a generated prisma client that can be instantiated with a connection string.
### How to switch branches when you've done migrations
Sometimes you've applied migrations and then want to switch branches without wiping out your local database.
To do this you can run the following command:
```bash
DB_VOLUME=database-data-alt pnpm run docker
```
This will switch to the `alt` volume for your local database. This database will be blank if you haven't switched to this volume before, so you'll need to follow the normal steps (in the Contributing guide) to get setup, e.g. apply migrations and seed.
To switch back to the original volume, run the following command:
```bash
pnpm run docker
```
### How to add a new index on a large table
1. Modify the Prisma.schema with a single index change (no other changes, just one index at a time)