git-sqlite-vfs (version 0.0.20) provides a unique solution for versioning SQLite databases using Git. It achieves this by implementing a custom Virtual File System (VFS) extension for SQLite, sharding database files into deterministic 4KB binary pages stored in a specified directory (e.g., `.my-db`). This approach resolves the common issue of binary merge conflicts in Git when trying to version a monolithic SQLite database file, enabling effective diffing and merging of database changes. The library integrates seamlessly with popular tools like Drizzle ORM and libSQL clients, and is compatible with both Node.js (v22.5+) and Deno environments. While still in early development, it offers CLI tools to replace standard `drizzle-kit` commands for schema management and migrations within the VFS context, ensuring database changes are correctly applied to the sharded structure. Its primary differentiator is making SQLite a first-class citizen in Git-based version control workflows, enabling collaborative database schema and data evolution.
npm install git-sqlite-vfsVerified import paths — ran on the pinned version, not inferred.
Demonstrates initializing a VFS-enabled libSQL client, integrating it with Drizzle ORM, and performing basic database operations. It also highlights the automatic configuration for database compaction.
Always use `npx git-sqlite-vfs <command>` for schema management and migrations when working with a VFS-enabled database.
Use the `createVFSClient` helper function provided by `git-sqlite-vfs`, which automatically handles the correct Node environment binding. If bypassing `createVFSClient`, import directly from the Node environment: `import { createClient } from 'npm:@libsql/client@<version>/node';`.Ensure `PRAGMA auto_vacuum = FULL;` and `PRAGMA journal_mode = DELETE;` are executed on your database connection, or periodically run `VACUUM;` to trigger compaction and shard removal.
For optimal and consistent behavior, consider using Node.js v22.5 or newer. If using older versions, ensure `better-sqlite3` is compatible with your environment.
Use `createVFSClient` from `git-sqlite-vfs` or explicitly import the Node-specific `@libsql/client/node` binding in Deno: `import { createClient } from 'npm:@libsql/client@<version>/node';`Ensure `PRAGMA auto_vacuum = FULL;` and `PRAGMA journal_mode = DELETE;` are executed upon database connection. Alternatively, run `VACUUM;` periodically to compact the database and allow the VFS to remove out-of-bounds shards.
Always use the `git-sqlite-vfs` CLI for schema management: `npx git-sqlite-vfs generate`, `npx git-sqlite-vfs push`, and `npx git-sqlite-vfs migrate`.