Skip to content

Commit e422fb5

Browse files
committed
Added the ability to switch database volumes locally without losing data, with docs
1 parent ceac10b commit e422fb5

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

docker/docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ version: "3"
22

33
volumes:
44
database-data:
5+
database-data-alt:
56
pgadmin-data:
67
redis-data:
78

@@ -15,7 +16,7 @@ services:
1516
image: postgres:14
1617
restart: always
1718
volumes:
18-
- database-data:/var/lib/postgresql/data/
19+
- ${DB_VOLUME:-database-data}:/var/lib/postgresql/data/
1920
environment:
2021
POSTGRES_USER: postgres
2122
POSTGRES_PASSWORD: postgres

internal-packages/database/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
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.
44

5+
### How to switch branches when you've done migrations
6+
7+
Sometimes you've applied migrations and then want to switch branches without wiping out your local database.
8+
9+
To do this you can run the following command:
10+
11+
```bash
12+
DB_VOLUME=database-data-alt pnpm run docker
13+
```
14+
15+
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.
16+
17+
To switch back to the original volume, run the following command:
18+
19+
```bash
20+
pnpm run docker
21+
```
22+
523
### How to add a new index on a large table
624

725
1. Modify the Prisma.schema with a single index change (no other changes, just one index at a time)

0 commit comments

Comments
 (0)