Skip to content

Conversation

@jcubic
Copy link
Collaborator

@jcubic jcubic commented Nov 20, 2025

Summary by CodeRabbit

  • Chores

    • Upgraded Prisma to v7 and added MariaDB and LibSQL adapters; updated package dependencies.
  • Refactor

    • Added an environment-aware Prisma configuration and adapter-backed client selection; removed embedded datasource connection declarations from schemas.
  • Tests / E2E

    • Tests now use a configurable DB file, simplified test DB lifecycle and cleanup steps, and removed a skipped auto-redirect password-reset test.
  • CI

    • Enhanced workflow triggers, guarded deployments, added preview builds, and PR preview URL comments.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 20, 2025

Walkthrough

Prisma upgraded to v7; added LibSQL and MariaDB adapters; generator provider changed to "prisma-client"; datasource URL lines removed from schemas; added prisma.config.ts for environment-aware schema/datasource selection; adapter-backed Prisma clients and CI/test DB/workflow adjustments introduced.

Changes

Cohort / File(s) Summary
Dependencies & Tooling
package.json
Add @prisma/adapter-libsql, @prisma/adapter-mariadb; bump @prisma/client and prisma v6 → v7; remove @prisma/client from devDependencies.
Prisma Schemas
prisma-e2e/schema.prisma, prisma-main/schema.prisma
Change generator provider "prisma-client-js""prisma-client"; remove datasource url / shadowDatabaseUrl lines; add header comments.
Centralized Prisma Config
prisma.config.ts
New file exporting defineConfig(...) that selects schema, migrations, seed and datasource by process.env.CI (file DB via DB_FILE for CI; env URLs otherwise).
Prisma Client & Adapters
src/lib/prisma.ts
Add @prisma/adapter-mariadb and @prisma/adapter-libsql; implement getPrismaMain() (MariaDB adapter) and getPrismaE2E() (LibSQL file DB); update client import/exports; export getPrismaE2E; wire authPrismaAdapter to adapter-backed client and preserve global singleton.
E2E / Test DB Setup & Constants
e2e/setup-e2e-db.js, src/test/global-setup.ts, src/test/constants.ts, src/test/setup-db.ts
Replace TEMP schema handling with DB_FILE/TEMPLATE_DB_FILE; update paths (e.g., ../prisma-e2e/test.db), add cleanup of existing DB and .next, run prisma generate/prisma db push with CI=true, remove journal/WAL/shm files, and adapt imports/types to new getPrismaE2E.
CI Workflow & Preview Deploy
.github/workflows/test.yml
Extend triggers/branch filters; split production vs preview build/deploy steps; conditionally run deploys; add preview deploy that outputs preview URL and comments/updates PR with the URL.
Tests
src/app/reset-password/ResetPasswordForm.test.tsx
Removed a previously skipped auto-redirect test; other tests unchanged.

Sequence Diagram(s)

sequenceDiagram
    participant Runner as CI/Test Runner
    participant Env as Environment
    participant Config as prisma.config.ts
    participant Lib as src/lib/prisma.ts
    participant PrismaCLI as Prisma CLI

    Runner->>Env: read CI, DB_FILE, DATABASE_URL, SHADOW_DATABASE_URL
    Env-->>Config: provide env values
    alt CI == "true"
        Note right of Config `#D6EAF8`: E2E mode (file DB)
        Config->>Lib: select schema "prisma-e2e/schema.prisma"
        Lib->>Lib: getPrismaE2E() → Prisma client(adapter: PrismaLibSql(file:DB_FILE))
    else
        Note right of Config `#F9E79F`: Dev/Prod mode (env DB)
        Config->>Lib: select schema "prisma-main/schema.prisma"
        Lib->>Lib: getPrismaMain() → Prisma client(adapter: PrismaMariaDb(DATABASE_URL))
    end
    Runner->>PrismaCLI: run `CI=true prisma generate` & `CI=true prisma db push --schema=...`
    PrismaCLI-->>Runner: generated client & applied schema
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Areas needing extra attention:
    • src/lib/prisma.ts — adapter integration, URL parsing, global singleton/typing and exported types.
    • prisma.config.ts — conditional schema/migrations/datasource correctness for Prisma CLI and seeds.
    • prisma schemas — generator/provider compatibility with Prisma v7.
    • E2E setup files (e2e/setup-e2e-db.js, src/test/global-setup.ts, src/test/setup-db.ts) — file paths, CI env usage, safe teardown and file permissions.
    • .github/workflows/test.yml — preview deploy outputs and PR comment/update logic.

Poem

🐇 I hopped through schemas and bumped the core,

Adapters stitched two clients, file and Maria door.
CI points to templates, runners scrub and write,
Previews bloom on PRs, tests wake up right,
A carrot-coded cheer for builds that take flight.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'migrate to prisma 7.0' directly and accurately summarizes the main change in the pull request, which involves upgrading Prisma from version 6.19.0 to 7.0.0 across dependencies and updating related configuration.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch prisma-7.0

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e3bc24 and f1074f4.

📒 Files selected for processing (1)
  • prisma.config.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • prisma.config.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: e2e-tests
  • GitHub Check: unit-integration-tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9d70ec1 and feac237.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • package.json (2 hunks)
  • prisma-e2e/schema.prisma (0 hunks)
  • prisma-main/schema.prisma (0 hunks)
  • prisma.config.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • prisma-e2e/schema.prisma
  • prisma-main/schema.prisma
🧰 Additional context used
🧬 Code graph analysis (1)
prisma.config.ts (1)
e2e/setup-e2e-db.js (1)
  • path (5-5)
🪛 GitHub Actions: Test & Deploy
prisma.config.ts

[warning] 1-1: Code style issues found by Prettier. Run 'npx prettier --write .' to fix.

🔇 Additional comments (1)
prisma.config.ts (1)

1-3: The import from prisma/config is valid. The Prisma Config reference documents defineConfig usage and options, including the env helper, confirming that both defineConfig and env are correct APIs for Prisma 7.0.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/test/global-setup.ts (1)

26-31: Confirm that implicit Prisma client generation in global test setup is desired

Dropping --skip-generate means every global test setup will now also run Prisma client generation for the temp schema, which adds work and may be redundant if the client is already generated elsewhere (and could differ slightly from your main config if the schema diverges over time). It’s worth double‑checking whether you actually need generation in this path; if not, consider re‑introducing --skip-generate here or removing any separate prisma generate step so you don’t pay for generation twice.

e2e/setup-e2e-db.js (1)

22-31: Avoid double Prisma client generation in E2E setup

With --skip-generate removed, prisma db push will now also run prisma generate, but you already call prisma generate just above. That means the client is generated twice on every E2E setup. Consider either dropping the explicit prisma generate call or restoring --skip-generate on db push, depending on which step you want to be the single source of truth.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d7a56a0 and 31725d0.

📒 Files selected for processing (2)
  • e2e/setup-e2e-db.js (1 hunks)
  • src/test/global-setup.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/test/global-setup.ts (1)
src/test/constants.ts (1)
  • TEMP_SCHEMA_PATH (4-7)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: e2e-tests

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
prisma.config.ts (1)

6-6: Inconsistent CI environment checks remain unfixed.

This issue was previously flagged but remains unresolved. Line 6 uses process.env.CI === 'true' (strict string equality) while line 14 uses process.env.CI (truthy check). This inconsistency will cause incorrect behavior when CI is set to values like '1', 'yes', or other truthy non-'true' strings, resulting in a datasource/schema mismatch.

Apply this diff to use consistent checking:

 export default defineConfig({
   datasource:
-    process.env.CI === 'true'
+    process.env.CI
       ? {
           url: process.env.DB_FILE ? process.env.DB_FILE : 'file:./prisma-main/test.db'
         }
       : {
           url: env('DATABASE_URL'),
           shadowDatabaseUrl: env('SHADOW_DATABASE_URL')
         },
   schema: path.join(process.env.CI ? 'prisma-e2e' : 'prisma-main', 'schema.prisma')
 });

Also applies to: 14-14

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 902b481 and cb01c61.

📒 Files selected for processing (6)
  • e2e/setup-e2e-db.js (1 hunks)
  • prisma.config.ts (1 hunks)
  • src/app/reset-password/ResetPasswordForm.test.tsx (0 hunks)
  • src/lib/prisma.ts (2 hunks)
  • src/test/constants.ts (1 hunks)
  • src/test/global-setup.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • src/app/reset-password/ResetPasswordForm.test.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • e2e/setup-e2e-db.js
  • src/test/global-setup.ts
🧰 Additional context used
🧬 Code graph analysis (2)
prisma.config.ts (1)
e2e/setup-e2e-db.js (1)
  • path (5-5)
src/test/constants.ts (1)
e2e/setup-e2e-db.js (1)
  • path (5-5)
🔇 Additional comments (2)
src/test/constants.ts (1)

4-5: LGTM!

Good refactor to extract the database file path as a reusable constant. This improves maintainability and allows the path to be referenced in other files.

src/lib/prisma.ts (1)

50-51: Import paths are correct for Prisma v7's custom generator configuration.

The paths ../../prisma-main/types/client and ../../prisma-e2e/types/client are correct. Both schema files define custom generator output paths:

  • prisma-main/schema.prisma: output = "../prisma-main/types"
  • prisma-e2e/schema.prisma: output = "../prisma-e2e/types"

Prisma v7 generates types into a client/ subdirectory within the specified output directory, so the import paths correctly target these generated locations. This is a valid monorepo setup with multiple Prisma schemas—the paths match the generator configuration exactly.

prisma.config.ts Outdated
datasource:
process.env.CI === 'true'
? {
url: process.env.DB_FILE ? process.env.DB_FILE : 'file:./prisma-main/test.db'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add file: prefix when using DB_FILE environment variable.

Based on src/test/constants.ts, DB_FILE is defined as 'prisma-e2e/template.db' without the file: protocol prefix. When this value is used directly as a Prisma datasource URL, it will be invalid. The URL should be formatted as file:./prisma-e2e/template.db for SQLite.

Apply this diff to add the proper prefix:

-          url: process.env.DB_FILE ? process.env.DB_FILE : 'file:./prisma-e2e/test.db'
+          url: process.env.DB_FILE ? `file:./${process.env.DB_FILE}` : 'file:./prisma-e2e/test.db'

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
prisma.config.ts around line 8: the DB_FILE env value may be
'prisma-e2e/template.db' (no protocol) which produces an invalid Prisma SQLite
URL; update the conditional to ensure the value used for url always includes the
'file:' protocol (and a './' relative prefix when appropriate) by checking if
process.env.DB_FILE starts with 'file:' and, if not, prepending 'file:./' to it;
keep the existing default 'file:./prisma-main/test.db' for the fallback.

⚠️ Potential issue | 🔴 Critical

Critical: Default datasource path mismatches selected schema.

When CI === 'true' but DB_FILE is not set, the code defaults to 'file:./prisma-main/test.db'. However, line 14 would select the prisma-e2e schema in this scenario. This creates a dangerous configuration where the datasource points to a prisma-main database but uses the prisma-e2e schema definition, which will cause runtime errors.

Apply this diff to fix the default path:

-          url: process.env.DB_FILE ? process.env.DB_FILE : 'file:./prisma-main/test.db'
+          url: process.env.DB_FILE ? process.env.DB_FILE : 'file:./prisma-e2e/test.db'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
url: process.env.DB_FILE ? process.env.DB_FILE : 'file:./prisma-main/test.db'
url: process.env.DB_FILE ? process.env.DB_FILE : 'file:./prisma-e2e/test.db'
🤖 Prompt for AI Agents
In prisma.config.ts around lines 8 to 14, the datasource default URL currently
falls back to 'file:./prisma-main/test.db' which mismatches the schema chosen
when CI === 'true' (prisma-e2e), causing dangerous cross-schema use; update the
fallback logic so when CI === 'true' and DB_FILE is unset the URL defaults to
'file:./prisma-e2e/test.db' (or otherwise compute the default path based on the
selected schema), ensuring the datasource file path always matches the selected
schema.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/test/setup-db.ts (1)

11-11: Consider removing redundant DATABASE_URL environment variable at line 11.

The environment variable is set but never used—all file system operations between line 11 and PrismaClient instantiation (lines 50-56) operate independently. Once PrismaClient is created with explicit datasources configuration, the env var becomes unused for the test flow.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7cc1165 and 3eb1626.

📒 Files selected for processing (1)
  • src/test/setup-db.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/test/setup-db.ts (2)
scripts/migration.js (1)
  • prisma (284-284)
src/test/constants.ts (1)
  • TEST_DB_PATH (6-6)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: e2e-tests
  • GitHub Check: unit-integration-tests
🔇 Additional comments (1)
src/test/setup-db.ts (1)

3-3: LGTM! Import path updated for Prisma 7.0.

The import path change from '../../prisma-e2e/types' to '../../prisma-e2e/types/client' aligns with the Prisma 7.0 migration and updated client type exports.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/lib/prisma.ts (2)

50-52: Imports and type re-export match Prisma 7 client layout; docs slightly stale

Switching to ../../prisma-main/types/client and ../../prisma-e2e/types/client (and re‑exporting from .../types/client) is consistent with the new Prisma client output. The top‑of‑file JSDoc still references ../../prisma-main/types / ../../prisma-e2e/types, which could be updated to mention .../types/client to avoid confusion for future readers.

If you rely on the Prisma 7 generator layout, please confirm the generated paths are indeed types/client in your build artifacts.

Also applies to: 62-62


91-99: Unify Prisma client typing for the global singleton and harden PrismaLibSql adapter creation

Two related points here:

  1. Typing of the global singleton vs. getPrisma return type
  • getPrisma now returns mainClient | e2eClient based on process.env.CI, but globalForPrisma.prisma is annotated as ReturnType<typeof getPrismaMain> only.
  • const prisma = globalForPrisma.prisma || getPrisma(); therefore has a union type, and assigning prisma back to globalForPrisma.prisma can become a TypeScript compatibility issue once e2eClient is involved.

Consider widening the global type to match getPrisma and making the property optional:

-const globalForPrisma = global as unknown as {
-  prisma: ReturnType<typeof getPrismaMain>;
-};
+type AppPrismaClient = ReturnType<typeof getPrisma>;
+
+const globalForPrisma = global as unknown as {
+  prisma?: AppPrismaClient;
+};
@@
-const prisma = globalForPrisma.prisma || getPrisma();
+const prisma: AppPrismaClient = globalForPrisma.prisma ?? getPrisma();

This keeps the singleton pattern but aligns the types with the actual runtime behavior.

  1. E2E adapter creation and DATABASE_URL handling
  • PrismaLibSql is instantiated at module load with url: process.env.DATABASE_URL ?? ''. That:
    • Constructs the adapter even when CI is false and you never use the e2e client.
    • Silently falls back to an empty URL if DATABASE_URL is misconfigured, which can hide setup errors.

It’s safer to build the adapter lazily and fail fast when DATABASE_URL is missing:

-import { PrismaLibSql } from '@prisma/adapter-libsql';
-
-const adapter = new PrismaLibSql({
-  url: process.env.DATABASE_URL ?? ''
-});
-
-export const getPrismaE2E = () => new e2eClient({ adapter });
+import { PrismaLibSql } from '@prisma/adapter-libsql';
+
+export const getPrismaE2E = () => {
+  const url = process.env.DATABASE_URL;
+  if (!url) {
+    throw new Error('DATABASE_URL must be set when using getPrismaE2E');
+  }
+  const adapter = new PrismaLibSql({ url });
+  return new e2eClient({ adapter });
+};

This confines adapter creation to the CI/e2e path and avoids silently using an invalid URL.

To confirm there are no type issues, you can run tsc --noEmit or next build and check for errors around globalForPrisma.prisma and authPrismaAdapter(prisma, ...). Also verify that your CI/e2e setup always sets DATABASE_URL before importing @/lib/prisma.

Also applies to: 108-108, 116-118, 140-142

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3eb1626 and 542626f.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • package.json (2 hunks)
  • src/lib/prisma.ts (3 hunks)
  • src/test/setup-db.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/setup-db.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: e2e-tests
  • GitHub Check: unit-integration-tests
🔇 Additional comments (1)
package.json (1)

40-41: Prisma packages are correctly placed and versions are aligned

@prisma/client and @prisma/adapter-libsql are in dependencies for runtime use, and prisma is in devDependencies for CLI/migrations. All three packages track ^7.0.0, confirming version alignment.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
prisma.config.ts (1)

5-15: Unify CI detection and fix datasource/schema & path mismatch.

There are still a few coupled issues here:

  1. Inconsistent CI check logic

    • Lines 7–10 use process.env.CI === 'true'.
    • Line 15 uses process.env.CI ? ... : ....

    This can select the prisma-e2e schema while using the non‑CI datasource (or vice versa) when CI is set to values like '1', 'TRUE', etc. Define a single isCI boolean and reuse it for both datasource and schema.

  2. Default CI datasource path mismatches schema

    • When CI === 'true' and DB_FILE is unset, the datasource url falls back to 'file:./prisma-main/test.db', but line 15 picks the prisma-e2e schema for truthy CI. That’s a dangerous mismatch.
  3. DB_FILE may be missing file: prefix

    • If DB_FILE is set to a bare path (for example prisma-e2e/test.db), passing it directly will produce an invalid SQLite URL. Normalizing it is safer.

You can address all three with something like:

-import 'dotenv/config';
-import path from 'node:path';
-import { defineConfig, env } from 'prisma/config';
-
-export default defineConfig({
-  datasource:
-    process.env.CI === 'true'
-      ? {
-          url: process.env.DB_FILE ? process.env.DB_FILE : 'file:./prisma-main/test.db'
-        }
-      : {
-          url: env('DATABASE_URL'),
-          shadowDatabaseUrl: env('SHADOW_DATABASE_URL')
-        },
-  schema: path.join(process.env.CI ? 'prisma-e2e' : 'prisma-main', 'schema.prisma')
-});
+import 'dotenv/config';
+import path from 'node:path';
+import { defineConfig, env } from 'prisma/config';
+
+const isCI = ['1', 'true', 'yes'].includes(String(process.env.CI ?? '').toLowerCase());
+
+const dbFileEnv = process.env.DB_FILE;
+const dbFileUrl =
+  dbFileEnv && dbFileEnv.startsWith('file:')
+    ? dbFileEnv
+    : dbFileEnv
+    ? `file:./${dbFileEnv}`
+    : 'file:./prisma-e2e/test.db';
+
+export default defineConfig({
+  datasource: isCI
+    ? {
+        url: dbFileUrl,
+      }
+    : {
+        url: env('DATABASE_URL'),
+        shadowDatabaseUrl: env('SHADOW_DATABASE_URL'),
+      },
+  schema: path.join(isCI ? 'prisma-e2e' : 'prisma-main', 'schema.prisma'),
+});

This keeps schema and datasource in lockstep and ensures the SQLite URL is valid in CI.

Confirm current Prisma 7 docs for `prisma.config.(ts|js)` regarding `datasource` URL formats (especially SQLite `file:` URLs) and recommended CI environment handling.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 542626f and 69ea1df.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • package.json (2 hunks)
  • prisma.config.ts (1 hunks)
  • src/lib/prisma.ts (4 hunks)
  • src/test/setup-db.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/setup-db.ts
🧰 Additional context used
🧬 Code graph analysis (2)
prisma.config.ts (1)
e2e/setup-e2e-db.js (1)
  • path (5-5)
src/lib/prisma.ts (1)
src/test/constants.ts (1)
  • TEST_DB_PATH (6-6)
🪛 GitHub Actions: Test & Deploy
src/lib/prisma.ts

[error] 105-105: Parsing error: ',' expected.

🔇 Additional comments (1)
package.json (1)

40-43: Dependency block aligns with adapter-based Prisma 7 setup.

The added adapter packages and the Prisma client/CLI version bumps are consistent with the new adapter‑based client instantiation elsewhere in the PR. I don’t see issues in this manifest segment.

Also applies to: 85-85

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
src/lib/prisma.ts (1)

73-83: Fix eager DATABASE_URL parsing and MariaDB adapter host/port handling

This still has two issues previously flagged in review comments:

  1. Module-scope new URL(process.env.DATABASE_URL as string)
    If DATABASE_URL is unset (typical in CI when only SQLite/e2e is used), importing this module will throw before getPrismaE2E can be used. URL parsing should be moved inside getPrismaMain with an explicit check for process.env.DATABASE_URL.

  2. Misuse of url.host and unsafe parseInt(url.port)
    url.host includes the port (e.g. "localhost:3306"), so passing it as host is incorrect. Also, when the URL omits a port, url.port is "", and parseInt(url.port) becomes NaN, which is not a valid adapter port.

A safer pattern is:

  • Lazily parse DATABASE_URL inside getPrismaMain.
  • Use url.hostname for the host.
  • Derive a numeric port only when present, and omit the field otherwise.

For example:

-import { PrismaMariaDb } from '@prisma/adapter-mariadb';
-
-const url = new URL(process.env.DATABASE_URL as string);
-
-const getPrismaMain = () =>
-  new mainClient({
-    adapter: new PrismaMariaDb({
-      host: url.host,
-      port: parseInt(url.port)
-    })
-  });
+import { PrismaMariaDb } from '@prisma/adapter-mariadb';
+
+const getPrismaMain = () => {
+  const databaseUrl = process.env.DATABASE_URL;
+  if (!databaseUrl) {
+    throw new Error('DATABASE_URL is not set');
+  }
+
+  const url = new URL(databaseUrl);
+  const port = url.port ? Number(url.port) : undefined;
+
+  return new mainClient({
+    adapter: new PrismaMariaDb({
+      host: url.hostname,
+      ...(port !== undefined ? { port } : {}),
+    }),
+  });
+};

This prevents CI/test imports from crashing and sends the adapter a clean hostname and numeric port.

Please double-check the Prisma MariaDB adapter docs for any additional required options (database name, user, password) and adjust the adapter config accordingly.

🧹 Nitpick comments (3)
e2e/setup-e2e-db.js (1)

3-15: E2E DB bootstrap with CI-based schema selection looks good (minor cleanup possible)

The header clearly explains the flow, and forcing CI: true for both prisma generate and prisma db push matches the prisma.config-based schema selection for the SQLite e2e schema. Only nit: dbUrl is now unused, so you can drop it to avoid confusion.

Also applies to: 37-41, 44-48

src/lib/prisma.ts (2)

92-100: Consider avoiding a test → app dependency in getPrismaE2E

getPrismaE2E imports TEST_DB_PATH from @/test/constants, which makes the main app library depend on a test-only module. This is workable since the constants file is simple, but it inverts the usual layering and could complicate production bundling if test code ever pulls in heavier dev-only dependencies.

If possible, consider either:

  • Moving getPrismaE2E and its constants into a test-only module (e.g. under src/test), or
  • Passing the DB path into getPrismaE2E from test code instead of importing test constants here.

52-53: Keep Prisma generator output paths aligned with these type imports

Both the client imports and the export * line assume that Prisma generates types at ../../prisma-main/types/client and ../../prisma-e2e/types/client. As you evolve prisma-main/prisma-e2e or change generator output paths, remember these imports need to stay in lockstep or you’ll get runtime import errors.

You might centralize these paths (e.g. via a small shared config module) so schema/generator changes can’t silently desync from this file.

Also applies to: 64-65

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 69ea1df and cbbf790.

📒 Files selected for processing (7)
  • e2e/setup-e2e-db.js (2 hunks)
  • prisma-e2e/schema.prisma (1 hunks)
  • prisma-main/schema.prisma (1 hunks)
  • prisma.config.ts (1 hunks)
  • src/lib/prisma.ts (5 hunks)
  • src/test/global-setup.ts (1 hunks)
  • src/test/setup-db.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • prisma-main/schema.prisma
  • src/test/setup-db.ts
  • prisma.config.ts
🧰 Additional context used
🧬 Code graph analysis (2)
src/test/global-setup.ts (1)
src/test/constants.ts (3)
  • TEMPLATE_DB_PATH (5-5)
  • SCHEMA_PATH (3-3)
  • DB_FILE (4-4)
src/lib/prisma.ts (1)
src/test/constants.ts (1)
  • TEST_DB_PATH (6-6)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: unit-integration-tests
  • GitHub Check: e2e-tests
🔇 Additional comments (2)
prisma-e2e/schema.prisma (1)

1-14: Schema documentation and Prisma 7 generator update look consistent

The CI/e2e-specific comments and the switch to provider = "prisma-client" with a SQLite datasource (URL delegated to prisma.config.ts) align with the new Prisma 7 + adapter-based setup. Just keep the “structurally identical to prisma-main/schema.prisma” note in sync if the main schema evolves.

Also applies to: 16-22

src/test/global-setup.ts (1)

11-20: Template DB creation flow via DB_FILE env is consistent and robust

The documented 3-step process (delete existing template, prisma db push with DB_FILE, then assert TEMPLATE_DB_PATH exists) is clear and matches the new constants setup. This should give predictable failures if prisma db push misconfigures the path, and teardown covers the main SQLite artifacts cleanly.

If you want extra safety, you can verify end-to-end by running tests once with DB_FILE intentionally mis-set to confirm the existence check fails as expected.

Also applies to: 29-38, 40-45

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
src/lib/prisma.ts (1)

73-83: Fix MariaDB adapter config: move URL parsing into getPrismaMain and use hostname + full credentials

The current MariaDB adapter wiring has a few problems:

  • const url = new URL((process.env.DATABASE_URL as string) ?? 'mysql://localhost:3306'); runs at module load, even in CI where only SQLite is needed, and silently falls back to a dummy URL instead of surfacing a missing DATABASE_URL.
  • host: url.host passes "hostname:port" instead of just the hostname; Prisma’s examples use a plain hostname and numeric port. (prisma.io)
  • Only host and port are passed; the official adapter README shows specifying user/password/database (or, alternatively, using a parsed connection string). (glama.ai)

Recommend:

  1. Parse DATABASE_URL inside getPrismaMain.
  2. Throw a clear error if DATABASE_URL is missing when getPrismaMain is actually invoked.
  3. Use url.hostname and a safely-parsed port, and ideally derive user/password/database from the URL.

Example:

-import { PrismaMariaDb } from '@prisma/adapter-mariadb';
-
-const url = new URL((process.env.DATABASE_URL as string) ?? 'mysql://localhost:3306');
-
-const getPrismaMain = () =>
-  new mainClient({
-    adapter: new PrismaMariaDb({
-      host: url.host,
-      port: parseInt(url.port)
-    })
-  });
+import { PrismaMariaDb } from '@prisma/adapter-mariadb';
+
+const getPrismaMain = () => {
+  const databaseUrl = process.env.DATABASE_URL;
+  if (!databaseUrl) {
+    throw new Error('DATABASE_URL is not set (required for main MySQL/MariaDB Prisma client)');
+  }
+
+  const url = new URL(databaseUrl);
+  const port = url.port ? Number(url.port) : undefined;
+  const username = url.username || undefined;
+  const password = url.password || undefined;
+  const database = url.pathname ? url.pathname.slice(1) || undefined : undefined;
+
+  return new mainClient({
+    adapter: new PrismaMariaDb({
+      host: url.hostname,
+      ...(port ? { port } : {}),
+      ...(username ? { user: decodeURIComponent(username) } : {}),
+      ...(password ? { password: decodeURIComponent(password) } : {}),
+      ...(database ? { database } : {}),
+    }),
+  });
+};

This matches the adapter’s documented configuration style and avoids hidden defaults or malformed host values.

Confirm that for `@prisma/adapter-mariadb` v7 / Prisma ORM 7, the recommended configuration pattern still uses either `{ host, port, user, password, database }` or a parsed `DATABASE_URL`, and that `url.hostname` (not `url.host`) is the correct value to pass as the `host` option.
🧹 Nitpick comments (1)
src/lib/prisma.ts (1)

111-112: Environment-based client selection and singleton typing are solid

  • getPrisma switching on process.env.CI correctly routes between main and E2E clients per the docs.
  • Typing globalForPrisma.prisma as ReturnType<typeof getPrisma> is a clean way to keep the singleton’s type in sync with the factory.

If you ever introduce more environments (e.g. local dev SQLite), consider abstracting the env switch to a small helper, but it’s not necessary now.

Also applies to: 120-121

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ebf4668 and 60fd7fc.

📒 Files selected for processing (2)
  • prisma.config.ts (1 hunks)
  • src/lib/prisma.ts (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • prisma.config.ts
🧰 Additional context used
🧬 Code graph analysis (1)
src/lib/prisma.ts (1)
src/test/constants.ts (1)
  • DB_FILE (4-4)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: unit-integration-tests
  • GitHub Check: e2e-tests
🔇 Additional comments (4)
src/lib/prisma.ts (4)

8-17: Docs correctly describe new multi-schema + adapter setup

Documentation now accurately reflects prisma-main/prisma-e2e split, adapter usage, and the “wrong import” example path. No issues here.

Also applies to: 28-29


52-53: Type re-exports and client imports look consistent

Importing PrismaClient from prisma-main / prisma-e2e and re-exporting all types from prisma-main cleanly centralizes typing behind this module, matching the comments’ intent. Looks good.

Also applies to: 64-64


169-172: Auth adapter wiring matches runtime DB selection

Configuring authPrismaAdapter once with provider: process.env.CI ? 'sqlite' : 'mysql' keeps Better Auth in sync with whichever Prisma client is active. This is consistent with the rest of the module.


87-90: E2E SQLite client via LibSQL adapter is correctly configured

The code pattern using PrismaLibSql({ url: \file:./${DB_FILE}` })is confirmed to work with@prisma/adapter-libsqlin Prisma ORM 7 for local/embedded SQLite databases without requiring anauthToken`.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
src/lib/prisma.ts (1)

73-82: Fix MariaDB adapter config: use hostname, safe port handling, and a clear DATABASE_URL check

Right now:

  • host: url.host includes both hostname and port (for example db:3306), which is not a valid hostname and can break DNS resolution.
  • parseInt(url.port) will be NaN when the URL omits an explicit port, and that NaN is passed straight to the adapter.
  • If DATABASE_URL is missing, new URL(process.env.DATABASE_URL as string) throws a generic “Invalid URL” instead of a clear configuration error.

Prisma’s own MySQL/MariaDB adapter examples show passing a plain hostname and numeric port into PrismaMariaDb’s options.(prisma.io)

Suggest tightening this function as follows:

-const getPrismaMain = () => {
-  const url = new URL(process.env.DATABASE_URL as string);
-  const adapter = new PrismaMariaDb({
-    host: url.host,
-    port: parseInt(url.port)
-  });
-  return new mainClient({ adapter });
-}
+const getPrismaMain = () => {
+  const databaseUrl = process.env.DATABASE_URL;
+  if (!databaseUrl) {
+    throw new Error('DATABASE_URL is not set');
+  }
+
+  const url = new URL(databaseUrl);
+  const port = url.port ? Number.parseInt(url.port, 10) : undefined;
+
+  const adapter = new PrismaMariaDb({
+    host: url.hostname,
+    ...(port && !Number.isNaN(port) ? { port } : {}),
+  });
+
+  return new mainClient({ adapter });
+};

This avoids malformed hosts, skips passing a bogus port, and fails fast with a clear message if DATABASE_URL is misconfigured.

🧹 Nitpick comments (1)
src/lib/prisma.ts (1)

118-120: Consider using globalThis and an optional prisma field for the singleton

The current singleton wiring works, but it hard-casts global and treats prisma as always-present in the type:

const globalForPrisma = global as unknown as {
  prisma: ReturnType<typeof getPrisma>;
};

const prisma = globalForPrisma.prisma || getPrisma();

For slightly safer and more portable code (Node + edge / different runtimes), you could:

  • Use globalThis instead of global.
  • Make prisma optional in the type and use ?? for the fallback.

Example:

-const globalForPrisma = global as unknown as {
-  prisma: ReturnType<typeof getPrisma>;
-};
+const globalForPrisma = globalThis as unknown as {
+  prisma?: ReturnType<typeof getPrisma>;
+};
@@
-const prisma = globalForPrisma.prisma || getPrisma();
+const prisma = globalForPrisma.prisma ?? getPrisma();

This keeps runtime behavior the same while better reflecting the actual lifecycle of the cached instance.

Also applies to: 142-144

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60fd7fc and ca2ea9a.

📒 Files selected for processing (1)
  • src/lib/prisma.ts (5 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/lib/prisma.ts (1)
src/test/constants.ts (1)
  • DB_FILE (4-4)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: unit-integration-tests
  • GitHub Check: e2e-tests
🔇 Additional comments (3)
src/lib/prisma.ts (3)

8-29: Docs accurately describe new adapter-based dual-schema setup

The updated module doc (dependencies list, CI SQLite vs prod MySQL/MariaDB explanation, and “correct vs wrong” import examples) matches the new adapter-backed architecture and reinforces the intended public API (@/lib/prisma only). No changes needed here.


52-65: Import/re-export wiring for Prisma clients and types looks consistent

Using separate generated clients for prisma-main and prisma-e2e while re-exporting all types from prisma-main keeps runtime concerns (engine choice) decoupled from the public typing surface, which is exactly what your docs above promise. This setup is coherent and should work well as long as both schemas remain structurally identical.


91-99: LibSQL E2E client wiring matches Prisma’s file-based SQLite pattern

getPrismaE2E using new PrismaLibSql({ url: process.env.DB_FILE ?? \file:./${DB_FILE}` })aligns with the documented pattern for file-backed SQLite/LibSQL adapters (for example,url: "file:./prisma/dev.db").([prisma.io](https://www.prisma.io/docs/concepts/database-connectors/sqlite?utm_source=openai)) The DB_FILE` constant keeps the default in sync with test helpers, and the env override gives CI flexibility. No changes needed here.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
src/lib/prisma.ts (1)

73-82: Fix MariaDB adapter host/port parsing and add a clearer DATABASE_URL validation.

getPrismaMain still has two issues:

  • host: url.host passes "hostname:port" to PrismaMariaDb, while Prisma docs show host should be just the hostname, with port as a separate numeric field. (prisma.io)
  • parseInt(url.port) will be NaN if the URL omits an explicit port, which can break otherwise valid DATABASE_URL values.

You already moved URL parsing inside getPrismaMain, so CI no longer crashes when using the SQLite client. To finish this off, I’d recommend:

  • Validate DATABASE_URL explicitly for a clearer error.
  • Use url.hostname and only pass port when it exists and parses cleanly.

Example diff:

-const getPrismaMain = () => {
-  const url = new URL(process.env.DATABASE_URL as string);
-  const adapter = new PrismaMariaDb({
-    host: url.host,
-    port: parseInt(url.port)
-  });
-  return new mainClient({ adapter });
-};
+const getPrismaMain = () => {
+  const databaseUrl = process.env.DATABASE_URL;
+  if (!databaseUrl) {
+    throw new Error('DATABASE_URL is not set');
+  }
+
+  const url = new URL(databaseUrl);
+  const port = url.port ? parseInt(url.port, 10) : undefined;
+
+  const adapter = new PrismaMariaDb({
+    host: url.hostname,
+    ...(port ? { port } : {}),
+  });
+
+  return new mainClient({ adapter });
+};

This aligns with the PrismaMariaDb examples (hostname + numeric port) and avoids NaN/URL edge cases. (prisma.io)

Please double‑check this against the current @prisma/adapter-mariadb docs you’re targeting to ensure the option shape remains correct.

🧹 Nitpick comments (2)
src/lib/prisma.ts (1)

91-99: LibSQL adapter wiring looks correct; consider decoupling test constants from app lib.

Functionally this is good:

  • PrismaLibSql is instantiated with a { url } options object, which matches the current adapter API. (prisma.io)
  • Defaulting to file:./${DB_FILE} keeps the runtime path in sync with the test constants.

Two minor suggestions:

  1. Decouple from @/test/constants: Importing from src/test inside src/lib couples production code to test-only modules. Consider moving DB_FILE (and related path constants) into a shared non-test module (e.g., src/lib/db-constants) and importing from there in both prisma.ts and test utilities.

  2. Make DB_FILE semantics explicit: In a follow-up, it might be worth a short comment indicating that process.env.DB_FILE is expected to be a full LibSQL/SQLite URL (including file:), while the constant is a relative path, to avoid accidental use of a bare filename in env.

If you update the adapter options in line with future @prisma/adapter-libsql releases, please re-verify that url: file:./... remains the recommended pattern for local SQLite databases.

src/test/constants.ts (1)

4-7: DB path constants look good; consider deriving the journal path from DB_FILE.

Centralizing DB_FILE and TEMPLATE_DB_FILE and then building TEMPLATE_DB_PATH / TEST_DB_PATH from them is a nice cleanup and keeps filesystem paths in sync across tests and setup scripts.

As a minor follow-up, you could also derive the journal path from DB_FILE to avoid one remaining hard-coded filename, e.g.:

export const TEST_DB_JOURNAL_PATH = path.resolve(
  __dirname,
  `../../${DB_FILE}-journal`
);

Not required, but it would make renaming DB_FILE safer in the future.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ca2ea9a and 459da86.

📒 Files selected for processing (6)
  • .github/workflows/test.yml (5 hunks)
  • e2e/setup-e2e-db.js (2 hunks)
  • src/lib/prisma.ts (5 hunks)
  • src/test/constants.ts (1 hunks)
  • src/test/global-setup.ts (1 hunks)
  • src/test/setup-db.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/test/setup-db.ts
  • e2e/setup-e2e-db.js
🧰 Additional context used
🧬 Code graph analysis (3)
src/test/global-setup.ts (1)
src/test/constants.ts (3)
  • TEMPLATE_DB_PATH (6-6)
  • SCHEMA_PATH (3-3)
  • TEMPLATE_DB_FILE (5-5)
src/test/constants.ts (1)
e2e/setup-e2e-db.js (1)
  • path (19-19)
src/lib/prisma.ts (1)
src/test/constants.ts (1)
  • DB_FILE (4-4)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: e2e-tests
  • GitHub Check: unit-integration-tests
🔇 Additional comments (9)
.github/workflows/test.yml (4)

5-7: Branch filter restricts workflow to master.

Good move to limit test & deploy runs to the master branch, reducing unnecessary CI load on feature branches.


203-203: Deploy condition correctly prevents fork PR deployments.

The condition properly gates deployment: prevents fork PRs while allowing pushes to master and manual workflow triggers. The branch filter on the push event (line 6) adds another layer of protection.


216-243: Production/preview deployment separation is well-structured.

The workflow cleanly separates production deployments (master pushes with --prod flag and alias setup) from preview deployments (pull requests with standard build). Each path has appropriate conditions and the preview build captures the URL for downstream use.


245-288: PR comment automation is functional; bot detection is reasonable.

The workflow correctly uses context.issue.number for pull request context and properly references the preview URL from the preceding deploy step. The bot comment detection (searching for 'Bot' user type and 'Preview Deployment' text) is practical, though could be more precise by checking for the 'github-actions' bot specifically. This is an acceptable balance between simplicity and accuracy for this use case.

src/lib/prisma.ts (3)

8-29: Doc updates for dual-schema Prisma setup look consistent.

The JSDoc accurately reflects the new main/e2e schema layout, adapter usage, and the recommended import pattern via @/lib/prisma. No issues here.


52-53: Importing schema-specific clients and re‑exporting types is solid.

Using PrismaClient aliases from prisma-main / prisma-e2e and re‑exporting everything from prisma-main gives a single canonical type surface while still allowing engine-specific clients behind the scenes. This is a clean abstraction.

Also applies to: 64-64


118-120: Singleton typing for globalForPrisma is acceptable for this pattern.

Using ReturnType<typeof getPrisma> for the global prisma instance keeps the union of main/e2e clients in sync with the factory. Given the explicit type assertion on global, this is consistent with common Prisma singleton patterns.

src/test/global-setup.ts (2)

11-20: Global setup documentation matches the new template DB flow.

The JSDoc clearly explains the three-step template DB process and aligns with the current implementation, which helps future maintainers understand why the schema push happens once up front.


40-42: Template DB existence check and logging look good.

Verifying TEMPLATE_DB_PATH after the prisma db push and throwing if it’s missing gives a clear failure mode, and the success log is helpful for diagnosing setup issues.

Also applies to: 44-44

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
src/test/global-setup.ts (1)

11-20: Fix comments to reference DB_FILE (not TEMPLATE_DB_FILE) and describe actual behavior.

The implementation uses the DB_FILE environment variable:

env: {
  ...process.env,
  DB_FILE: `file:./${TEMPLATE_DB_FILE}`
}

but both the doc block (step 2) and the inline comments still talk about a TEMPLATE_DB_FILE env var. That’s misleading for future maintainers.

Suggested wording:

- * 2. Runs prisma db push with TEMPLATE_DB_FILE env to create template database
+ * 2. Runs prisma db push with DB_FILE env pointing to TEMPLATE_DB_FILE to create the template database
@@
-  // Use TEMPLATE_DB_FILE environment variable for database path
-  // prisma.config.ts reads TEMPLATE_DB_FILE when CI=true to determine database location
+  // Use DB_FILE environment variable for the database path (pointing at TEMPLATE_DB_FILE)
+  // prisma.config.ts reads DB_FILE in CI/test mode to determine the SQLite database location

Optionally, you might also switch stdio: 'pipe' to 'inherit' during prisma db push when you’re debugging, to get CLI output in the test logs, but the current setting is fine for CI.

Also applies to: 29-38

🧹 Nitpick comments (3)
e2e/setup-e2e-db.js (1)

21-48: Optional: explicitly wire DB_FILE for Prisma CLI instead of relying on the config fallback.

Right now these prisma generate / prisma db push calls depend on the CI branch in prisma.config.ts defaulting to file:./prisma-e2e/test.db. To make the script self‑contained and future‑proof (and reuse the computed dbFile), you could pass DB_FILE explicitly:

-const dbFile = path.join(__dirname, '../prisma-e2e/test.db');
+const dbFile = path.join(__dirname, '../prisma-e2e/test.db');
+const dbUrl = `file:${dbFile}`;
@@
-execSync('npx prisma generate --schema=prisma-e2e/schema.prisma', {
-  stdio: 'inherit',
-  env: { ...process.env, CI: true }
-});
+execSync('npx prisma generate --schema=prisma-e2e/schema.prisma', {
+  stdio: 'inherit',
+  env: { ...process.env, CI: true, DB_FILE: dbUrl }
+});
@@
-execSync('npx prisma db push --schema=prisma-e2e/schema.prisma', {
-  stdio: 'inherit',
-  env: { ...process.env, CI: true }
-});
+execSync('npx prisma db push --schema=prisma-e2e/schema.prisma', {
+  stdio: 'inherit',
+  env: { ...process.env, CI: true, DB_FILE: dbUrl }
+});

This keeps the DB URL used by the CLI aligned with the file you just cleaned up, even if the Prisma config’s default ever changes.

src/test/setup-db.ts (1)

3-4: Test DB setup is consistent with getPrismaE2E; consider tightening error handling in cleanDatabase.

The flow of:

  • setting process.env.DB_FILE = \file:${DB_FILE}``,
  • copying TEMPLATE_DB_PATHTEST_DB_PATH,
  • then creating the client via getPrismaE2E()

keeps the adapter URL and the physical test DB file in sync, which is exactly what you want for fast, file‑based tests.

One small optional improvement: cleanDatabase() wraps all deletes in a single try and swallows any error. If a real connection/config issue occurs, tests might silently reuse stale data. You could, for example, rethrow non‑“table not found” / non‑schema errors or at least log them at console.error while still ignoring missing‑table cases.

Also applies to: 21-22, 60-62

prisma.config.ts (1)

1-11: Clarify CI / DB_FILE expectations in the config comment to match current behavior.

The runtime behavior here is:

  • Any truthy process.env.CI selects the prisma-e2e schema/migrations.
  • DB_FILE is treated as a complete SQLite URL (e.g. file:./prisma-e2e/test.db), with a sane default if it’s unset.

The header comment still reads as if CI must literally be "true" and doesn’t spell out that DB_FILE is a full URL, not just a path. To avoid future confusion/misconfiguration, you might tweak the doc like:

- * - CI=true: Uses SQLite schema (prisma-e2e/schema.prisma) for testing
+ * - CI set: Uses SQLite schema (prisma-e2e/schema.prisma) for testing
@@
- * Database URLs are configured via environment variables (DATABASE_URL) or
- * DB_FILE for test environments.
+ * Database URLs are configured via environment variables:
+ * - DATABASE_URL / SHADOW_DATABASE_URL for MySQL (dev/prod)
+ * - DB_FILE (full SQLite URL, e.g. "file:./prisma-e2e/test.db") for CI/test

No functional changes needed; this just documents the current invariants more precisely so future scripts don’t start passing a bare path into DB_FILE.

Also applies to: 15-25

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 459da86 and 8e3bc24.

📒 Files selected for processing (6)
  • .github/workflows/test.yml (5 hunks)
  • e2e/setup-e2e-db.js (2 hunks)
  • prisma.config.ts (1 hunks)
  • src/test/constants.ts (1 hunks)
  • src/test/global-setup.ts (1 hunks)
  • src/test/setup-db.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/constants.ts
🧰 Additional context used
🧬 Code graph analysis (2)
src/test/setup-db.ts (2)
src/lib/prisma.ts (1)
  • getPrismaE2E (94-99)
src/test/constants.ts (1)
  • DB_FILE (4-4)
src/test/global-setup.ts (1)
src/test/constants.ts (3)
  • TEMPLATE_DB_PATH (6-6)
  • SCHEMA_PATH (3-3)
  • TEMPLATE_DB_FILE (5-5)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: unit-integration-tests
  • GitHub Check: e2e-tests
🔇 Additional comments (2)
.github/workflows/test.yml (2)

141-147: E2E DB_FILE wiring looks consistent with Prisma/test setup.

Using DB_FILE: 'file:./prisma-e2e/test.db' here aligns with the CI branch in prisma.config.ts and the getPrismaE2E fallback, so the Playwright run should hit the same SQLite file as your Vitest setup. No issues from a workflow perspective.


202-288: Deploy job split between production and preview is structured well.

The if on the job plus the per‑step if conditions cleanly separate:

  • production pulls/builds/deploys only on push to master
  • preview pulls/builds/deploys only for pull_request
  • PR comment with preview URL is updated or created idempotently.

This is a solid pattern for visibility without over‑deploying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants