Skip to content

Refactor: Migrate from MongoDB Node.js Driver to Prisma - #28

Merged
ByteKatana merged 48 commits into
mainfrom
refactor/migrate-to-prisma
Jul 25, 2026
Merged

Refactor: Migrate from MongoDB Node.js Driver to Prisma#28
ByteKatana merged 48 commits into
mainfrom
refactor/migrate-to-prisma

Conversation

@ByteKatana

Copy link
Copy Markdown
Owner

Closes #27

Key Changes
🛢️ Database & Schema

  • New Schema: Introduced prisma/schema.prisma defining models for User, Entry, EntryType, ApiKey, PermissionGroup, Settings, VerificationToken, and ApiRequestLog.
  • Collection Mapping: Configured models to map directly to existing MongoDB collections using @@Map.
  • Client Initialization: Added a centralized Prisma client in lib/prisma.ts.
  • Cleanup: Removed the legacy lib/mongodb.ts and all associated native driver configurations.

🗄️ Controllers & Server Actions

  • Controller Refactor: Migrated all core controllers (UserController, EntryController, EntryTypeController, ApiKeyController, PermissionGroupController) to use prisma queries.
  • Actions Update: Refactored server-side actions in lib/actions/studio/ to leverage Prisma's type-safe API.
  • Setup Logic: Updated app/setup/setup-action.ts to handle initial database provisioning via Prisma.

🧪 Testing Infrastructure

  • Enhanced Mocks: Updated lib/mocks/prisma.ts with comprehensive mocks for findFirst, findMany, deleteMany, update, and create.
  • Test Migration: Updated over 40 test files to align with the Prisma implementation, ensuring no regressions in business logic.
  • Environment: Adjusted jest.setup.ts and jest.config.ts to support the new database layer.

…pe.controller.test.ts` and add mocks for Prisma, API controllers, and utilities for improved test isolation
@ByteKatana ByteKatana self-assigned this Jul 25, 2026
@ByteKatana ByteKatana added the type/refactoring Code quality and restructuring label Jul 25, 2026
@ByteKatana ByteKatana linked an issue Jul 25, 2026 that may be closed by this pull request
8 tasks
@CLAassistant

CLAassistant commented Jul 25, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codacy-production

codacy-production Bot commented Jul 25, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 437 complexity · 163 duplication

Metric Results
Complexity 437
Duplication 163

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@ByteKatana
ByteKatana merged commit c16d159 into main Jul 25, 2026
3 checks passed
@ByteKatana ByteKatana added the status/done Completed and merged/deployed label Jul 25, 2026
@ByteKatana
ByteKatana deleted the refactor/migrate-to-prisma branch July 25, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/done Completed and merged/deployed type/refactoring Code quality and restructuring

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Switch to Prisma as ORM/ODM solution.

2 participants