Skip to content

Replace libSQL with Node SQLite - #39

Open
jamesmontemagno wants to merge 2 commits into
github-samples:mainfrom
jamesmontemagno:motz-simplify-database-setup
Open

Replace libSQL with Node SQLite#39
jamesmontemagno wants to merge 2 commits into
github-samples:mainfrom
jamesmontemagno:motz-simplify-database-setup

Conversation

@jamesmontemagno

Copy link
Copy Markdown
Contributor

Description

Replace the platform-native libSQL client with Node.js's built-in SQLite driver through Drizzle's SQLite proxy adapter. This preserves the workshop's Drizzle schema, migrations, seed flow, and injectable helpers while making setup reliable across supported Windows and macOS architectures. It also applies the safe npm audit remediation, removing all high-severity findings.

Related Issue

Closes #38

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📚 Documentation update
  • 🧪 Test update
  • 🔧 Refactor (no functional changes)

Changes Made

  • Replace @libsql/client with node:sqlite behind Drizzle's SQLite proxy adapter.
  • Preserve cross-process file migrations and seeding, plus in-memory test databases and injectable helpers.
  • Require Node.js 22.13+ and update onboarding, contributor, and workshop guidance.
  • Apply non-forced npm audit updates, removing all high-severity advisories.

Testing

Data Layer Changes

  • Ran npm run test:unit - all tests pass
  • Added/updated Vitest tests for data-layer changes (existing tests cover migrations, joins, and lookups)
  • Generated a migration (npm run db:generate) for any schema change (not applicable; schema unchanged)

Frontend Changes

  • Ran npm run test:e2e - all tests pass
  • Added data-testid attributes to interactive elements (not applicable; UI unchanged)
  • Verified build succeeds (npm run build)

Also ran npm run typecheck:all and npm run lint.

Checklist

  • My code follows the project's coding standards
  • I have used explicit TypeScript types for function parameters and return values
  • I have built the UI with Astro components and Tailwind CSS utility classes (not applicable; UI unchanged)
  • I have updated documentation (README, instruction files) if needed
  • My changes are focused on a single concern
  • I have written clear commit messages explaining what and why

Additional Notes

Node.js 22.13 is the minimum supported version because it is the first Node 22 release where node:sqlite works without the experimental SQLite flag. Four moderate, development-only audit findings remain in the deprecated drizzle-kit esbuild-loader chain; npm's only remediation is a breaking downgrade, so it was intentionally not applied.

Use Node's built-in SQLite driver to avoid platform-native libSQL installs while preserving the Drizzle workshop workflow.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 577ec881-eb21-4233-b7ba-5a91e021e274
Copilot AI review requested due to automatic review settings August 3, 2026 17:15

Copilot AI left a comment

Copy link
Copy Markdown

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 migrates the data layer from the platform-native libSQL client to Node.js’s built-in node:sqlite via Drizzle’s SQLite proxy adapter, keeping the existing schema/migrations/seed flow and injectable helpers while aiming to improve cross-platform setup reliability.

Changes:

  • Reworked the Drizzle database client to use drizzle-orm/sqlite-proxy bridged to node:sqlite, including transactional migration execution.
  • Updated data-access and migration/test utilities to use the new adapter (.get() for single-row fetches; proxy migrator wiring for migrations).
  • Updated docs and tooling metadata for the new SQLite approach + Node 22.13+ requirement, and removed libSQL-specific config/deps.
Show a summary per file
File Description
src/lib/games.ts Switches single-row lookup to .get() for the proxy-backed SQLite adapter.
src/lib/db.ts Replaces libSQL client setup with a node:sqlite + Drizzle proxy bridge, plus migration helpers.
db/test-helpers.ts Updates in-memory test DB creation/migrations to use the SQLite proxy migrator.
db/migrate.ts Updates migration runner to use the proxy migrator + atomic execution via DatabaseSync.
drizzle.config.ts Aligns drizzle-kit default DB URL with the new local DB filename.
README.md Updates architecture/setup docs to reflect Node SQLite and the new local DB location.
CONTRIBUTING.md Updates contributor setup requirements and data-layer terminology for Node SQLite.
package.json Adds a Node engine constraint (>=22.13) and removes @libsql/client.
package-lock.json Removes libSQL packages and applies dependency/audit updates (also changes many resolved URLs).
eslint.config.js Removes .data/ ignore in line with the new DB location.
.gitignore Removes .data/ ignore; continues to ignore *.db files.
.npmrc Removes the libSQL registry override.
.github/workflows/copilot-setup-steps.yml Updates workflow comments to reference Node SQLite instead of libSQL.
.github/skills/quality-checks/SKILL.md Updates quality-check guidance for Node SQLite + new DB file name + Node version.
.github/instructions/unit-tests.instructions.md Updates unit test instructions to reference in-memory Node SQLite.
.github/instructions/drizzle.instructions.md Updates Drizzle data-layer guidance to Node SQLite and adds Node 22.13 requirement.
.github/instructions/astro.instructions.md Updates Astro guidance to reference Node SQLite-backed helpers.
.github/copilot-instructions.md Updates repo-level Copilot guidance to reflect Node SQLite and new DB lifecycle wording.
.github/agents/pr-readiness.md Updates PR readiness guidance to reference in-memory Node SQLite for unit tests.
.devcontainer/devcontainer.json Updates devcontainer name to include Node SQLite.

Review details

  • Files reviewed: 18/20 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread src/lib/db.ts Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 577ec881-eb21-4233-b7ba-5a91e021e274
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace platform-native libSQL client with Node SQLite

2 participants