CelestiumX / CelestiumX/SkillChain-Backend

Integrate Prisma ORM with Current Database Schema

Open
#6 1 comment 0 reactions 0 assignees View on GitHub
good first issue Manteiner:Yuli Non-rewarded ODHack13
Dominant language
TypeScript
Stars
0
Forks
1
PR merge metrics
No merged PRs in 30d

Description

## 📚 Overview
Integrate Prisma ORM with the current PostgreSQL schema to enable type-safe database queries, reduce boilerplate code, and improve maintainability.

If you need coordination or clarification, use the project’s [[Telegram Group](https://t.me/+YZEXOc_LOzIyYTgx)](https://t.me/+YZEXOc_LOzIyYTgx).

---

## 🔍 Background
The project currently uses raw SQL or another ORM approach. Switching to Prisma offers a more developer-friendly interface, auto-completion, type-checking, and improved schema evolution support.

---

## 🛠 Requirements
- Install Prisma and initialize the configuration:
```bash
npm install prisma --save-dev
npx prisma init
```
- Connect to the existing PostgreSQL database by configuring `DATABASE_URL` in the `.env` file.
- Use Prisma introspection to generate the schema from the current database:
```bash
npx prisma db pull
```
- Verify and adjust the `schema.prisma` file as needed.
- Generate the Prisma Client:
```bash
npx prisma generate
```
- Replace raw SQL queries or previous ORM logic with Prisma in the data access layer (e.g., `ServiceManager`, `UserManager`, etc.).
- Update existing unit tests to work with Prisma or add new ones where missing.

---

## 🔧 Implementation Plan

### 1. Create Feature Branch
```bash
git checkout -b feature-integrate-prisma-[issue-number]
```

### 2. Setup and Introspect
- Configure `.env` and run `npx prisma db pull`
- Inspect and refactor `schema.prisma` as needed

### 3. Generate Client
- Run `npx prisma generate`

### 4. Integrate ORM Logic
- Refactor DB logic using Prisma Client
- Use type-safe queries for all CRUD operations

### 5. Testing
- Unit tests to validate Prisma queries (≥ 90% coverage)
- Test common operations: insert, update, search, and delete

### 6. Commit and Push
```bash
git add .
git commit -m "Feature: Prisma ORM integration with PostgreSQL"
git push origin feature-integrate-prisma-[issue-number]
```

---

## ✅ Definition of Done
- [ ] Prisma initialized and connected to PostgreSQL
- [ ] `schema.prisma` generated from the database
- [ ] Prisma Client queries replace existing DB logic
- [ ] Unit test coverage ≥ 90%
- [ ] Pull request meets template standards

---

## 📆 Timeframe
2 days

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the current database access code, especially ServiceManager and UserManager, then inspect the existing PostgreSQL schema. Follow the listed Prisma setup, introspection, and generation commands to produce schema.prisma and the Prisma Client. Done means database logic uses Prisma, tests cover insert, update, search, and delete operations, and coverage reaches at least 90%.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, typescript
Domain
backend, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.