Skip to content

feat: add new models and fields to Prisma schema: - #246

Merged
yashdev9274 merged 1 commit into
mainfrom
supercode-cli
Jul 29, 2026
Merged

feat: add new models and fields to Prisma schema:#246
yashdev9274 merged 1 commit into
mainfrom
supercode-cli

Conversation

@yashdev9274

@yashdev9274 yashdev9274 commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Description

  • 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.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor (no functional changes)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

  • bun test passes
  • bun run typecheck passes
  • bun run lint passes (if applicable)

Checklist:

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

Summary by CodeRabbit

  • New Features

    • Added subscription and plan data support.
    • Added credit balance tracking for accounts and plans.
    • Added model and pricing metadata management.
    • Added billing customer identification and subscription status tracking.
  • Performance

    • Improved conversation lookup performance with an additional database index.
  • Bug Fixes

    • Updated database migrations to avoid redundant schema changes and support reliable migration execution.

- 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.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
supercli Ready Ready Preview, Comment Jul 29, 2026 8:59am
supercli-client Ready Ready Preview, Comment Jul 29, 2026 8:59am
supercli-docs Ready Ready Preview, Comment Jul 29, 2026 8:59am

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The 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.

Changes

Billing Persistence

Layer / File(s) Summary
Billing schema models and relations
apps/supercode-cli/server/prisma/schema.prisma
Adds billing fields and relations to User, an index for Conversation.userId, and the Plan, Subscription, CreditBalance, and Model models.
Billing migration implementation
apps/supercode-cli/server/prisma/migrations/20260729130000_add_missing_models/migration.sql
Adds the customer identifier, billing tables, indexes, constraints, defaults, and foreign keys.
Timestamp migration reconciliation
apps/supercode-cli/server/prisma/migrations/20260629120000_add_device_code_timestamps/migration.sql
Replaces the existing schema alteration with explanatory comments and SELECT 1;.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Poem

I’m a bunny with schemas to bring,
New plans and credits make databases sing.
Subscriptions hop into place,
Models get fields with orderly grace.
The timestamp migration now rests—
SELECT 1 passes its test!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change by describing added Prisma models and fields.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch supercode-cli

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
apps/supercode-cli/server/prisma/schema.prisma (1)

175-191: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Remove redundant single-column indexes.

@unique already creates an index for dodoSubscriptionId and slug; 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 | 🔵 Trivial

Validate a non-blocking rollout for existing-table indexes.

Regular CREATE INDEX blocks writes while building these indexes. If conversation or user is sizable, deploy these in a separate non-transactional CREATE INDEX CONCURRENTLY step 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

📥 Commits

Reviewing files that changed from the base of the PR and between ee1f3f4 and 83afef4.

📒 Files selected for processing (3)
  • apps/supercode-cli/server/prisma/migrations/20260629120000_add_device_code_timestamps/migration.sql
  • apps/supercode-cli/server/prisma/migrations/20260729130000_add_missing_models/migration.sql
  • apps/supercode-cli/server/prisma/schema.prisma

Comment on lines +1 to +4
-- 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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.prisma

Repository: 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 || true

Repository: 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.

@yashdev9274
yashdev9274 merged commit fe241d5 into main Jul 29, 2026
5 of 8 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.

1 participant