npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lyku/lockstep-sqlite

v0.1.1

Published

Schema-driven SQLite/D1 migration toolkit: DDL generation, introspection, and additive diff/migration for @lyku/lockstep-core models

Downloads

289

Readme

@lyku/lockstep-sqlite

Schema-driven SQLite / Cloudflare D1 migration toolkit for @lyku/lockstep-core models. The SQLite-dialect sibling of @lyku/lockstep-pg: it takes the same PostgresTableModel definitions and emits SQLite DDL, introspects a live database, and generates additive migrations.

npm install -D @lyku/lockstep-sqlite @lyku/lockstep-core

Generate the initial schema

import { generateCreateTablesSql } from '@lyku/lockstep-sqlite';
import { users, sessions, projects } from './my-models';

const sql = generateCreateTablesSql({ tables: { users, sessions, projects } });
// → CREATE TABLE IF NOT EXISTS ... + CREATE INDEX ...

Apply to D1: wrangler d1 execute my-db --remote --file=schema.sql.

Evolve a live database

Introspection is driver-agnostic — pass any function that runs a read query and returns rows. Works with bun:sqlite, better-sqlite3, or a D1 binding:

import { generateMigration } from '@lyku/lockstep-sqlite';

// bun:sqlite
const mig = await generateMigration(config, (sql) => db.query(sql).all());

// Cloudflare D1
const mig = await generateMigration(config, (sql) =>
  env.DB.prepare(sql).all().then((r) => r.results),
);

console.log(mig.safe);        // additive: CREATE TABLE / ADD COLUMN
console.log(mig.destructive); // DROP TABLE / DROP COLUMN — held back for review
console.log(mig.notes);       // e.g. "required column added nullable"

PostgreSQL → SQLite type mapping

| lockstep-core type | SQLite | | ------------------------------------------ | ------------- | | serial* / bigserial (as single PK) | INTEGER PRIMARY KEY AUTOINCREMENT | | integer / bigint / smallint | INTEGER | | snowflake | TEXT (see below) | | real / double precision / numeric / money | REAL | | boolean | INTEGER + CHECK (col IN (0,1)) | | text / varchar / char / enum | TEXT (+ enum / length CHECKs) | | jsonb / json / array / point | TEXT (serialized) | | date / time / timestamp / timestamptz | TEXT (ISO-8601) | | bytea | BLOB |

snowflakeTEXT, not INTEGER. SQLite stores 64-bit integers fine, but D1 (and most SQLite drivers) return INTEGER columns to JavaScript as a number (double), exact only up to 2^53 − 1. A snowflake is ~19 digits and embeds a timestamp in its high bits, so it is always past that and would be silently rounded on read. As TEXT it round-trips exactly; the app treats it as a string / BigInt. (This diverges from @lyku/lockstep-pg, where snowflake → int8 is safe — Postgres returns 64-bit values losslessly.)

bigint stays INTEGER (values are usually small — epoch-ms timestamps, counters — and benefit from numeric ordering). If a bigint column can exceed 2^53, model it as snowflake (or text) instead.

What it does not do

  • No triggers. SQLite has no PostgreSQL-style updated_at trigger convention; keep timestamp bookkeeping in the application.
  • No in-place column-type changes. SQLite can't reliably ALTER a column's type; type divergence is surfaced as a note, not an op.

See LLMs.md for the full API and architecture.