Skip to content

Commit

Permalink
Run prisma diff in CI to ensure migrations match schema
Browse files Browse the repository at this point in the history
  • Loading branch information
darthmaim committed Nov 28, 2024
1 parent e7b35ce commit c84303b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ jobs:
name: Renovate
uses: ./.github/workflows/renovate-validate-config.yml

prisma:
name: Prisma
uses: ./.github/workflows/prisma-pending-migrations.yml

success:
name: Success
needs: [build, docker, test, lint, renovate]
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/prisma-pending-migrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Pending prisma migrations
on:
workflow_call:

jobs:
pending-migrations:
name: Pending Migrations
runs-on: ubuntu-latest
services:
database:
image: timescale/timescaledb:2.17.2-pg17
env:
POSTGRES_USER: gw2treasures
POSTGRES_PASSWORD: gw2treasures
POSTGRES_DB: gw2treasures
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Setup Node.js env
uses: ./.github/actions/setup-node-env
- name: Run prisma diff
run: |
pnpm --filter @gw2treasures/database exec \
prisma migrate diff \
--exit-code \
--from-schema-datamodel "./prisma/schema.prisma" \
--to-migrations "./prisma/migrations" \
--shadow-database-url "postgresql://gw2treasures:gw2treasures@localhost:5432/gw2treasures?schema=public"

0 comments on commit c84303b

Please sign in to comment.