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

@wuyuchentr/database-migration-tool

v1.0.0

Published

Database migration tool with version control, transactions, locking, and rollback. Supports SQLite/MySQL/PostgreSQL.

Downloads

101

Readme

@wuyuchentr/database-migration-tool

Database migration tool with version control, transactions, locking, and rollback. Zero core dependencies (optional driver packages).

Flyway-inspired, umzug alternative. Supports SQLite, MySQL, PostgreSQL.

Install

npm install @wuyuchentr/database-migration-tool

For SQLite (built-in support for Node 22+ node:sqlite):

# Optional, for better performance:
npm install better-sqlite3

For MySQL:

npm install mysql2

For PostgreSQL:

npm install pg

CLI

# Create a new migration
npx migrate create add_users_table
# → Created: ./migrations/20250101000123_add_users_table.up.sql
#                   ./migrations/20250101000123_add_users_table.down.sql

# Apply pending migrations
npx migrate up

# Apply up to a specific target
npx migrate up --target=20250101000123

# Rollback
npx migrate down
npx migrate down --step=3

# Check status
npx migrate status

# Run seed files
npx migrate seed
npx migrate seed users.sql posts.sql

API

const { Migrator } = require('@wuyuchentr/database-migration-tool');

const migrator = new Migrator({
  driver: 'sqlite',       // 'sqlite' | 'mysql' | 'postgres'
  database: './app.db',   // SQLite path, or MySQL/PG database name
  directory: './migrations',
  table: '_migrations',   // migration history table name
});

await migrator.connect();

// Run migrations
const count = await migrator.up();
const count = await migrator.up({ target: '20250101000123' });

// Rollback
const count = await migrator.down({ step: 1 });

// Create migration
const { name, up, down } = await migrator.create('add_posts_table');

// Status
const rows = await migrator.status();
// [{ name, timestamp, executed, hash }, ...]

// Seeds
await migrator.seed('users.sql');

await migrator.disconnect();

Config file

Create migrate.config.js or migrate.json in your project root:

{
  "driver": "sqlite",
  "database": "./data/app.db",
  "directory": "./db/migrations",
  "seedDirectory": "./db/seeds",
  "table": "my_migrations"
}

Migration files

migrations/
├── 20250101000123_add_users_table.up.sql
├── 20250101000123_add_users_table.down.sql
├── 20250201000123_add_posts_table.up.sql
├── 20250201000123_add_posts_table.down.sql
└── seeds/
    ├── 001_admin_user.sql
    └── 002_sample_data.sql

Each migration must have a paired up/down file.

How it works

  1. Creates a _migrations table to track applied migrations
  2. On up: reads pending .up.sql files in order, executes within a transaction, records hash
  3. On down: executes .down.sql within a transaction, removes record
  4. Transaction wrapping ensures atomicity — partial migrations roll back cleanly
  5. Locking via driver-specific mechanisms prevents concurrent migration runs