Skip to content

Migrate from Prisma to Drizzle ORM#17

Draft
Copilot wants to merge 7 commits intomainfrom
copilot/migrate-db-to-drizzle
Draft

Migrate from Prisma to Drizzle ORM#17
Copilot wants to merge 7 commits intomainfrom
copilot/migrate-db-to-drizzle

Conversation

Copy link

Copilot AI commented Feb 7, 2026

Migration Plan: Prisma to Drizzle ORM

Understanding

The project currently uses:

  • Prisma ORM with PostgreSQL database
  • Neon serverless database adapter
  • 4 models: User, AttendanceRoom, AttendanceRecord, Attendant
  • Multiple server actions using Prisma client
  • Prisma-specific error handling

Migration Checklist

  • Install Drizzle dependencies (drizzle-orm, drizzle-kit, postgres)
  • Create Drizzle schema file based on existing Prisma schema
  • Create Drizzle configuration file (drizzle.config.ts)
  • Create database client file with Drizzle setup
  • Migrate all database queries from Prisma to Drizzle:
    • src/lib/auth.ts - User queries
    • src/app/(internal)/(protected)/actions.tsx - AttendanceRoom CRUD
    • src/app/(internal)/(protected)/(sidebar)/attendance/[id]/actions.tsx - Room and record queries
    • src/app/(public)/attendance/[id]/take/actions.tsx - Attendant and record operations
  • Update error handling to replace Prisma-specific errors
  • Update package.json scripts (remove prisma generate/migrate, add drizzle scripts)
  • Fix all TypeScript compilation errors
  • Update all test files to use Drizzle ORM
  • Remove Prisma dependencies and files (prisma, @prisma/client, @prisma/adapter-neon)
  • Update component files to use Drizzle types
  • Address code review feedback
  • Use pnpm instead of npm (removed package-lock.json, updated pnpm-lock.yaml)

Summary

Successfully migrated the entire codebase from Prisma to Drizzle ORM:

  • Replaced all Prisma queries with Drizzle equivalents
  • Updated error handling to use PostgreSQL error codes
  • Migrated all tests to use Drizzle
  • Removed all Prisma dependencies and files
  • Fixed all TypeScript compilation errors
  • Used proper SQL COUNT aggregate functions
  • Improved variable naming for clarity
  • Updated to use pnpm package manager as per project convention
Original prompt

Migrate the db to use drizzle instead of postgresdb


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link

vercel bot commented Feb 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dashboard-chainlab Error Error Feb 7, 2026 8:07pm

Request Review

Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
Copilot AI changed the title [WIP] Migrate database to use drizzle instead of postgresdb Migrate from Prisma to Drizzle ORM Feb 7, 2026
Copilot AI requested a review from sirily11 February 7, 2026 19:48
@sirily11
Copy link
Contributor

sirily11 commented Feb 7, 2026

@copilot use pnpm, not npm. Delete your npm lock file

Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 7, 2026

@copilot use pnpm, not npm. Delete your npm lock file

Done! Removed package-lock.json and updated pnpm-lock.yaml with the Drizzle dependencies. (commit: 7437b06)

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants