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

@ooneex/migrations

v1.6.2

Published

Database migration runner with versioned schema changes, rollback support, execution logging, and container-aware lifecycle management

Downloads

607

Readme

@ooneex/migrations

Database migration runner with versioned schema changes, rollback support, execution logging, and container-aware lifecycle management.

Bun TypeScript MIT License

Features

Versioned Migrations - Timestamp-based migration versioning with automatic ordering

Up/Down Methods - Each migration defines up and down for applying and rolling back changes

Dependency Support - Migrations can declare dependencies on other migrations

Transaction Safety - Each migration runs inside a database transaction

Migration Tracking - Tracks executed migrations in a dedicated database table

Code Generation - Create new migration files from a template with migrationCreate

Container Integration - Decorator-based registration with dependency injection

Terminal Logging - Progress and error reporting via the TerminalLogger

Installation

bun add @ooneex/migrations

Usage

Creating a Migration

import { migrationCreate } from '@ooneex/migrations';

// Creates a new migration file in the migrations/ directory
const filePath = await migrationCreate();
console.log(`Created: ${filePath}`);

Writing a Migration

import { decorator } from '@ooneex/migrations';
import type { IMigration, MigrationClassType } from '@ooneex/migrations';
import type { SQL, TransactionSQL } from 'bun';

@decorator.migration()
class Migration20240115103045 implements IMigration {
  public async up(tx: TransactionSQL, sql: SQL): Promise<void> {
    await tx`CREATE TABLE users (
      id SERIAL PRIMARY KEY,
      email VARCHAR(255) NOT NULL UNIQUE,
      created_at TIMESTAMP DEFAULT NOW()
    )`;
  }

  public async down(tx: TransactionSQL, sql: SQL): Promise<void> {
    await tx`DROP TABLE IF EXISTS users`;
  }

  public getVersion(): string {
    return '20240115103045';
  }

  public getDependencies(): MigrationClassType[] {
    return [];
  }
}

Running Migrations

import { up } from '@ooneex/migrations';

// Uses DATABASE_URL environment variable by default
await up();

// Or with custom config
await up({
  databaseUrl: 'postgres://user:pass@localhost:5432/mydb',
  tableName: 'schema_migrations',
});

API Reference

Functions

migrationCreate(config?)

Creates a new migration file from a template.

Parameters:

  • config.dir - Directory for migration files (default: "migrations")

Returns: Promise<string> - Path to the created migration file

up(config?)

Runs all pending migrations in version order.

Parameters:

  • config.databaseUrl - Database connection URL (default: DATABASE_URL env var)
  • config.tableName - Name of the migrations tracking table (default: "migrations")

generateMigrationVersion()

Generates a timestamp-based version string for new migrations.

getMigrations()

Returns all registered migrations sorted by version.

createMigrationTable(sql, tableName)

Creates the migration tracking table if it does not exist.

Interfaces

IMigration

interface IMigration {
  up: (tx: TransactionSQL, sql: SQL) => Promise<void>;
  down: (tx: TransactionSQL, sql: SQL) => Promise<void>;
  getVersion: () => string;
  getDependencies: () => Promise<MigrationClassType[]> | MigrationClassType[];
}

Decorators

@decorator.migration()

Registers a class as a migration with the dependency injection container.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Development Setup

  1. Clone the repository
  2. Install dependencies: bun install
  3. Run tests: bun run test
  4. Build the project: bun run build

Guidelines

  • Write tests for new features
  • Follow the existing code style
  • Update documentation for API changes
  • Ensure all tests pass before submitting PR

Made with ❤️ by the Ooneex team