Skip to content

chore: add loan model prisma migration#56

Merged
zkCaleb-dev merged 1 commit intoTrustless-Work:developfrom
AnoukRImola:chore/add-loan-migration
Mar 11, 2026
Merged

chore: add loan model prisma migration#56
zkCaleb-dev merged 1 commit intoTrustless-Work:developfrom
AnoukRImola:chore/add-loan-migration

Conversation

@AnoukRImola
Copy link
Contributor

@AnoukRImola AnoukRImola commented Mar 11, 2026

chore: add missing prisma migration for Loan model

Summary

  • Add the Prisma migration file for the Loan model and LoanStatus enum
    introduced in feat: Add the core folder with NestJS project. #2
  • The migration was missing from the original PR per reviewer feedback, but
    per the team's README convention (prisma:migrate + commit both schema and
    migrations), it should be included

Summary by CodeRabbit

  • New Features
    • Loan management system now available with comprehensive status tracking (pending, disbursed, repaid, defaulted) to streamline loan administration and workflows.

@coderabbitai
Copy link

coderabbitai bot commented Mar 11, 2026

📝 Walkthrough

Walkthrough

A SQL migration introduces a new LoanStatus enum with four states (PENDING, DISBURSED, REPAID, DEFAULTED) and creates a loans table with columns for tracking loan details, including references to campaigns via a foreign key constraint with RESTRICT deletion policy.

Changes

Cohort / File(s) Summary
Loan Model Migration
apps/core/prisma/migrations/20260311220446_add_loan_model/migration.sql
Adds LoanStatus enum type and loans table with fields for loan amount, receiver, disbursement, repayment tracking, and campaign association.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A table of loans now hops into place,
With statuses tracking their lending race,
From pending to paid, each journey unfolds,
Where campaigns and coins find their true holds! 💰✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: add loan model prisma migration' accurately and concisely describes the main change: adding a Prisma migration file that defines the Loan model and LoanStatus enum.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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.

🧹 Nitpick comments (1)
apps/core/prisma/migrations/20260311220446_add_loan_model/migration.sql (1)

21-22: Consider adding an index on campaignId for query performance.

The LoansService.findByCampaign() method queries loans by campaignId. While PostgreSQL doesn't automatically index foreign key columns, an index here would improve lookup performance as the table grows.

This can be deferred and added later via a separate migration if needed, or by adding @@index([campaignId]) to the Loan model in schema.prisma.

📈 Optional: Add index for campaignId lookups

If you want to add the index now, you could append to this migration:

 -- AddForeignKey
 ALTER TABLE "loans" ADD CONSTRAINT "loans_campaignId_fkey" FOREIGN KEY ("campaignId") REFERENCES "campaigns"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
+
+-- CreateIndex
+CREATE INDEX "loans_campaignId_idx" ON "loans"("campaignId");

Or add to schema.prisma and regenerate:

model Loan {
  // ... existing fields
  @@index([campaignId])
  @@map("loans")
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/core/prisma/migrations/20260311220446_add_loan_model/migration.sql`
around lines 21 - 22, Add an index on the foreign key column to speed up
LoansService.findByCampaign() lookups: either add @@index([campaignId]) to the
Loan model in schema.prisma and regenerate migrations, or create a new migration
that issues CREATE INDEX on "loans"(campaignId) (or ALTER TABLE ... ADD INDEX
equivalent) so the "campaignId" column is indexed; reference the Loan model, the
campaignId field, and LoansService.findByCampaign() when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/core/prisma/migrations/20260311220446_add_loan_model/migration.sql`:
- Around line 21-22: Add an index on the foreign key column to speed up
LoansService.findByCampaign() lookups: either add @@index([campaignId]) to the
Loan model in schema.prisma and regenerate migrations, or create a new migration
that issues CREATE INDEX on "loans"(campaignId) (or ALTER TABLE ... ADD INDEX
equivalent) so the "campaignId" column is indexed; reference the Loan model, the
campaignId field, and LoansService.findByCampaign() when making the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c237f4a1-53fe-4350-adc0-e1357243d22b

📥 Commits

Reviewing files that changed from the base of the PR and between 2b73055 and 09332f8.

📒 Files selected for processing (1)
  • apps/core/prisma/migrations/20260311220446_add_loan_model/migration.sql

@zkCaleb-dev zkCaleb-dev merged commit 554b9c4 into Trustless-Work:develop Mar 11, 2026
1 of 4 checks passed
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.

3 participants