-
Notifications
You must be signed in to change notification settings - Fork 10.2k
fix: add database setup for platform settings in local development #22456
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
base: main
Are you sure you want to change the base?
fix: add database setup for platform settings in local development #22456
Conversation
nehaaaa8 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Someone is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
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.
cubic found 1 issue across 1 file. Review it in cubic.dev
React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai
to give specific feedback.
quick-fix.sql
Outdated
"subscriptionId", | ||
"plan" | ||
) VALUES ( | ||
1, -- Replace with your team ID |
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.
Hardcoding the ID as 1 in the PlatformBilling insert may cause a primary key conflict or insert/update the wrong record if the user's team ID is not 1. The comment suggests replacement, but the risk of user error is high.
Graphite Automations"Add consumer team as reviewer" took an action on this PR • (07/13/25)1 reviewer was added to this PR based on Keith Williams's automation. "Add community label" took an action on this PR • (07/13/25)1 label was added to this PR based on Keith Williams's automation. "Add platform team as reviewer" took an action on this PR • (07/13/25)1 reviewer was added to this PR based on Keith Williams's automation. |
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the """ WalkthroughA new SQL script has been added to configure platform-related settings for a team in the database. The script identifies the team, enables the platform feature, updates or inserts billing information, and sets a license key in the deployment table, ensuring idempotency with conflict handling. Additionally, a new asynchronous function was introduced in the seed script to enable the platform feature and billing records for existing teams associated with admin users, and to insert or update a deployment license key, integrating this setup into the main seed workflow. Changes
Assessment against linked issues
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 2
♻️ Duplicate comments (1)
quick-fix.sql (1)
10-24
: Hard-coded primary key inPlatformBilling
can collide with existing rows.
This was mentioned in a previous review and is still unresolved.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
quick-fix.sql
(1 hunks)
🧰 Additional context used
🪛 Gitleaks (8.27.2)
quick-fix.sql
30-30: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Install dependencies / Yarn install & cache
- GitHub Check: Security Check
quick-fix.sql
Outdated
-- Step 2: Enable platform for your team (replace 1 with your actual team ID from step 1) | ||
UPDATE "Team" SET "isPlatform" = true WHERE id = 1; | ||
|
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.
Avoid hard-coding the team ID — parametrize or pass as a psql variable.
Blindly updating id = 1
risks clobbering the wrong team on multi-tenant/dev DBs. Accept the ID returned from Step 1 instead, e.g.:
\set team_id 123 -- ← paste the value from Step 1
UPDATE "Team"
SET "isPlatform" = true
WHERE id = :team_id;
🤖 Prompt for AI Agents
In quick-fix.sql around lines 7 to 9, the team ID is hard-coded as 1 in the
UPDATE statement, which risks updating the wrong record. Modify the script to
accept the team ID as a psql variable by adding a \set command to define the
team_id variable with the value from Step 1, then update the query to use WHERE
id = :team_id instead of a fixed number.
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.
@naaa760 can you please address the potential issues suggested by coderabbit. Marking it draft until then. Feel free to rfr.
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.
Hey appreciate the PR. Let’s move these queries to seed.ts.
…) Secure license key with env fallback Auto‑executes during DB seeding
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/prisma/seed.ts (1)
633-633
: Consider using environment variable validation for the license key.The fallback license key is hardcoded, which could pose security risks if this accidentally runs in production environments.
Consider adding validation to ensure this only runs in development:
// Set license key from environment variable - const licenseKey = process.env.CALCOM_LICENSE_KEY || "59c0bed7-8b21-4280-8514-e022fbfc24c7"; + if (process.env.NODE_ENV === "production" && !process.env.CALCOM_LICENSE_KEY) { + throw new Error("CALCOM_LICENSE_KEY environment variable is required in production"); + } + const licenseKey = process.env.CALCOM_LICENSE_KEY || "59c0bed7-8b21-4280-8514-e022fbfc24c7";
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/prisma/seed.ts
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Install dependencies / Yarn install & cache
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Security Check
🔇 Additional comments (1)
packages/prisma/seed.ts (1)
1406-1406
: Good placement of the platform setup function.Calling
enablePlatformForExistingTeams()
at the end of the main seeding process ensures that platform features are enabled after all users and teams have been created.
✅ Issues Resolved Original Bug:
Result:
|
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.
left a question.
@kart1ka |
This PR is being marked as stale due to inactivity. |
What does this PR do?
Fixes platform settings access in local development environment by providing proper database configuration. This resolves the "Subscription needed" error and 500 response from OAuth clients API.
Fixes #22423
Before:
Platform settings shows "Subscription needed"
OAuth clients API returns 500 error
After:
Platform settings accessible
OAuth clients API returns 200 success
Mandatory Tasks
I have self-reviewed the code
I have updated the developer docs in /docs
I confirm the fix is verified by accessing platform settings successfully