-
Notifications
You must be signed in to change notification settings - Fork 0
feat!: remove 'prisma setup-db-for-litestream' and add pragmas getters #565
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
Summary of ChangesHello @exKAZUu, 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 refactors the management of SQLite PRAGMA settings by deprecating a specific Prisma command previously used for Litestream setup. It introduces new, dedicated utility functions that provide the necessary PRAGMA strings, enabling a more flexible and standardized way to apply these database configurations throughout the application. Highlights
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
|
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
このプルリクエストは、prisma setup-db-for-litestream コマンドを削除し、代わりにLitestreamに必要なSQLiteのPRAGMA文字列を返すヘルパーを shared-lib に追加するものです。これにより、PRAGMAの設定が wb コマンドからアプリケーションコード側に移譲され、より明示的な設定が可能になります。全体として、アーキテクチャの改善につながる良い変更だと評価します。新しく追加されたヘルパーについて、より良い実装方法を提案するコメントをいくつか追加しました。
| export { parseCommandLineArgs } from './parseCommandLineArgs.js'; | ||
| export { shuffle } from './shuffle.js'; | ||
| export { sleep } from './sleep.js'; | ||
| export { getConnectionLevelSqlitePragmas, getPersistentSqlitePragmas } from './sqlite.js'; |
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.
| export function getConnectionLevelSqlitePragmas(): string { | ||
| return 'PRAGMA busy_timeout = 5000; PRAGMA synchronous = NORMAL; PRAGMA wal_autocheckpoint = 0;'; | ||
| } | ||
|
|
||
| export function getPersistentSqlitePragmas(): string { | ||
| return 'PRAGMA journal_mode = WAL;'; | ||
| } |
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.
これらの関数は常に固定の文字列を返すため、関数ではなく export した定数として定義する方がシンプルで分かりやすいです。これにより、不要な関数呼び出しのオーバーヘッドをなくし、値が定数であることを明確に示すことができます。
| export function getConnectionLevelSqlitePragmas(): string { | |
| return 'PRAGMA busy_timeout = 5000; PRAGMA synchronous = NORMAL; PRAGMA wal_autocheckpoint = 0;'; | |
| } | |
| export function getPersistentSqlitePragmas(): string { | |
| return 'PRAGMA journal_mode = WAL;'; | |
| } | |
| export const CONNECTION_LEVEL_SQLITE_PRAGMAS = 'PRAGMA busy_timeout = 5000; PRAGMA synchronous = NORMAL; PRAGMA wal_autocheckpoint = 0;'; | |
| export const PERSISTENT_SQLITE_PRAGMAS = 'PRAGMA journal_mode = WAL;'; |
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.
Pull request overview
This PR refactors SQLite pragma configuration for Litestream by removing the CLI command prisma setup-db-for-litestream and replacing it with reusable utility functions. The change moves the pragma logic from a CLI-specific implementation to shared library functions that can be imported and used programmatically across the codebase.
Key Changes:
- Removed the
setUpDBForLitestreammethod and associated CLI command from the wb package - Added two new pragma getter functions in shared-lib:
getConnectionLevelSqlitePragmas()andgetPersistentSqlitePragmas() - Exported the new functions from shared-lib's public API
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/wb/src/scripts/prismaScripts.ts | Removed setUpDBForLitestream method and unused runtimeWithArgs import |
| packages/wb/src/commands/prisma.ts | Removed setUpDBForLitestreamCommand CLI command definition |
| packages/shared-lib/src/sqlite.ts | Added new pragma getter functions for connection-level and persistent SQLite pragmas |
| packages/shared-lib/src/index.ts | Exported the new pragma getter functions from shared-lib's public API |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export function getConnectionLevelSqlitePragmas(): string { | ||
| return 'PRAGMA busy_timeout = 5000; PRAGMA synchronous = NORMAL; PRAGMA wal_autocheckpoint = 0;'; | ||
| } | ||
|
|
||
| export function getPersistentSqlitePragmas(): string { | ||
| return 'PRAGMA journal_mode = WAL;'; | ||
| } |
Copilot
AI
Dec 13, 2025
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 new pragma getter functions lack documentation explaining their purpose and usage. Consider adding JSDoc comments to describe:
- What these SQLite pragmas do
- Why they are separated into connection-level vs persistent pragmas
- The context that they are intended for use with Litestream (as referenced in the original code comment: https://litestream.io/tips/)
- When each function should be called
This documentation would help developers understand when and how to use these functions correctly.
| export function getConnectionLevelSqlitePragmas(): string { | ||
| return 'PRAGMA busy_timeout = 5000; PRAGMA synchronous = NORMAL; PRAGMA wal_autocheckpoint = 0;'; | ||
| } | ||
|
|
||
| export function getPersistentSqlitePragmas(): string { | ||
| return 'PRAGMA journal_mode = WAL;'; | ||
| } |
Copilot
AI
Dec 13, 2025
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 new pragma getter functions lack test coverage. Since shared-lib has tests for other utility functions (humanize, parseCommandLineArgs, zenkaku), these new functions should also have corresponding tests to verify:
- The returned pragma strings are formatted correctly
- The expected pragma statements are included in each function
- The pragmas remain consistent with Litestream best practices
Consider adding a test file at test/sqlite.test.ts.
Close #
Self Check
All checks have passedon this page.WIP:.yarn test) passed.yarn lint) passed.