chore: replace better-sqlite3 with bun:sqlite#167
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (28)
✨ 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 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
fbaec90 to
8154df0
Compare
Eliminates the C++ native module `better-sqlite3` in favor of Bun's
built-in `bun:sqlite`, removing the need for Node.js in CI and
simplifying the toolchain.
Driver swap (db/index.ts):
- drizzle-orm/better-sqlite3 → drizzle-orm/bun-sqlite
- better-sqlite3 → bun:sqlite (built-in)
- sqlite.pragma("journal_mode = WAL") → sqlite.exec("PRAGMA ...")
- Export SqliteDatabase type for shared use
Type renames across 22 repositories:
- BetterSQLite3Database → BunSQLiteDatabase
Tests consolidated to Bun test runner:
- Removed src/tests/node/sqlite-repositories.test.ts (vitest)
- Migrated full coverage into src/tests/integration/sqlite-repositories.test.ts
using bun:test + bun:sqlite
- 28 SQLite integration tests pass under bun test
Dependencies removed:
- better-sqlite3 (native module)
- @types/better-sqlite3
- vitest (only used for the SQLite tests above)
CI simplification:
- Drop actions/setup-node step from sqlite-tests job
- bunx vitest → bun test
Verification (local):
- bun run typecheck (backend + frontend) — pass
- bun run lint — 0 warnings, 0 errors
- bun test src/tests/unit/ — 1012 pass / 0 fail
- bun test src/tests/integration/ — 70 pass / 0 fail
- bun run build (backend) — succeeds
- node_modules/better-sqlite3 — not installed (optional peer only)
8154df0 to
865a259
Compare
Closes #166
Summary
C++ ネイティブモジュール
better-sqlite3を Bun 組み込みのbun:sqliteに置換。CI から Node.js セットアップを撤廃し、ネイティブビルド依存(python / build-essential)も不要に。Why
better-sqlite3は Bun では動作せず、CI で Node.js 24 を追加セットアップする運用だったbun:sqlite+drizzle-orm/bun-sqliteで同等機能を提供できるChanges
Driver swap (
packages/backend/src/db/index.ts)drizzle-orm/better-sqlite3→drizzle-orm/bun-sqlitebetter-sqlite3→bun:sqlite(Bun 組み込み)sqlite.pragma("journal_mode = WAL")→sqlite.exec("PRAGMA journal_mode = WAL")SqliteDatabase型を共通 export(D1 型もこれに合流)Repository (22 files)
BetterSQLite3Database→BunSQLiteDatabase(型エイリアスのみ、ロジック変更なし)Tests
src/tests/node/sqlite-repositories.test.ts(vitest 経由)を削除src/tests/integration/sqlite-repositories.test.tsに bun:test + bun:sqlite で再実装(28 テスト、全 pass)Dependencies
better-sqlite3,@types/better-sqlite3,vitesttest:sqlitescript:npx vitest run …node/…→bun test …integration/…CI (
.github/workflows/ci.yml)sqlite-testsjob からactions/setup-nodeステップを削除bunx vitest→bun testTest plan
ローカル検証済み(macOS, Bun 1.3.13):
bun run typecheck(backend + frontend) — passbun run lint— 0 warnings, 0 errors (576 files)bun test src/tests/unit/— 1012 pass / 0 failbun test src/tests/integration/— 70 pass / 0 fail(うち 28 が SQLite)bun run build(backend) — 6.65 MB, 1966 modulesnode_modules/better-sqlite3,vitest,@types/better-sqlite3— すべて不在を確認Compatibility
bun:sqliteAPI はbetter-sqlite3とほぼ互換、Drizzle 抽象化で吸収Conflicts with PR #164
.github/workflows/ci.ymlのsqlite-testsjob が PR #164(hardening: Actions SHA 固定)と重なります。マージ順序により:どちらにせよ簡単な競合解決で済みます。