feat: add new models and fields to Prisma schema: - #246
Conversation
- Introduced new models: Plan, Subscription, CreditBalance, and Model. - Added fields to User model: dodoCustomerId, subscriptions, and creditBalances. - Updated Conversation model with an index on userId. - Created migration scripts for the new models and updated existing tables.
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThe Prisma schema adds billing, subscription, credit balance, and model entities, with a migration creating their tables and relationships. The existing device-code timestamp migration is changed to a no-op because those columns already exist. ChangesBilling Persistence
Estimated code review effort: 3 (Moderate) | ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
apps/supercode-cli/server/prisma/schema.prisma (1)
175-191: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winRemove redundant single-column indexes.
@uniquealready creates an index fordodoSubscriptionIdandslug; Lines 191 and 229 duplicate those indexes. Remove them and omit the corresponding migration statements (Lines 92 and 113).Proposed fix
model Subscription { dodoSubscriptionId String `@unique` ... - @@index([dodoSubscriptionId]) } model Model { slug String `@unique` ... - @@index([slug]) }Also applies to: 216-229
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/supercode-cli/server/prisma/schema.prisma` around lines 175 - 191, Remove the redundant single-column @@index entries for dodoSubscriptionId and slug from the relevant Prisma models, since both fields already have `@unique` constraints. Also remove the corresponding index-creation statements from the migration, while preserving all other indexes and schema definitions.apps/supercode-cli/server/prisma/migrations/20260729130000_add_missing_models/migration.sql (1)
116-119: 🩺 Stability & Availability | 🔵 TrivialValidate a non-blocking rollout for existing-table indexes.
Regular
CREATE INDEXblocks writes while building these indexes. Ifconversationoruseris sizable, deploy these in a separate non-transactionalCREATE INDEX CONCURRENTLYstep rather than directly substituting it into a Prisma transactional migration.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/supercode-cli/server/prisma/migrations/20260729130000_add_missing_models/migration.sql` around lines 116 - 119, Separate the conversation_userId_idx and user_dodoCustomerId_key creation from the transactional Prisma migration and add them to a non-transactional rollout step using CREATE INDEX CONCURRENTLY. Ensure the migration framework does not wrap these statements in a transaction, while preserving both indexes and their existing names.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@apps/supercode-cli/server/prisma/migrations/20260629120000_add_device_code_timestamps/migration.sql`:
- Around line 1-4: Restore the original SQL for the migration identified by
20260629120000_add_device_code_timestamps instead of keeping the SELECT 1 no-op.
Do not modify this already-applied migration or its checksum; address any
shadow-database or rebaseline requirement through a separate controlled
migration process.
---
Nitpick comments:
In
`@apps/supercode-cli/server/prisma/migrations/20260729130000_add_missing_models/migration.sql`:
- Around line 116-119: Separate the conversation_userId_idx and
user_dodoCustomerId_key creation from the transactional Prisma migration and add
them to a non-transactional rollout step using CREATE INDEX CONCURRENTLY. Ensure
the migration framework does not wrap these statements in a transaction, while
preserving both indexes and their existing names.
In `@apps/supercode-cli/server/prisma/schema.prisma`:
- Around line 175-191: Remove the redundant single-column @@index entries for
dodoSubscriptionId and slug from the relevant Prisma models, since both fields
already have `@unique` constraints. Also remove the corresponding index-creation
statements from the migration, while preserving all other indexes and schema
definitions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 56a2d1bc-da95-4475-8eec-6386c7065274
📒 Files selected for processing (3)
apps/supercode-cli/server/prisma/migrations/20260629120000_add_device_code_timestamps/migration.sqlapps/supercode-cli/server/prisma/migrations/20260729130000_add_missing_models/migration.sqlapps/supercode-cli/server/prisma/schema.prisma
| -- This is a no-op: createdAt/updatedAt were already part of the initial device_code table | ||
| -- in migration 20260601105723_device_flow. This migration is already recorded as applied | ||
| -- in the main database but needs to pass in shadow DB for future migrations. | ||
| SELECT 1; No newline at end of file |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
npx prisma migrate status \
--schema apps/supercode-cli/server/prisma/schema.prismaRepository: yashdev9274/supercli
Length of output: 923
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf 'Migration file:\n'
cat -n apps/supercode-cli/server/prisma/migrations/20260629120000_add_device_code_timestamps/migration.sql
printf '\nMigration list around device_flow:\n'
find apps/supercode-cli/server/prisma/migrations -maxdepth 1 -type f -name '_prisma_migrations*' 2>/dev/null || true
find apps/supercode-cli/server/prisma/migrations -maxdepth 1 -type d | sort
printf '\nSearch for migration name/comments/status references:\n'
rg -n "20260629120000_add_device_code_timestamps|created_at|updated_at|device_code|device flow|migration" apps/supercode-cli/server/prisma apps/supercode-cli/server package.json 2>/dev/null || trueRepository: yashdev9274/supercli
Length of output: 5101
Do not rewrite an already-applied migration.
The comments state this migration is already recorded as applied, but replacing its SQL changes Prisma’s migration checksum/history. Prisma recommends restoring the original migration file and handling any pending shadow database work as a separate controlled rebaseline.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@apps/supercode-cli/server/prisma/migrations/20260629120000_add_device_code_timestamps/migration.sql`
around lines 1 - 4, Restore the original SQL for the migration identified by
20260629120000_add_device_code_timestamps instead of keeping the SELECT 1 no-op.
Do not modify this already-applied migration or its checksum; address any
shadow-database or rebaseline requirement through a separate controlled
migration process.
Description
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
bun testpassesbun run typecheckpassesbun run lintpasses (if applicable)Checklist:
Summary by CodeRabbit
New Features
Performance
Bug Fixes