From 234c0a96519f0cbe6ca07d7ef13ed70351f50200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Gr=C3=A6sberg?= Date: Sun, 22 Nov 2026 15:23:27 +0100 Subject: [PATCH] Fix CI not resetting db after test, causing failing seeding for runs on other branches --- .github/workflows/ci.yaml | 4 ++++ .prettierignore | 2 ++ packages/db/package.json | 1 + packages/db/prisma/blank.sql | 4 ++++ 4 files changed, 11 insertions(+) create mode 100644 packages/db/prisma/blank.sql diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 36b63d5..2099b4a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -50,3 +50,7 @@ jobs: - name: Test run: pnpm test + + - name: Reset test database + if: always() + run: pnpm --filter @t09-project-2/db run db:blank diff --git a/.prettierignore b/.prettierignore index 5b32ef0..c869462 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,5 +4,7 @@ yarn.lock .tanstack .agents **/src/generated/ +# Prisma SQL helpers (no prettier parser) +packages/db/prisma/*.sql # Generated Lighthouse report kept at the repo root for reference. lighthouse.json diff --git a/packages/db/package.json b/packages/db/package.json index d6d29ee..8c38c8c 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -13,6 +13,7 @@ "db:seed": "dotenv -e .env -- prisma db seed", "db:studio": "dotenv -e .env -- prisma studio", "db:reset": "dotenv -e .env -- prisma migrate reset", + "db:blank": "dotenv -e .env -- prisma db execute --file ./prisma/blank.sql", "typecheck": "tsc --noEmit" }, "dependencies": { diff --git a/packages/db/prisma/blank.sql b/packages/db/prisma/blank.sql new file mode 100644 index 0000000..5f515e9 --- /dev/null +++ b/packages/db/prisma/blank.sql @@ -0,0 +1,4 @@ +-- Drop everything in the public schema without replaying migrations. +-- Used by CI to leave the test database blank between runs. +DROP SCHEMA IF EXISTS public CASCADE; +CREATE SCHEMA public;