-
Notifications
You must be signed in to change notification settings - Fork 34
feat: add new models and fields to Prisma schema: #246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 4 additions & 3 deletions
7
...code-cli/server/prisma/migrations/20260629120000_add_device_code_timestamps/migration.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| -- AlterTable | ||
| ALTER TABLE "device_code" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP; | ||
| -- 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; | ||
132 changes: 132 additions & 0 deletions
132
apps/supercode-cli/server/prisma/migrations/20260729130000_add_missing_models/migration.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| -- AlterTable | ||
| ALTER TABLE "user" ADD COLUMN "dodoCustomerId" TEXT; | ||
|
|
||
| -- CreateTable | ||
| CREATE TABLE "plan" ( | ||
| "id" TEXT NOT NULL, | ||
| "tier" TEXT NOT NULL, | ||
| "name" TEXT NOT NULL, | ||
| "description" TEXT, | ||
| "variant" TEXT, | ||
| "interval" TEXT, | ||
| "priceCents" INTEGER NOT NULL, | ||
| "currency" TEXT NOT NULL DEFAULT 'USD', | ||
| "requestLimit" INTEGER NOT NULL, | ||
| "contextLimit" INTEGER NOT NULL, | ||
| "modelAccess" TEXT NOT NULL, | ||
| "creditAmountCents" INTEGER NOT NULL DEFAULT 0, | ||
| "dodoProductId" TEXT, | ||
| "active" BOOLEAN NOT NULL DEFAULT true, | ||
| "sortOrder" INTEGER NOT NULL DEFAULT 0, | ||
| "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| "updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
|
||
| CONSTRAINT "plan_pkey" PRIMARY KEY ("id") | ||
| ); | ||
|
|
||
| -- CreateTable | ||
| CREATE TABLE "subscription" ( | ||
| "id" TEXT NOT NULL, | ||
| "userId" TEXT NOT NULL, | ||
| "planId" TEXT NOT NULL, | ||
| "dodoSubscriptionId" TEXT NOT NULL, | ||
| "dodoCustomerId" TEXT, | ||
| "status" TEXT NOT NULL, | ||
| "currentPeriodStart" TIMESTAMP(3), | ||
| "currentPeriodEnd" TIMESTAMP(3), | ||
| "trialEndsAt" TIMESTAMP(3), | ||
| "cancelAtPeriodEnd" BOOLEAN NOT NULL DEFAULT false, | ||
| "metadata" JSONB, | ||
| "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| "updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
|
||
| CONSTRAINT "subscription_pkey" PRIMARY KEY ("id") | ||
| ); | ||
|
|
||
| -- CreateTable | ||
| CREATE TABLE "credit_balance" ( | ||
| "userId" TEXT NOT NULL, | ||
| "planId" TEXT NOT NULL, | ||
| "balanceCents" INTEGER NOT NULL DEFAULT 0, | ||
| "totalCredits" INTEGER NOT NULL DEFAULT 0, | ||
| "resetAt" TIMESTAMP(3) NOT NULL, | ||
| "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| "updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
|
||
| CONSTRAINT "credit_balance_pkey" PRIMARY KEY ("userId","planId") | ||
| ); | ||
|
|
||
| -- CreateTable | ||
| CREATE TABLE "model" ( | ||
| "id" TEXT NOT NULL, | ||
| "slug" TEXT NOT NULL, | ||
| "displayName" TEXT NOT NULL, | ||
| "provider" TEXT NOT NULL, | ||
| "minTier" TEXT NOT NULL, | ||
| "inputPrice" DOUBLE PRECISION NOT NULL, | ||
| "outputPrice" DOUBLE PRECISION NOT NULL, | ||
| "cachedPrice" DOUBLE PRECISION NOT NULL, | ||
| "active" BOOLEAN NOT NULL DEFAULT true, | ||
| "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| "updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
|
||
| CONSTRAINT "model_pkey" PRIMARY KEY ("id") | ||
| ); | ||
|
|
||
| -- CreateIndex | ||
| CREATE UNIQUE INDEX "plan_dodoProductId_key" ON "plan"("dodoProductId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "plan_tier_idx" ON "plan"("tier"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE UNIQUE INDEX "subscription_dodoSubscriptionId_key" ON "subscription"("dodoSubscriptionId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "subscription_userId_idx" ON "subscription"("userId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "subscription_planId_idx" ON "subscription"("planId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "subscription_dodoSubscriptionId_idx" ON "subscription"("dodoSubscriptionId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "subscription_status_idx" ON "subscription"("status"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "credit_balance_userId_idx" ON "credit_balance"("userId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "credit_balance_planId_idx" ON "credit_balance"("planId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE UNIQUE INDEX "model_slug_key" ON "model"("slug"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "model_minTier_idx" ON "model"("minTier"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "model_provider_idx" ON "model"("provider"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "model_slug_idx" ON "model"("slug"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "conversation_userId_idx" ON "conversation"("userId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE UNIQUE INDEX "user_dodoCustomerId_key" ON "user"("dodoCustomerId"); | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "subscription" ADD CONSTRAINT "subscription_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "subscription" ADD CONSTRAINT "subscription_planId_fkey" FOREIGN KEY ("planId") REFERENCES "plan"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "credit_balance" ADD CONSTRAINT "credit_balance_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "credit_balance" ADD CONSTRAINT "credit_balance_planId_fkey" FOREIGN KEY ("planId") REFERENCES "plan"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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:
Repository: yashdev9274/supercli
Length of output: 923
🏁 Script executed:
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