-
Notifications
You must be signed in to change notification settings - Fork 98
feat: add SQLite database support for local development #942
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: master
Are you sure you want to change the base?
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. ✨ 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 |
Summary of ChangesHello @fengmk2, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request integrates SQLite database support into the project, significantly enhancing the local development experience by removing the need for Docker containers. It involves adding new database schema, initialization scripts, and updating core configuration and testing utilities to ensure seamless operation with SQLite, alongside existing MySQL and PostgreSQL support. The changes aim to reduce setup friction and provide a faster, more lightweight development environment. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #942 +/- ##
==========================================
- Coverage 95.39% 95.29% -0.11%
==========================================
Files 197 197
Lines 22262 22282 +20
Branches 2472 2075 -397
==========================================
- Hits 21237 21233 -4
- Misses 1025 1049 +24 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Code Review
This pull request introduces SQLite support, which is a valuable addition for simplifying the local development setup. The implementation is thorough, covering configuration, database schema, test utilities, and documentation. The handling of SQLite-specific characteristics, such as connection limits and busy timeouts, is well-executed. I have identified a few areas for improvement to enhance robustness and usability. My feedback includes suggestions for making the database preparation script more reliable in CI and more intuitive for developers, as well as a fix in the test utilities to ensure compatibility with all supported database clients.
| if (config.type === DATABASE_TYPE.SQLite) { | ||
| this.connection.close(); | ||
| } else { | ||
| this.connection.destroy(); |
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.
The destroy() method is specific to the mysql2 client and is not available on the pg client, which could lead to errors when running tests with PostgreSQL. A more portable method is end(), which is supported by both mysql2 and pg clients for gracefully closing the connection. Using end() would make this utility more robust across different database types.
| this.connection.destroy(); | |
| this.connection.end(); |
| DATA_DIR=${CNPMCORE_DATA_DIR:-.cnpmcore_unittest} | ||
| DB_NAME=${CNPMCORE_DATABASE_NAME:-cnpmcore_unittest} | ||
| DB_PATH=${CNPMCORE_SQLITE_PATH:-"${DATA_DIR}/${DB_NAME}.sqlite"} |
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.
The current default values for DATA_DIR and DB_NAME are hardcoded for the test environment. This means a developer running bash ./prepare-database-sqlite.sh for local development (as instructed in CLAUDE.md) will incorrectly set up the test database instead of the development one. This increases setup friction.
To improve this, the script could determine the correct defaults based on the execution context. For example, you could check npm_lifecycle_event to see if it's being run as part of a test script. This would make the script 'do the right thing' for both development and testing without requiring developers to set environment variables manually.
5d8c9db to
8c5a08e
Compare
- Add sqlite3 dependency for SQLite database driver - Create sql/ddl_sqlite.sql with complete schema (24 tables) - Add prepare-database-sqlite.sh script for database initialization - Update config/database.ts with SQLite storage path configuration - Update config/config.default.ts with SQLite-specific ORM options - Update config/config.unittest.ts to handle SQLite file paths - Update test/TestUtil.ts with SQLite connection and query support - Add npm scripts: dev:sqlite, test:sqlite, cov:sqlite, ci:sqlite - Update .env.example and CLAUDE.md documentation SQLite eliminates the need for Docker containers during local development, reducing setup friction significantly. Usage: npm run dev:sqlite # Start dev server with SQLite npm run test:sqlite # Run tests with SQLite 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
SQLite eliminates the need for Docker containers during local development, reducing setup friction significantly. Usage:
npm run dev:sqlite # Start dev server with SQLite
npm run test:sqlite # Run tests with SQLite
🤖 Generated with Claude Code