-
Notifications
You must be signed in to change notification settings - Fork 2
ENG-625 Construct environment files to access supabase. #301
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
Conversation
This pull request has been ignored for the connected project Preview Branches by Supabase. |
@CodeRabbit review |
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainI'll help you review this PR! Let me examine the changes to understand what's been implemented for grabbing Supabase keys from Vercel using the CLI. 🏁 Script executed:
Length of output: 648 Let me try different approaches to examine the changes in this PR: 🏁 Script executed:
Length of output: 1262 Let me examine the specific files that are most likely to contain the Vercel CLI integration for Supabase keys: 🏁 Script executed:
Length of output: 8255 @maparent Thank you for starting the review process! I can see this is a comprehensive implementation for ENG-625. Let me examine a few more details to provide a thorough review: 🏁 Script executed:
Length of output: 446 🏁 Script executed:
Length of output: 2885 @maparent I've completed my review of the Vercel CLI integration for grabbing Supabase keys! This is a well-implemented solution for ENG-625. Here's my comprehensive analysis: ✅ StrengthsSolid Architecture & Design:
Dependencies & Configuration:
Security & Error Handling:
🔍 Areas for ImprovementError Handling & Robustness: // Consider adding validation for the vercel CLI availability
const checkVercelCli = () => {
try {
execSync("vercel --version", { stdio: 'ignore' });
} catch {
throw new Error("Vercel CLI not found. Run 'npm install -g vercel' first.");
}
}; Code Organization:
Testing & Documentation:
🚨 Minor IssuesType Safety: // Line 71: Optional chaining could be cleaner
const branchM = stdout.match(/On branch (.*)/)?.[1];
if (!branchM) throw new Error("Could not find the git branch");
// Instead of: if (branchM) branch = branchM; Consistency:
📋 Recommendations for Follow-up
🎯 Overall AssessmentThis is a solid implementation that effectively addresses the requirements. The code integrates well with the existing codebase patterns and provides the flexibility needed for different deployment scenarios. The use of both Vercel SDK and CLI is appropriate for the different use cases. The implementation is ready for testing, though I'd recommend addressing the testing and documentation gaps in follow-up work. ✏️ Learnings added
🧠 Learnings used
|
@CodeRabbit I added documentation, let me know if you see issues there. |
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain@maparent Thank you for adding the documentation and clarifying the CLI availability! Let me examine the new documentation to provide feedback. 🏁 Script executed:
Length of output: 8976 @maparent I can see the comprehensive database documentation, and you're absolutely right about the vercel CLI availability through the package dependency! Let me look more specifically for the documentation about the new Vercel environment generation workflow: 🏁 Script executed:
Length of output: 2192 I'm not finding specific documentation about the new 🏁 Script executed:
Length of output: 1706 @maparent I can see the genenv scripts are properly configured in package.json, but I'm not finding specific documentation about the new Vercel CLI integration workflow. Let me check the main README one more time for any new sections: Based on my search, I don't see specific documentation about the new Vercel environment generation workflow. Here's my feedback: ✅ Acknowledged - Vercel CLI AvailabilityYou're absolutely correct about the Vercel CLI availability! Since the 📋 Documentation FeedbackWhile the existing README has excellent coverage of the database development workflow, I think the new Vercel environment generation feature could benefit from specific documentation covering:
Suggested addition to the README: ### Environment Generation from Vercel
The database package can automatically generate `.env` files by pulling environment variables from Vercel deployments:
- `npm run genenv` - Generate from local Vercel environment
- `npm run genenv:branch` - Generate from current git branch deployment
- `npm run genenv:production` - Generate from production deployment
- `npm run genenv:all` - Generate all variants
Requires `VERCEL_TOKEN` environment variable. Get your token from [Vercel Settings > Tokens](https://vercel.com/account/tokens). Would you like me to help you craft more detailed documentation for this feature? 🏁 Script executed:
Length of output: 3844 @maparent Thank you for the clarification about Vercel CLI availability - you're absolutely right! The However, I wasn't able to find specific documentation about the new Vercel environment generation functionality in my search through the codebase. While the existing README has excellent coverage of the database development workflow, I don't see documentation covering:
Could you point me to where the new documentation was added? It's possible I missed it or it might not be committed yet. 🎯 Overall Assessment UpdateThe implementation itself remains solid and well-architected. Your clarification about CLI availability addresses my main concern about error handling. The code integrates well with existing patterns and provides the flexibility needed for different deployment scenarios. If documentation is still needed, I'd be happy to help draft something that explains:
The feature is ready for testing from a code perspective! 🧠 Learnings used
|
c4e9320
to
3b72a25
Compare
@CodeRabbit: When I said this required testing, I meant testing that it worked at all, I did not mean unit tests. The important points are actually more complex integration tests than unit tests. I have now manually tested that the clients are created properly in both website and roam projects, with all three scenarios. |
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain@maparent Thank you for the clarification about testing approach and completing the manual integration testing! You're absolutely right that integration testing is more valuable here than unit tests. Let me examine the current state of the code since you mentioned substantial changes. Based on the current implementation, I'll provide you with an updated comprehensive review of the substantial changes you've made. 🏁 Script executed:
Length of output: 6606 @maparent Excellent work on the substantial improvements! The code has indeed changed significantly and is much better now. Here's my updated comprehensive review: ✅ Major Improvements Since Initial ReviewCode Quality & Organization:
Documentation Added:
Architecture Improvements:
🎯 Current Implementation AssessmentStrengths: // Clean branch detection with proper error handling
const branchM = stdout.match(/On branch (.*)/)?.[1];
if (branchM) branch = branchM;
else throw new Error("Could not find the git branch"); // Proper file writing with appropriate extensions
writeFileSync(join(projectRoot, ".env.local"), prefixed + '\nNEXT_API_ROOT="http://localhost:3000/api"\n');
appendFileSync(".env.branch", `NEXT_API_ROOT="${url}/api"\n`); Excellent Integration Testing Approach: 🔍 Minor ObservationsThe implementation is now very solid. Only minor suggestions:
// Could be slightly more descriptive
if (result.deployments.length === 0) {
console.warn(`No deployment found for branch '${branch}' in project '${projectIdOrName}'`);
return;
} 🎉 Final AssessmentThis is now a high-quality, production-ready implementation that:
The substantial improvements you've made have transformed this into an excellent piece of infrastructure code. The manual integration testing approach you used is exactly what this type of feature needs - validating that the entire workflow works end-to-end across multiple projects. Ready for merge! 🚀 ✏️ Learnings added
🧠 Learnings used
|
@mdroidian just saw the deploy failure. Will fix that now. |
Ok, the deploy step requires more thought. It goes to tomorrow. |
6ffcd5b
to
91dafb6
Compare
deploy step working. Ready for review. |
@maparent Could you elaborate on this? What is "The base one" referring to? |
91dafb6
to
7cbf07f
Compare
@CodeRabbit full review |
✅ Actions performedFull review triggered. |
📝 WalkthroughWalkthroughThis change introduces a unified environment variable management system across multiple packages by centralizing environment configuration logic in a new Changes
Sequence Diagram(s)sequenceDiagram
participant Script/Server/Client
participant dbdotenv
participant .env File(s)
participant process.env
Script/Server/Client->>dbdotenv: envContents()
dbdotenv->>Script/Server/Client: {SUPABASE_URL, SUPABASE_ANON_KEY, ...}
alt Variant-specific .env file exists
dbdotenv->>.env File(s): Read and parse
.env File(s)-->>dbdotenv: Env variables
else
dbdotenv->>process.env: Fallback to process.env
process.env-->>dbdotenv: Env variables
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15–25 minutes Possibly related PRs
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 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. 🪧 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: 4
🧹 Nitpick comments (3)
packages/database/dbdotenv.ts (1)
30-39
: Consider making fallback behavior more explicit.The fallback to
process.env
when no environment file exists is logical, but the hardcoded keys (SUPABASE_URL
,SUPABASE_ANON_KEY
) create an implicit dependency on these specific environment variables.Consider documenting this fallback behavior or making the fallback keys configurable:
export const envContents = () => { const path = envFilePath(); if (!path) + // Fallback to process.env when running in production environments return { SUPABASE_URL: process.env.SUPABASE_URL, SUPABASE_ANON_KEY: process.env.SUPABASE_ANON_KEY, }; const data = fs.readFileSync(path, "utf8"); return dotenv.parse(data); };
packages/database/README.md (2)
31-31
: Fix spelling error in documentation.There's a typo in the build process description.
- 1. Start supbase + 1. Start supabase
44-44
: Fix indentation inconsistency.The markdown indentation is inconsistent for this list item.
- 10. When your migration is pushed in a branch, supabase will create a branch instance. Note there is a small cost to this, so we do not want those branches to linger. + 10. When your migration is pushed in a branch, supabase will create a branch instance. Note there is a small cost to this, so we do not want those branches to linger.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (14)
apps/roam/package.json
(1 hunks)apps/roam/scripts/compile.ts
(3 hunks)apps/website/app/utils/supabase/client.ts
(1 hunks)apps/website/app/utils/supabase/middleware.ts
(1 hunks)apps/website/app/utils/supabase/server.ts
(1 hunks)packages/database/README.md
(2 hunks)packages/database/create_env.ts
(1 hunks)packages/database/dbdotenv.ts
(1 hunks)packages/database/features/step-definitions/stepdefs.ts
(2 hunks)packages/database/package.json
(2 hunks)packages/database/scripts/create_env.ts
(1 hunks)packages/ui/package.json
(1 hunks)packages/ui/src/lib/supabase/client.ts
(2 hunks)turbo.json
(1 hunks)
🧰 Additional context used
🧠 Learnings (15)
📓 Common learnings
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-22T01:50:20.253Z
Learning: In packages/database/scripts/create_env.ts, the Vercel CLI integration uses both @vercel/sdk for deployment queries and vercel CLI for environment variable pulling, with support for different variants (local, branch, production, all) and proper team/project configuration with discourse-graphs defaults.
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#165
File: packages/database/scripts/deploy.ts:0-0
Timestamp: 2025-05-22T23:48:45.450Z
Learning: The database deployment script in packages/database/scripts/deploy.ts requires that the branch is 'main' and pristine (no uncommitted or unpushed changes) before allowing deployment to proceed.
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#241
File: packages/database/tsconfig.json:3-7
Timestamp: 2025-06-25T18:03:52.669Z
Learning: The packages/database directory in the discourse-graph repository has a unique structure as a database schema/migration package. It contains doc/, scripts/, supabase/ directories and TypeScript files at the root level, but no typical src/, test/, dist/, or node_modules directories. The current tsconfig.json with "include": ["."] and "exclude": ["supabase"] is appropriate for this structure.
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#165
File: packages/database/supabase/migrations/20250512142307_sync_table.sql:20-21
Timestamp: 2025-05-20T03:04:21.602Z
Learning: Database migration files (like the SQL files in packages/database/supabase/migrations/) should not be modified after they're created, even to fix minor issues like unused variables. Issues should be addressed in newer schema files instead to maintain migration history integrity.
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#182
File: apps/website/app/utils/supabase/dbUtils.ts:22-28
Timestamp: 2025-05-30T14:49:24.016Z
Learning: In apps/website/app/utils/supabase/dbUtils.ts, expanding the KNOWN_EMBEDDINGS and DEFAULT_DIMENSIONS mappings to support additional embedding models requires corresponding database model changes (creating new embedding tables), which should be scoped as separate work from API route implementations.
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#198
File: packages/database/supabase/migrations/20250605083319_alpha_upload.sql:157-337
Timestamp: 2025-06-09T16:57:14.681Z
Learning: Migration files in packages/database/supabase/migrations/ are historical snapshots that preserve database schema and functions as they existed at the time of creation. These files should not be updated to reflect current schema changes, even if they reference tables or columns that have since been modified or removed. Schema incompatibilities in migration files are expected and acceptable as they represent the valid state at the time of migration.
apps/roam/package.json (11)
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/roam.mdc:0-0
Timestamp: 2025-07-19T22:34:23.619Z
Learning: Applies to apps/roam/package.json : Prefer existing dependencies from package.json when adding or using dependencies in the Roam Research extension
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/roam.mdc:0-0
Timestamp: 2025-07-19T22:34:23.619Z
Learning: Applies to apps/roam/**/*.{js,jsx,ts,tsx} : Use Roam Depot/Extension API documentation from https://roamresearch.com/#/app/developer-documentation/page/y31lhjIqU when working with the Roam Extension API
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/roam.mdc:0-0
Timestamp: 2025-07-19T22:34:23.619Z
Learning: Applies to apps/roam/**/*.{js,jsx,ts,tsx} : Use the roamAlphaApi documentation from https://roamresearch.com/#/app/developer-documentation/page/tIaOPdXCj when working with the Roam API
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/obsidian.mdc:0-0
Timestamp: 2025-07-19T22:34:16.794Z
Learning: Applies to apps/obsidian/package.json : Prefer existing dependencies from package.json when adding or using dependencies in the Obsidian plugin
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/website.mdc:0-0
Timestamp: 2025-07-19T22:34:26.600Z
Learning: Applies to apps/website/** : Prefer existing dependencies from package.json when adding or using dependencies in the website project
Learnt from: maparent
PR: #241
File: packages/database/tsconfig.json:3-7
Timestamp: 2025-06-25T18:03:52.669Z
Learning: The packages/database directory in the discourse-graph repository has a unique structure as a database schema/migration package. It contains doc/, scripts/, supabase/ directories and TypeScript files at the root level, but no typical src/, test/, dist/, or node_modules directories. The current tsconfig.json with "include": ["."] and "exclude": ["supabase"] is appropriate for this structure.
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/roam.mdc:0-0
Timestamp: 2025-07-19T22:34:23.619Z
Learning: Applies to apps/roam/**/*.{js,jsx,ts,tsx} : Use BlueprintJS 3 components and Tailwind CSS for platform-native UI in the Roam Research extension
Learnt from: maparent
PR: #165
File: packages/database/scripts/deploy.ts:0-0
Timestamp: 2025-05-22T23:48:45.450Z
Learning: The database deployment script in packages/database/scripts/deploy.ts requires that the branch is 'main' and pristine (no uncommitted or unpushed changes) before allowing deployment to proceed.
Learnt from: maparent
PR: #220
File: apps/roam/src/utils/conceptConversion.ts:11-40
Timestamp: 2025-06-23T11:49:45.457Z
Learning: In the DiscourseGraphs/discourse-graph codebase, direct access to window.roamAlphaAPI
is the established pattern throughout the codebase. The team prefers to maintain this pattern consistently rather than making piecemeal changes, and plans to address dependency injection as a global refactor when scheduled.
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/main.mdc:0-0
Timestamp: 2025-07-19T22:34:08.725Z
Learning: Applies to apps/website/**/*.{tsx,jsx,ts,js} : Use Tailwind CSS for styling where possible
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/main.mdc:0-0
Timestamp: 2025-07-19T22:34:08.725Z
Learning: Applies to {apps/website,packages/ui}/**/*.{tsx,jsx} : When refactoring inline styles, use tailwind classes
packages/ui/package.json (2)
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/obsidian.mdc:0-0
Timestamp: 2025-07-19T22:34:16.794Z
Learning: Applies to apps/obsidian/package.json : Prefer existing dependencies from package.json when adding or using dependencies in the Obsidian plugin
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/main.mdc:0-0
Timestamp: 2025-07-19T22:34:08.725Z
Learning: Applies to {apps/website,packages/ui}/**/*.{tsx,jsx} : Use platform-native UI components first with shadcn/ui as a fallback
packages/ui/src/lib/supabase/client.ts (4)
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-22T01:50:20.253Z
Learning: In packages/database/scripts/create_env.ts, the Vercel CLI integration uses both @vercel/sdk for deployment queries and vercel CLI for environment variable pulling, with support for different variants (local, branch, production, all) and proper team/project configuration with discourse-graphs defaults.
Learnt from: maparent
PR: #291
File: packages/database/supabase/functions/create-space/index.ts:0-0
Timestamp: 2025-07-21T14:22:20.752Z
Learning: In the discourse-graph codebase, types.gen.ts is not accessible from Supabase edge functions, requiring duplication of types and utilities when needed in the edge function environment at packages/database/supabase/functions/.
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-08T14:51:55.299Z
Learning: DiscourseGraphs maintainers prefer not to add narrowly typed definitions for individual process.env
keys to avoid unnecessary coupling.
Learnt from: maparent
PR: #272
File: packages/ui/src/lib/supabase/contextFunctions.ts:50-111
Timestamp: 2025-07-08T14:48:38.048Z
Learning: The Supabase client does not offer transaction support, so idempotent upserts with proper conflict resolution (using onConflict with ignoreDuplicates: false) are the preferred approach for multi-step database operations in packages/ui/src/lib/supabase/contextFunctions.ts. This pattern prevents orphaned records when retrying operations.
apps/website/app/utils/supabase/server.ts (7)
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-22T01:50:20.253Z
Learning: In packages/database/scripts/create_env.ts, the Vercel CLI integration uses both @vercel/sdk for deployment queries and vercel CLI for environment variable pulling, with support for different variants (local, branch, production, all) and proper team/project configuration with discourse-graphs defaults.
Learnt from: maparent
PR: #291
File: packages/database/supabase/functions/create-space/index.ts:0-0
Timestamp: 2025-07-21T14:22:20.752Z
Learning: In the discourse-graph codebase, types.gen.ts is not accessible from Supabase edge functions, requiring duplication of types and utilities when needed in the edge function environment at packages/database/supabase/functions/.
Learnt from: maparent
PR: #182
File: apps/website/app/utils/supabase/dbUtils.ts:22-28
Timestamp: 2025-05-30T14:49:24.016Z
Learning: In apps/website/app/utils/supabase/dbUtils.ts, expanding the KNOWN_EMBEDDINGS and DEFAULT_DIMENSIONS mappings to support additional embedding models requires corresponding database model changes (creating new embedding tables), which should be scoped as separate work from API route implementations.
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-08T14:51:55.299Z
Learning: DiscourseGraphs maintainers prefer not to add narrowly typed definitions for individual process.env
keys to avoid unnecessary coupling.
Learnt from: maparent
PR: #272
File: packages/ui/src/lib/supabase/contextFunctions.ts:50-111
Timestamp: 2025-07-08T14:48:38.048Z
Learning: The Supabase client does not offer transaction support, so idempotent upserts with proper conflict resolution (using onConflict with ignoreDuplicates: false) are the preferred approach for multi-step database operations in packages/ui/src/lib/supabase/contextFunctions.ts. This pattern prevents orphaned records when retrying operations.
Learnt from: maparent
PR: #241
File: packages/database/tsconfig.json:3-7
Timestamp: 2025-06-25T18:03:52.669Z
Learning: The packages/database directory in the discourse-graph repository has a unique structure as a database schema/migration package. It contains doc/, scripts/, supabase/ directories and TypeScript files at the root level, but no typical src/, test/, dist/, or node_modules directories. The current tsconfig.json with "include": ["."] and "exclude": ["supabase"] is appropriate for this structure.
Learnt from: maparent
PR: #165
File: packages/database/scripts/deploy.ts:0-0
Timestamp: 2025-05-22T23:48:45.450Z
Learning: The database deployment script in packages/database/scripts/deploy.ts requires that the branch is 'main' and pristine (no uncommitted or unpushed changes) before allowing deployment to proceed.
turbo.json (3)
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-22T01:50:20.253Z
Learning: In packages/database/scripts/create_env.ts, the Vercel CLI integration uses both @vercel/sdk for deployment queries and vercel CLI for environment variable pulling, with support for different variants (local, branch, production, all) and proper team/project configuration with discourse-graphs defaults.
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-08T14:51:55.299Z
Learning: DiscourseGraphs maintainers prefer not to add narrowly typed definitions for individual process.env
keys to avoid unnecessary coupling.
Learnt from: maparent
PR: #165
File: packages/database/supabase/config.toml:0-0
Timestamp: 2025-05-20T15:51:22.084Z
Learning: Wildcard patterns in additional_redirect_urls within Supabase configuration are acceptable in this codebase when needed for Vercel branch deployments, despite the small security risk they introduce.
apps/website/app/utils/supabase/client.ts (4)
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-22T01:50:20.253Z
Learning: In packages/database/scripts/create_env.ts, the Vercel CLI integration uses both @vercel/sdk for deployment queries and vercel CLI for environment variable pulling, with support for different variants (local, branch, production, all) and proper team/project configuration with discourse-graphs defaults.
Learnt from: maparent
PR: #182
File: apps/website/app/utils/supabase/dbUtils.ts:22-28
Timestamp: 2025-05-30T14:49:24.016Z
Learning: In apps/website/app/utils/supabase/dbUtils.ts, expanding the KNOWN_EMBEDDINGS and DEFAULT_DIMENSIONS mappings to support additional embedding models requires corresponding database model changes (creating new embedding tables), which should be scoped as separate work from API route implementations.
Learnt from: maparent
PR: #272
File: packages/ui/src/lib/supabase/contextFunctions.ts:50-111
Timestamp: 2025-07-08T14:48:38.048Z
Learning: The Supabase client does not offer transaction support, so idempotent upserts with proper conflict resolution (using onConflict with ignoreDuplicates: false) are the preferred approach for multi-step database operations in packages/ui/src/lib/supabase/contextFunctions.ts. This pattern prevents orphaned records when retrying operations.
Learnt from: maparent
PR: #291
File: packages/database/supabase/functions/create-space/index.ts:0-0
Timestamp: 2025-07-21T14:22:20.752Z
Learning: In the discourse-graph codebase, types.gen.ts is not accessible from Supabase edge functions, requiring duplication of types and utilities when needed in the edge function environment at packages/database/supabase/functions/.
apps/roam/scripts/compile.ts (8)
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-22T01:50:20.253Z
Learning: In packages/database/scripts/create_env.ts, the Vercel CLI integration uses both @vercel/sdk for deployment queries and vercel CLI for environment variable pulling, with support for different variants (local, branch, production, all) and proper team/project configuration with discourse-graphs defaults.
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/roam.mdc:0-0
Timestamp: 2025-07-19T22:34:23.619Z
Learning: Applies to apps/roam/**/*.{js,jsx,ts,tsx} : Use Roam Depot/Extension API documentation from https://roamresearch.com/#/app/developer-documentation/page/y31lhjIqU when working with the Roam Extension API
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-08T14:51:55.299Z
Learning: DiscourseGraphs maintainers prefer not to add narrowly typed definitions for individual process.env
keys to avoid unnecessary coupling.
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/roam.mdc:0-0
Timestamp: 2025-07-19T22:34:23.619Z
Learning: Applies to apps/roam/**/*.{js,jsx,ts,tsx} : Use the roamAlphaApi documentation from https://roamresearch.com/#/app/developer-documentation/page/tIaOPdXCj when working with the Roam API
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/roam.mdc:0-0
Timestamp: 2025-07-19T22:34:23.619Z
Learning: Applies to apps/roam/package.json : Prefer existing dependencies from package.json when adding or using dependencies in the Roam Research extension
Learnt from: maparent
PR: #291
File: packages/database/supabase/functions/create-space/index.ts:0-0
Timestamp: 2025-07-21T14:22:20.752Z
Learning: In the discourse-graph codebase, types.gen.ts is not accessible from Supabase edge functions, requiring duplication of types and utilities when needed in the edge function environment at packages/database/supabase/functions/.
Learnt from: maparent
PR: #241
File: packages/database/tsconfig.json:3-7
Timestamp: 2025-06-25T18:03:52.669Z
Learning: The packages/database directory in the discourse-graph repository has a unique structure as a database schema/migration package. It contains doc/, scripts/, supabase/ directories and TypeScript files at the root level, but no typical src/, test/, dist/, or node_modules directories. The current tsconfig.json with "include": ["."] and "exclude": ["supabase"] is appropriate for this structure.
Learnt from: maparent
PR: #165
File: packages/database/scripts/deploy.ts:0-0
Timestamp: 2025-05-22T23:48:45.450Z
Learning: The database deployment script in packages/database/scripts/deploy.ts requires that the branch is 'main' and pristine (no uncommitted or unpushed changes) before allowing deployment to proceed.
apps/website/app/utils/supabase/middleware.ts (3)
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-22T01:50:20.253Z
Learning: In packages/database/scripts/create_env.ts, the Vercel CLI integration uses both @vercel/sdk for deployment queries and vercel CLI for environment variable pulling, with support for different variants (local, branch, production, all) and proper team/project configuration with discourse-graphs defaults.
Learnt from: maparent
PR: #182
File: apps/website/app/utils/supabase/dbUtils.ts:22-28
Timestamp: 2025-05-30T14:49:24.016Z
Learning: In apps/website/app/utils/supabase/dbUtils.ts, expanding the KNOWN_EMBEDDINGS and DEFAULT_DIMENSIONS mappings to support additional embedding models requires corresponding database model changes (creating new embedding tables), which should be scoped as separate work from API route implementations.
Learnt from: maparent
PR: #272
File: packages/ui/src/lib/supabase/contextFunctions.ts:50-111
Timestamp: 2025-07-08T14:48:38.048Z
Learning: The Supabase client does not offer transaction support, so idempotent upserts with proper conflict resolution (using onConflict with ignoreDuplicates: false) are the preferred approach for multi-step database operations in packages/ui/src/lib/supabase/contextFunctions.ts. This pattern prevents orphaned records when retrying operations.
packages/database/scripts/create_env.ts (8)
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-22T01:50:20.253Z
Learning: In packages/database/scripts/create_env.ts, the Vercel CLI integration uses both @vercel/sdk for deployment queries and vercel CLI for environment variable pulling, with support for different variants (local, branch, production, all) and proper team/project configuration with discourse-graphs defaults.
Learnt from: maparent
PR: #165
File: packages/database/scripts/deploy.ts:0-0
Timestamp: 2025-05-22T23:48:45.450Z
Learning: The database deployment script in packages/database/scripts/deploy.ts requires that the branch is 'main' and pristine (no uncommitted or unpushed changes) before allowing deployment to proceed.
Learnt from: maparent
PR: #241
File: packages/database/tsconfig.json:3-7
Timestamp: 2025-06-25T18:03:52.669Z
Learning: The packages/database directory in the discourse-graph repository has a unique structure as a database schema/migration package. It contains doc/, scripts/, supabase/ directories and TypeScript files at the root level, but no typical src/, test/, dist/, or node_modules directories. The current tsconfig.json with "include": ["."] and "exclude": ["supabase"] is appropriate for this structure.
Learnt from: maparent
PR: #291
File: packages/database/supabase/functions/create-space/index.ts:0-0
Timestamp: 2025-07-21T14:22:20.752Z
Learning: In the discourse-graph codebase, types.gen.ts is not accessible from Supabase edge functions, requiring duplication of types and utilities when needed in the edge function environment at packages/database/supabase/functions/.
Learnt from: maparent
PR: #182
File: apps/website/app/utils/supabase/dbUtils.ts:22-28
Timestamp: 2025-05-30T14:49:24.016Z
Learning: In apps/website/app/utils/supabase/dbUtils.ts, expanding the KNOWN_EMBEDDINGS and DEFAULT_DIMENSIONS mappings to support additional embedding models requires corresponding database model changes (creating new embedding tables), which should be scoped as separate work from API route implementations.
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-13T16:47:14.352Z
Learning: In the discourse-graph codebase, types.gen.ts contains automatically generated database function type definitions that may have reordered signatures between versions. This reordering is expected behavior from the code generation process and should not be flagged as an issue requiring fixes.
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-25T03:22:48.188Z
Learning: In the discourse-graph project, manual integration testing is preferred over unit tests for complex features like Vercel CLI integration, especially when testing client creation across multiple projects (website and roam) with different deployment scenarios.
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-25T03:22:48.188Z
Learning: In the discourse-graph project, manual integration testing is preferred over unit tests for complex features like Vercel CLI integration, especially when testing client creation across multiple projects (website and roam) with different deployment scenarios.
packages/database/features/step-definitions/stepdefs.ts (8)
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-13T16:47:14.352Z
Learning: In the discourse-graph codebase, types.gen.ts contains automatically generated database function type definitions that may have reordered signatures between versions. This reordering is expected behavior from the code generation process and should not be flagged as an issue requiring fixes.
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-22T01:50:20.253Z
Learning: In packages/database/scripts/create_env.ts, the Vercel CLI integration uses both @vercel/sdk for deployment queries and vercel CLI for environment variable pulling, with support for different variants (local, branch, production, all) and proper team/project configuration with discourse-graphs defaults.
Learnt from: maparent
PR: #165
File: packages/database/scripts/deploy.ts:0-0
Timestamp: 2025-05-22T23:48:45.450Z
Learning: The database deployment script in packages/database/scripts/deploy.ts requires that the branch is 'main' and pristine (no uncommitted or unpushed changes) before allowing deployment to proceed.
Learnt from: maparent
PR: #291
File: packages/database/supabase/functions/create-space/index.ts:0-0
Timestamp: 2025-07-21T14:22:20.752Z
Learning: In the discourse-graph codebase, types.gen.ts is not accessible from Supabase edge functions, requiring duplication of types and utilities when needed in the edge function environment at packages/database/supabase/functions/.
Learnt from: maparent
PR: #241
File: packages/database/tsconfig.json:3-7
Timestamp: 2025-06-25T18:03:52.669Z
Learning: The packages/database directory in the discourse-graph repository has a unique structure as a database schema/migration package. It contains doc/, scripts/, supabase/ directories and TypeScript files at the root level, but no typical src/, test/, dist/, or node_modules directories. The current tsconfig.json with "include": ["."] and "exclude": ["supabase"] is appropriate for this structure.
Learnt from: maparent
PR: #182
File: apps/website/app/utils/supabase/dbUtils.ts:22-28
Timestamp: 2025-05-30T14:49:24.016Z
Learning: In apps/website/app/utils/supabase/dbUtils.ts, expanding the KNOWN_EMBEDDINGS and DEFAULT_DIMENSIONS mappings to support additional embedding models requires corresponding database model changes (creating new embedding tables), which should be scoped as separate work from API route implementations.
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/main.mdc:0-0
Timestamp: 2025-07-19T22:34:08.725Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Maintain consistent naming conventions: UPPERCASE for constants
Learnt from: maparent
PR: #272
File: packages/ui/src/lib/supabase/contextFunctions.ts:50-111
Timestamp: 2025-07-08T14:48:38.048Z
Learning: The Supabase client does not offer transaction support, so idempotent upserts with proper conflict resolution (using onConflict with ignoreDuplicates: false) are the preferred approach for multi-step database operations in packages/ui/src/lib/supabase/contextFunctions.ts. This pattern prevents orphaned records when retrying operations.
packages/database/create_env.ts (6)
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-22T01:50:20.253Z
Learning: In packages/database/scripts/create_env.ts, the Vercel CLI integration uses both @vercel/sdk for deployment queries and vercel CLI for environment variable pulling, with support for different variants (local, branch, production, all) and proper team/project configuration with discourse-graphs defaults.
Learnt from: maparent
PR: #165
File: packages/database/scripts/deploy.ts:0-0
Timestamp: 2025-05-22T23:48:45.450Z
Learning: The database deployment script in packages/database/scripts/deploy.ts requires that the branch is 'main' and pristine (no uncommitted or unpushed changes) before allowing deployment to proceed.
Learnt from: maparent
PR: #241
File: packages/database/tsconfig.json:3-7
Timestamp: 2025-06-25T18:03:52.669Z
Learning: The packages/database directory in the discourse-graph repository has a unique structure as a database schema/migration package. It contains doc/, scripts/, supabase/ directories and TypeScript files at the root level, but no typical src/, test/, dist/, or node_modules directories. The current tsconfig.json with "include": ["."] and "exclude": ["supabase"] is appropriate for this structure.
Learnt from: maparent
PR: #291
File: packages/database/supabase/functions/create-space/index.ts:0-0
Timestamp: 2025-07-21T14:22:20.752Z
Learning: In the discourse-graph codebase, types.gen.ts is not accessible from Supabase edge functions, requiring duplication of types and utilities when needed in the edge function environment at packages/database/supabase/functions/.
Learnt from: maparent
PR: #165
File: packages/database/supabase/migrations/20250512142307_sync_table.sql:20-21
Timestamp: 2025-05-20T03:04:21.602Z
Learning: Database migration files (like the SQL files in packages/database/supabase/migrations/) should not be modified after they're created, even to fix minor issues like unused variables. Issues should be addressed in newer schema files instead to maintain migration history integrity.
Learnt from: maparent
PR: #182
File: apps/website/app/utils/supabase/dbUtils.ts:22-28
Timestamp: 2025-05-30T14:49:24.016Z
Learning: In apps/website/app/utils/supabase/dbUtils.ts, expanding the KNOWN_EMBEDDINGS and DEFAULT_DIMENSIONS mappings to support additional embedding models requires corresponding database model changes (creating new embedding tables), which should be scoped as separate work from API route implementations.
packages/database/dbdotenv.ts (3)
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-22T01:50:20.253Z
Learning: In packages/database/scripts/create_env.ts, the Vercel CLI integration uses both @vercel/sdk for deployment queries and vercel CLI for environment variable pulling, with support for different variants (local, branch, production, all) and proper team/project configuration with discourse-graphs defaults.
Learnt from: maparent
PR: #165
File: packages/database/scripts/deploy.ts:0-0
Timestamp: 2025-05-22T23:48:45.450Z
Learning: The database deployment script in packages/database/scripts/deploy.ts requires that the branch is 'main' and pristine (no uncommitted or unpushed changes) before allowing deployment to proceed.
Learnt from: maparent
PR: #241
File: packages/database/tsconfig.json:3-7
Timestamp: 2025-06-25T18:03:52.669Z
Learning: The packages/database directory in the discourse-graph repository has a unique structure as a database schema/migration package. It contains doc/, scripts/, supabase/ directories and TypeScript files at the root level, but no typical src/, test/, dist/, or node_modules directories. The current tsconfig.json with "include": ["."] and "exclude": ["supabase"] is appropriate for this structure.
packages/database/README.md (15)
Learnt from: maparent
PR: #241
File: packages/database/tsconfig.json:3-7
Timestamp: 2025-06-25T18:03:52.669Z
Learning: The packages/database directory in the discourse-graph repository has a unique structure as a database schema/migration package. It contains doc/, scripts/, supabase/ directories and TypeScript files at the root level, but no typical src/, test/, dist/, or node_modules directories. The current tsconfig.json with "include": ["."] and "exclude": ["supabase"] is appropriate for this structure.
Learnt from: maparent
PR: #198
File: packages/database/supabase/migrations/20250605083319_alpha_upload.sql:157-337
Timestamp: 2025-06-09T16:57:14.681Z
Learning: Migration files in packages/database/supabase/migrations/ are historical snapshots that preserve database schema and functions as they existed at the time of creation. These files should not be updated to reflect current schema changes, even if they reference tables or columns that have since been modified or removed. Schema incompatibilities in migration files are expected and acceptable as they represent the valid state at the time of migration.
Learnt from: maparent
PR: #165
File: packages/database/supabase/migrations/20250512142307_sync_table.sql:20-21
Timestamp: 2025-05-20T03:04:21.602Z
Learning: Database migration files (like the SQL files in packages/database/supabase/migrations/) should not be modified after they're created, even to fix minor issues like unused variables. Issues should be addressed in newer schema files instead to maintain migration history integrity.
Learnt from: maparent
PR: #165
File: packages/database/supabase/migrations/20250513173724_content_concept_key.sql:37-60
Timestamp: 2025-05-22T23:50:23.771Z
Learning: For the discourse-graph project, database schema management focuses on the final state in the supabase/schemas directory, not on the individual migration files. When reviewing database changes, consider only the schema definitions in this directory, not potential duplications or conflicts across migration files.
Learnt from: maparent
PR: #182
File: apps/website/app/utils/supabase/dbUtils.ts:22-28
Timestamp: 2025-05-30T14:49:24.016Z
Learning: In apps/website/app/utils/supabase/dbUtils.ts, expanding the KNOWN_EMBEDDINGS and DEFAULT_DIMENSIONS mappings to support additional embedding models requires corresponding database model changes (creating new embedding tables), which should be scoped as separate work from API route implementations.
Learnt from: maparent
PR: #165
File: packages/database/scripts/deploy.ts:0-0
Timestamp: 2025-05-22T23:48:45.450Z
Learning: The database deployment script in packages/database/scripts/deploy.ts requires that the branch is 'main' and pristine (no uncommitted or unpushed changes) before allowing deployment to proceed.
Learnt from: maparent
PR: #189
File: packages/database/types.gen.ts:336-371
Timestamp: 2025-06-04T11:54:37.239Z
Learning: The team prefers not to manually edit generated files (like Supabase TypeScript types) even when they contain inaccuracies, as manual changes would be overwritten during regeneration. They treat generated files as read-only artifacts.
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-13T16:47:14.352Z
Learning: In the discourse-graph codebase, types.gen.ts contains automatically generated database function type definitions that may have reordered signatures between versions. This reordering is expected behavior from the code generation process and should not be flagged as an issue requiring fixes.
Learnt from: maparent
PR: #165
File: packages/database/supabase/migrations/20250504195841_remote_schema.sql:1-7
Timestamp: 2025-05-20T03:01:11.220Z
Learning: Supabase automatically creates necessary schemas like the "extensions" schema before migrations run, so there's no need to explicitly create these schemas in migration files.
Learnt from: maparent
PR: #165
File: packages/database/supabase/migrations/20250504202930_content_tables.sql:37-45
Timestamp: 2025-05-20T03:11:07.917Z
Learning: When reviewing SQL migrations in this codebase, understand that historical migration files should not be modified once they're applied. Instead, issues should be fixed in subsequent migrations or schema definition files. This is why maparent indicated "migration, not changing. corrected in schema."
Learnt from: maparent
PR: #165
File: packages/database/supabase/schemas/extensions.sql:1-11
Timestamp: 2025-05-20T03:02:36.027Z
Learning: The necessary schemas for Supabase extensions (like 'extensions', 'graphql', and 'vault') are automatically created by Supabase before extensions are installed, so they don't need to be explicitly created in SQL migration files.
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-22T01:50:20.253Z
Learning: In packages/database/scripts/create_env.ts, the Vercel CLI integration uses both @vercel/sdk for deployment queries and vercel CLI for environment variable pulling, with support for different variants (local, branch, production, all) and proper team/project configuration with discourse-graphs defaults.
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-25T03:22:48.188Z
Learning: In the discourse-graph project, manual integration testing is preferred over unit tests for complex features like Vercel CLI integration, especially when testing client creation across multiple projects (website and roam) with different deployment scenarios.
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-25T03:22:48.188Z
Learning: In the discourse-graph project, manual integration testing is preferred over unit tests for complex features like Vercel CLI integration, especially when testing client creation across multiple projects (website and roam) with different deployment scenarios.
Learnt from: maparent
PR: #272
File: packages/ui/src/lib/supabase/contextFunctions.ts:50-111
Timestamp: 2025-07-08T14:48:38.048Z
Learning: The Supabase client does not offer transaction support, so idempotent upserts with proper conflict resolution (using onConflict with ignoreDuplicates: false) are the preferred approach for multi-step database operations in packages/ui/src/lib/supabase/contextFunctions.ts. This pattern prevents orphaned records when retrying operations.
packages/database/package.json (12)
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-22T01:50:20.253Z
Learning: In packages/database/scripts/create_env.ts, the Vercel CLI integration uses both @vercel/sdk for deployment queries and vercel CLI for environment variable pulling, with support for different variants (local, branch, production, all) and proper team/project configuration with discourse-graphs defaults.
Learnt from: maparent
PR: #241
File: packages/database/tsconfig.json:3-7
Timestamp: 2025-06-25T18:03:52.669Z
Learning: The packages/database directory in the discourse-graph repository has a unique structure as a database schema/migration package. It contains doc/, scripts/, supabase/ directories and TypeScript files at the root level, but no typical src/, test/, dist/, or node_modules directories. The current tsconfig.json with "include": ["."] and "exclude": ["supabase"] is appropriate for this structure.
Learnt from: maparent
PR: #165
File: packages/database/scripts/deploy.ts:0-0
Timestamp: 2025-05-22T23:48:45.450Z
Learning: The database deployment script in packages/database/scripts/deploy.ts requires that the branch is 'main' and pristine (no uncommitted or unpushed changes) before allowing deployment to proceed.
Learnt from: maparent
PR: #198
File: packages/database/supabase/migrations/20250605083319_alpha_upload.sql:157-337
Timestamp: 2025-06-09T16:57:14.681Z
Learning: Migration files in packages/database/supabase/migrations/ are historical snapshots that preserve database schema and functions as they existed at the time of creation. These files should not be updated to reflect current schema changes, even if they reference tables or columns that have since been modified or removed. Schema incompatibilities in migration files are expected and acceptable as they represent the valid state at the time of migration.
Learnt from: maparent
PR: #165
File: packages/database/supabase/migrations/20250512142307_sync_table.sql:20-21
Timestamp: 2025-05-20T03:04:21.602Z
Learning: Database migration files (like the SQL files in packages/database/supabase/migrations/) should not be modified after they're created, even to fix minor issues like unused variables. Issues should be addressed in newer schema files instead to maintain migration history integrity.
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#0
File: :0-0
Timestamp: 2025-07-13T16:47:14.352Z
Learning: In the discourse-graph codebase, types.gen.ts contains automatically generated database function type definitions that may have reordered signatures between versions. This reordering is expected behavior from the code generation process and should not be flagged as an issue requiring fixes.
Learnt from: maparent
PR: #182
File: apps/website/app/utils/supabase/dbUtils.ts:22-28
Timestamp: 2025-05-30T14:49:24.016Z
Learning: In apps/website/app/utils/supabase/dbUtils.ts, expanding the KNOWN_EMBEDDINGS and DEFAULT_DIMENSIONS mappings to support additional embedding models requires corresponding database model changes (creating new embedding tables), which should be scoped as separate work from API route implementations.
Learnt from: maparent
PR: #291
File: packages/database/supabase/functions/create-space/index.ts:0-0
Timestamp: 2025-07-21T14:22:20.752Z
Learning: In the discourse-graph codebase, types.gen.ts is not accessible from Supabase edge functions, requiring duplication of types and utilities when needed in the edge function environment at packages/database/supabase/functions/.
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/obsidian.mdc:0-0
Timestamp: 2025-07-19T22:34:16.794Z
Learning: Applies to apps/obsidian/package.json : Prefer existing dependencies from package.json when adding or using dependencies in the Obsidian plugin
Learnt from: maparent
PR: #189
File: packages/database/types.gen.ts:336-371
Timestamp: 2025-06-04T11:54:37.239Z
Learning: The team prefers not to manually edit generated files (like Supabase TypeScript types) even when they contain inaccuracies, as manual changes would be overwritten during regeneration. They treat generated files as read-only artifacts.
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/main.mdc:0-0
Timestamp: 2025-07-19T22:34:08.725Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Maintain consistent naming conventions: UPPERCASE for constants
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/main.mdc:0-0
Timestamp: 2025-07-19T22:34:08.725Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use Prettier with the project's configuration
🧬 Code Graph Analysis (6)
packages/ui/src/lib/supabase/client.ts (1)
packages/database/dbdotenv.ts (1)
envContents
(30-39)
apps/website/app/utils/supabase/server.ts (3)
apps/website/app/utils/supabase/client.ts (1)
createClient
(7-16)packages/ui/src/lib/supabase/client.ts (1)
createClient
(16-26)packages/database/dbdotenv.ts (1)
envContents
(30-39)
apps/website/app/utils/supabase/client.ts (1)
packages/database/dbdotenv.ts (1)
envContents
(30-39)
apps/roam/scripts/compile.ts (1)
packages/database/dbdotenv.ts (1)
envContents
(30-39)
apps/website/app/utils/supabase/middleware.ts (1)
packages/database/dbdotenv.ts (1)
envContents
(30-39)
packages/database/features/step-definitions/stepdefs.ts (1)
packages/database/dbdotenv.ts (2)
getVariant
(8-22)config
(43-48)
🪛 Biome (2.1.2)
packages/ui/package.json
[error] 6-6: The key type was already declared.
This where a duplicated key was declared again.
If a key is defined multiple times, only the last definition takes effect. Previous definitions are ignored.
(lint/suspicious/noDuplicateObjectKeys)
🪛 LanguageTool
packages/database/README.md
[grammar] ~31-~31: Ensure spelling is correct
Context: ...h will do the following: 1. Start supbase 2. Apply the new migration locally 3....
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
[style] ~41-~41: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...r in the studio, or psql
. 3. If that fails, you can reset your local da...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
🪛 markdownlint-cli2 (0.17.2)
packages/database/README.md
44-44: Inconsistent indentation for list items at the same level
Expected: 3; Actual: 4
(MD005, list-indent)
🔇 Additional comments (34)
apps/roam/package.json (1)
16-16
: LGTM! Dependency addition supports centralized environment management.This addition enables the roam app to import the new
envContents()
function from@repo/database/dbdotenv
, supporting the centralized environment variable management system introduced in this PR.packages/ui/src/lib/supabase/client.ts (2)
6-6
: LGTM! Centralized environment variable access implemented.The import of
envContents
from@repo/database/dbdotenv
enables the centralized environment management system.
17-19
: LGTM! Environment variable access correctly refactored.The refactoring from direct
process.env
access to usingenvContents()
is implemented correctly. The function provides fallback toprocess.env
when no environment file is found, ensuring backwards compatibility while enabling the new environment variant system.apps/website/app/utils/supabase/middleware.ts (2)
3-3
: LGTM! Centralized environment variable access implemented.The import enables the new centralized environment management system via
envContents()
.
8-10
: LGTM! Environment variable access correctly refactored.The refactoring from direct
process.env
access toenvContents()
follows the same reliable pattern used across other files. ThedbEnv
variable naming provides good clarity about the source of these environment variables.apps/website/app/utils/supabase/client.ts (2)
3-3
: LGTM! Centralized environment variable access implemented.The import of
envContents
aligns with the centralized environment management system being introduced across the codebase.
8-10
: LGTM! Environment variable access correctly refactored.The refactoring consistently implements the new environment variable access pattern. The
envContents()
function provides the same environment variables with additional support for environment variants while maintaining backwards compatibility.apps/roam/scripts/compile.ts (2)
5-5
: LGTM: Clean integration with centralized environment management.The import of
envContents
from the new@repo/database/dbdotenv
module aligns well with the broader effort to centralize environment variable access across the codebase.
126-137
: Fallback logic verifiedThe
envContents()
function inpackages/database/dbdotenv.ts
correctly falls back toprocess.env.SUPABASE_URL
andprocess.env.SUPABASE_ANON_KEY
when no env file is found (lines 30–36). Inapps/roam/scripts/compile.ts
,NEXT_API_ROOT
is safely defaulted to an empty string viadbEnv.NEXT_API_ROOT || ""
. No changes required.apps/website/app/utils/supabase/server.ts (2)
3-4
: LGTM: Correct import path and environment centralization.Good fix removing the
.ts
extension from the import path, and the integration with the centralized environment management system is clean and consistent.
9-12
: Environment variable access properly centralized.The refactoring to use
envContents()
maintains the existing error handling logic while providing consistent environment variable sourcing across the codebase. The fallback behavior inenvContents()
ensures backward compatibility.packages/database/features/step-definitions/stepdefs.ts (2)
4-5
: LGTM: Correct imports and environment integration.Good fix removing the
.ts
extension from the import path, and the addition ofgetVariant
andconfig
imports properly integrates with the new environment management system.
16-20
: Excellent production safety guard.This is a critical safety measure that prevents destructive tests from running against the production database. The early exit with a clear error message and the subsequent
config()
call for environment initialization are both well-implemented.turbo.json (2)
15-23
: LGTM: Environment variables properly configured for new functionality.The addition of Supabase and Vercel environment variables to
globalEnv
correctly supports the new environment management system. The variables likeSUPABASE_USE_DB
andSUPABASE_GIT_BRANCH
enable the variant-based environment selection introduced in the PR.
30-30
: Proper handling of sensitive environment variables.The addition of
GITHUB_ACTIONS
,SUPABASE_ACCESS_TOKEN
, andVERCEL_TOKEN
toglobalPassThroughEnv
is correct - these sensitive tokens should be passed through rather than cached in the global environment.Also applies to: 35-35, 39-39
packages/database/create_env.ts (4)
10-10
: LGTM: Appropriate early exit for Vercel environment.Good check to prevent the script from running in Vercel's build environment where it's not needed.
14-19
: Proper token validation with clear error message.The VERCEL_TOKEN requirement check is appropriate and provides a clear error message for developers.
21-29
: Good variant validation with comprehensive options.The validation correctly handles both command-line arguments and environment variable sources, with proper error handling for invalid variants.
66-67
: Missing NEXT_API_ROOT configuration for branch and production variants.The local variant sets
NEXT_API_ROOT="http://localhost:3000"
but the branch and production variants don't set this variable, which could cause issues when the environment is loaded.Consider adding appropriate API root URLs for each variant:
execSync( `vercel -t ${vercelToken} env pull --environment preview --git-branch ${safeBranch} .env.branch`, { encoding: "utf8" }, ); + // Append branch-specific API root + const branchContent = readFileSync(join(projectRoot, ".env.branch"), "utf8"); + writeFileSync( + join(projectRoot, ".env.branch"), + branchContent + `\nNEXT_API_ROOT="https://${branch}-discourse-graphs.vercel.app"\n` + ); } catch (err) {execSync( `vercel -t ${vercelToken} env pull --environment production .env.production`, ); + // Append production API root + const prodContent = readFileSync(join(projectRoot, ".env.production"), "utf8"); + writeFileSync( + join(projectRoot, ".env.production"), + prodContent + '\nNEXT_API_ROOT="https://discourse-graphs.vercel.app"\n' + ); }Also applies to: 75-77
⛔ Skipped due to learnings
Learnt from: maparent PR: DiscourseGraphs/discourse-graph#0 File: :0-0 Timestamp: 2025-07-22T01:50:20.253Z Learning: In packages/database/scripts/create_env.ts, the Vercel CLI integration uses both @vercel/sdk for deployment queries and vercel CLI for environment variable pulling, with support for different variants (local, branch, production, all) and proper team/project configuration with discourse-graphs defaults.
Learnt from: maparent PR: DiscourseGraphs/discourse-graph#165 File: packages/database/scripts/deploy.ts:0-0 Timestamp: 2025-05-22T23:48:45.450Z Learning: The database deployment script in packages/database/scripts/deploy.ts requires that the branch is 'main' and pristine (no uncommitted or unpushed changes) before allowing deployment to proceed.
Learnt from: maparent PR: DiscourseGraphs/discourse-graph#0 File: :0-0 Timestamp: 2025-07-08T14:51:55.299Z Learning: DiscourseGraphs maintainers prefer not to add narrowly typed definitions for individual `process.env` keys to avoid unnecessary coupling.
packages/database/dbdotenv.ts (2)
8-22
: Environment detection and variant validation logic looks solid.The function correctly prioritizes production environment detection over user configuration, which prevents accidental local environment usage in CI/CD. The validation against allowed variants with meaningful error messages is well implemented.
41-48
: Singleton pattern implementation is appropriate.The one-time configuration pattern with
CONFIG_DONE
flag prevents multiple dotenv configurations, which is the correct approach for this use case.packages/database/package.json (4)
9-10
: New export enables clean cross-package imports.The addition of the
"./dbdotenv"
export allows other packages to import environment utilities using@repo/database/dbdotenv
, which is cleaner than relative imports.
14-14
: Dev script integration looks good.Running
tsx scripts/create_env.ts
during development startup ensures environment files are generated before functions serve, which is the correct workflow.
21-25
: Environment generation scripts are well-organized.The script naming convention is clear and covers all necessary variants. The
genenv:all
script provides a convenient way to generate all environment files at once.
34-39
: Dependency additions support the new functionality.The
@vercel/sdk
andvercel
packages are necessary for the environment generation scripts, and thetsx
update ensures compatibility.packages/database/scripts/create_env.ts (6)
11-11
: Early exit for production environments is correct.The check for Vercel's environment (
HOME === "/vercel"
) prevents the script from running in production deployments, which is the intended behavior.
15-23
: Variant validation and argument parsing looks solid.The logic correctly prioritizes command line arguments over environment variables, with proper validation against allowed variants.
34-48
: Vercel client setup with proper token validation.The token validation ensures the script fails fast when credentials are missing for non-local variants. The team configuration with fallback values is well-structured.
50-67
: Local environment generation is straightforward and correct.The use of
supabase status -o env
to get local environment variables, combined with the prefix transformation logic, is the right approach for generating local environment files.
69-100
: Branch environment generation with robust git integration.The git branch detection with override capability and Vercel deployment querying is well-implemented. The warning for missing deployments is helpful for debugging.
121-134
: Error handling approach is appropriate.The try-catch block with logging and re-throwing ensures errors are visible while still failing the script execution, which is the correct behavior for build/dev scripts.
packages/database/README.md (3)
3-47
: Comprehensive workflow documentation with clear scenario separation.The restructured documentation effectively separates different usage scenarios and provides detailed step-by-step instructions. The local development workflow is particularly well-documented with proper handling of schema changes and migration management.
57-66
: Branch database usage documentation is clear and helpful.The instructions for using local code against the Supabase branch database are well-structured, with appropriate security considerations and clear environment variable setup instructions.
67-72
: Production database usage includes appropriate security warnings.The documentation correctly emphasizes the security risks of using local code against production databases and provides clear guidance on when this might be appropriate.
packages/database/create_env.ts
Outdated
@@ -0,0 +1,78 @@ | |||
import { execSync } from "node:child_process"; |
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.
filename (create_env) should be camelCase
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.
Looks like this is still create_env
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.
Actually, who/what is using this file?
Good general direction. Great work! 👍 |
148375a
to
dc7964b
Compare
rebased on main, no other change. |
Curious: I resolved all conversations (afaik) and GitHub still says I'm in "changes requested" state. Is there something else I'm expected to do? |
It needs another review. I should be able to get it today or tomorrow. |
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.
Couple changes we probably should do, but can merge after.
packages/database/eslint.config.mjs
Outdated
parserOptions: { | ||
project: true, | ||
tsconfigRootDir: ".", | ||
project: "./tsconfig.json", |
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.
rm project: ./tsconfig.json
, to allow project: true
to work
makeLocalEnv(); | ||
} | ||
if (variant === "branch" || variant === "all") { | ||
await makeBranchEnv(vercel); |
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.
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.
Unless in the case of "all", where we need it before. This is actually a typescript error; it should know that vercel is non-null if variant is not local. And indeed tsx does not protest. I could add a "!" to tell typescript about this, I did in an earlier version, but for some reason the warning does not show in some cases.
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.
actually made a change.
packages/database/create_env.ts
Outdated
@@ -0,0 +1,78 @@ | |||
import { execSync } from "node:child_process"; |
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.
Looks like this is still create_env
packages/database/create_env.ts
Outdated
@@ -0,0 +1,78 @@ | |||
import { execSync } from "node:child_process"; |
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.
Actually, who/what is using this file?
The base one is for running against the local supabase. It is possible to talk directly against either a supabase branch or the production database. Use cases for either should be extremely rare, and are documented separately. For this, set SUPABASE_USE_DB to 'branch' or 'production' respectively. The branch used will be the current branch, unless overridden by SUPABASE_GIT_BRANCH.
create_env.ts: That earlier version was checked in by mistake. Removed. |
dc7964b
to
56a4f5e
Compare
This code auto-constructs up to three environment files in
packages/database
:.env.{local, branch, production}. These are for development, so the local code can speak to the appropriate supabase instance, and not expected to be present in production. The base scenario is running against the local supabase, hence using
.env.local`.It is also possible to talk directly against either a supabase branch or the production database. Use cases for either should be extremely rare, and are documented separately. For this, set SUPABASE_USE_DB to 'branch' or 'production' respectively. The branch used will be the current branch, unless overridden by SUPABASE_GIT_BRANCH.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores