fairdataihub / codefair-app

Your coding assistant to make research software reusable without breaking a sweat!
https://codefair.io
MIT License
7 stars 2 forks source link

refactor: ♻️ ✨ Convert MongoDB to Prisma Postgres #68

Closed slugb0t closed 1 month ago

slugb0t commented 1 month ago

Summary by Sourcery

Migrate the database layer from MongoDB to PostgreSQL using Prisma as the ORM. This involves refactoring database operations throughout the codebase to use Prisma's API, updating data models, and adding necessary dependencies for Prisma. Additionally, scripts are introduced to facilitate data migration from MongoDB to PostgreSQL.

New Features:

Enhancements:

Build:

Chores:

fairdataihub-bot[bot] commented 1 month ago

Thank you for submitting this pull request! We appreciate your contribution to the project. Before we can merge it, we need to review the changes you've made to ensure they align with our code standards and meet the requirements of the project. We'll get back to you as soon as we can with feedback. Thanks again!

sourcery-ai[bot] commented 1 month ago

Reviewer's Guide by Sourcery

This pull request refactors the codebase to replace MongoDB with Prisma and PostgreSQL as the database solution. The changes involve updating database operations, modifying schema definitions, and adjusting API endpoints to work with the new Prisma client.

File-Level Changes

Change Details Files
Replace MongoDB with Prisma and PostgreSQL
  • Update database connection and initialization
  • Modify database queries to use Prisma client
  • Update schema definitions for Prisma
  • Adjust API endpoints to work with Prisma
  • Implement new error handling for database operations
  • Update authentication logic to use Prisma adapter
  • Create migration script for transferring data from MongoDB to PostgreSQL
bot/index.js
ui/server/api/codeMetadata/[identifier]/index.post.ts
ui/server/utils/auth.ts
bot/utils/tools/index.js
bot/metadata/index.js
ui/server/api/dashboard/[owner]/[repo]/index.get.ts
bot/cwl/index.js
ui/server/api/cwlValidation/[identifier]/rerun.post.ts
bot/utils/renderer/index.js
bot/license/index.js
ui/server/api/license/[identifier]/index.put.ts
ui/server/routes/login/github/callback.get.ts
ui/server/api/dashboard/[owner]/index.get.ts
ui/server/api/codeMetadata/[identifier]/index.put.ts
bot/db.js
ui/server/api/cwlValidation/[identifier]/index.get.ts
ui/server/api/license/[identifier]/index.get.ts
ui/server/api/codeMetadata/[identifier]/index.get.ts
ui/server/api/dashboard/[owner]/[repo]/rerun.post.ts
ui/server/api/user.get.ts
bot/scripts/prismaM.ts
ui/server/utils/prisma.ts
bot/transfer-postgres.js
Update data models and schema
  • Modify existing data models to match Prisma schema
  • Update field names to follow Prisma conventions
  • Add new fields and relationships in Prisma schema
bot/index.js
ui/server/utils/auth.ts
bot/utils/tools/index.js
bot/metadata/index.js
ui/server/api/dashboard/[owner]/[repo]/index.get.ts
bot/cwl/index.js
bot/utils/renderer/index.js
bot/license/index.js
ui/server/routes/login/github/callback.get.ts
ui/server/api/dashboard/[owner]/index.get.ts
ui/server/api/codeMetadata/[identifier]/index.put.ts
ui/server/api/cwlValidation/[identifier]/index.get.ts
ui/server/api/license/[identifier]/index.get.ts
ui/server/api/codeMetadata/[identifier]/index.get.ts
ui/server/api/user.get.ts
Implement data migration strategy
  • Create script for transferring data from MongoDB to PostgreSQL
  • Implement data transformation logic for different collections
  • Add error handling and logging for migration process
bot/scripts/prismaM.ts
bot/transfer-postgres.js
Update dependencies and configuration
  • Add Prisma and @prisma/client dependencies
  • Remove MongoDB-related dependencies
  • Update pnpm-lock.yaml with new dependency versions
pnpm-lock.yaml

Sequence Diagrams

Database Operation Flow

sequenceDiagram
    participant A as Application
    participant P as Prisma Client
    participant DB as PostgreSQL
    A->>P: Make database query
    P->>DB: Execute SQL query
    DB-->>P: Return query results
    P-->>A: Return formatted data

Authentication Flow

sequenceDiagram
    participant U as User
    participant A as Auth Handler
    participant P as Prisma Adapter
    participant DB as PostgreSQL
    U->>A: Login request
    A->>P: Verify credentials
    P->>DB: Query user data
    DB-->>P: Return user data
    P-->>A: User verification result
    A-->>U: Authentication response

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.
fairdataihub-bot[bot] commented 1 month ago

Thanks for making updates to your pull request. Our team will take a look and provide feedback as soon as possible. Please wait for any GitHub Actions to complete before editing your pull request. If you have any additional questions or concerns, feel free to let us know. Thank you for your contributions!

fairdataihub-bot[bot] commented 1 month ago

Thanks for closing this pull request! If you have any further questions, please feel free to open a new issue. We are always happy to help!