-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix(db): added database config to drizzle.config in app container #1536
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
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.
Greptile Overview
Summary
This PR adds SSL configuration support to the Drizzle database configuration in the app container (`apps/sim/drizzle.config.ts`). The implementation introduces a `getSSLConfig()` function that handles various SSL connection modes including disable, prefer, require, verify-ca, and verify-full, with support for custom CA certificates via base64 encoded environment variables. This brings the app container's database configuration in line with the existing SSL handling found in the packages database configuration.The change also updates the schema and output directory paths to reference the centralized database package (../../packages/db/schema.ts and ../../packages/db/migrations) rather than local paths, indicating a move toward centralizing database configuration management. This ensures consistency across the codebase and eliminates duplication of database schema definitions.
The SSL configuration logic reads from DATABASE_SSL and DATABASE_SSL_CA environment variables, providing flexible deployment options for different environments - from local development (SSL disabled) to production environments requiring strict SSL verification with custom certificates.
Changed Files
| Filename | Score | Overview |
|---|---|---|
| apps/sim/drizzle.config.ts | 4/5 | Added SSL configuration function and updated paths to use centralized database package |
Confidence score: 4/5
- This PR is safe to merge with minimal risk as it adds defensive SSL configuration handling
- Score reflects solid implementation following existing patterns with proper error handling and type safety
- Pay attention to environment variable setup in deployment environments to ensure SSL configuration works correctly
Sequence Diagram
sequenceDiagram
participant User
participant "Drizzle CLI" as CLI
participant "drizzle.config.ts" as Config
participant "Environment" as Env
participant "SSL Config" as SSL
participant "Database" as DB
User->>CLI: "Run drizzle migration/push command"
CLI->>Config: "Load configuration"
Config->>Env: "Import env from './lib/env'"
Config->>SSL: "Call getSSLConfig()"
SSL->>Env: "Check env.DATABASE_SSL"
alt SSL disabled or not set
SSL-->>Config: "Return undefined"
else SSL prefer
SSL-->>Config: "Return 'prefer'"
else SSL require
SSL-->>Config: "Return {rejectUnauthorized: false}"
else SSL verify-ca/verify-full
SSL->>Env: "Check env.DATABASE_SSL_CA"
alt CA certificate provided
SSL->>SSL: "Decode base64 CA certificate"
SSL-->>Config: "Return {rejectUnauthorized: true, ca: decodedCA}"
else No CA certificate
SSL-->>Config: "Return {rejectUnauthorized: true}"
end
end
Config->>Config: "Build dbCredentials with URL and SSL config"
Config-->>CLI: "Return complete configuration"
CLI->>DB: "Connect using credentials with SSL settings"
DB-->>CLI: "Connection established"
CLI-->>User: "Command completed successfully"
1 file reviewed, 1 comment
| return 'prefer' as const | ||
| } | ||
|
|
||
| const sslConfig: any = {} |
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.
style: Using any type reduces type safety. Consider defining a proper SSL config interface.
Context Used: Context from dashboard - Avoid using type assertions to 'any' in TypeScript. Instead, ensure proper type definitions are used... (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/drizzle.config.ts
Line: 15:15
Comment:
**style:** Using `any` type reduces type safety. Consider defining a proper SSL config interface.
**Context Used:** Context from `dashboard` - Avoid using type assertions to 'any' in TypeScript. Instead, ensure proper type definitions are used... ([source](https://app.greptile.com/review/custom-context?memory=c63aedff-69e6-48d8-81cf-9763416ee01c))
How can I resolve this? If you propose a fix, please make it concise.
Summary
added database config to drizzle.config in app container
Type of Change
Testing
Manually.
Checklist