Enhance database schema DDL execution control: default to false for non-SQLite drivers#2274
Conversation
…on-SQLite drivers to mitigate security risks, with updated logging for schema execution status.
📝 WalkthroughWalkthrough
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
… security by requiring pre-provisioned schemas in production. Adjust logging to reflect new execution conditions.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@platform-api/src/config/config.go`:
- Around line 281-287: The comment in config initialization overstates what
explicit opt-in does; update the wording around the database.execute_schema_ddl
defaulting logic in config.go to reflect that setting the key only preserves the
config value, while actual DDL execution is still gated later by
StartPlatformAPIServer via executeDDL and demoMode(). Keep the existing
key-existence and driver-based default behavior, but make the comment clear that
non-SQLite auto-provisioning remains disabled unless both the config and
demo-mode gate allow it.
In `@platform-api/src/internal/server/server.go`:
- Around line 84-91: The skip-schema log in server startup is misleading because
executeDDL uses an AND between cfg.Database.ExecuteSchemaDDL and demoMode(), so
the message in server.go should state that both APIP_DEMO_MODE=true and
DATABASE_EXECUTE_SCHEMA_DDL=true are required to enable DDL. Update the
slogger.Info text in the schema initialization branch of server startup to
reflect the actual condition, keeping the driver context unchanged.
🪄 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
Run ID: 629de76e-2018-47bc-b834-1974a97a3abd
📒 Files selected for processing (2)
platform-api/src/config/config.goplatform-api/src/internal/server/server.go
…tabases, with explicit config key preservation. Update logging level for schema execution status to debug for clarity.
… default behavior for SQLite and non-SQLite drivers, and update logging messages to improve clarity on schema execution conditions.
#2281
Problem: ExecuteSchemaDDL defaulted to true for all drivers. When a user configured PostgreSQL (or SQL Server) by setting database.host, the API still auto-ran CREATE TABLE IF NOT EXISTS DDL at startup — requiring DDL privileges on the external DB and silently mutating a schema the operator may not want touched.
Fix:
execute_schema_ddl controls whether the server automatically creates or migrates the database schema at startup.
Default behaviour:
Opt-in for non-SQLite: Set execute_schema_ddl = true only if you want the server to own schema management for your non-SQLite database. Make sure the database user has the necessary DDL privileges.