diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 6653e931c..e221063e7 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -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 diff --git a/internal-packages/database/README.md b/internal-packages/database/README.md index 41612ac2b..8dcb9c2da 100644 --- a/internal-packages/database/README.md +++ b/internal-packages/database/README.md @@ -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)