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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ssegrera/ts-goose

v1.1.3

Published

A lightweight database migration tool for TypeScript and Bun

Readme

goose logo

ts-goose

A lightweight database migration tool for TypeScript and Bun, inspired by goose.

It supports both SQL and TypeScript migrations, and currently supports PostgreSQL and SQLite.

Installation

Using bunx (recommended)

bunx @ssegrera/ts-goose [command]

Using pnpmx/npx

pnpx @ssegrera/ts-goose [command]
# or
npx @ssegrera/ts-goose [command]

Global installation

# Using bun
bun add -g @ssegrera/ts-goose

# Using pnpm
pnpm add -g @ssegrera/ts-goose

# Using npm
npm install -g @ssegrera/ts-goose

Usage

Commands

  • ts-goose create <name> [sql|ts] - Create a new migration file
  • ts-goose up - Apply all pending migrations
  • ts-goose up-by-one - Apply the next pending migration
  • ts-goose up-to VERSION - Apply all pending migrations up to a specific version
  • ts-goose down-to VERSION - Rollback all migrations up to a specific version
  • ts-goose reset - Rollback all migrations
  • ts-goose down - Rollback the last applied migration
  • ts-goose status - Show migration status

Examples

# Create a new SQL migration
bunx @ssegrera/ts-goose create add_users_table sql

# Create a new TypeScript migration
bunx @ssegrera/ts-goose create add_products_table ts

# Apply the next migration
bunx @ssegrera/ts-goose up

# Check migration status
bunx @ssegrera/ts-goose status

# Rollback the last migration
bunx @ssegrera/ts-goose down

Configuration

The following environment variables can be used to configure the tool:

  • TSGOOSE_DRIVER - The database driver to use (postgres or sqlite, defaults to postgres)
  • TSGOOSE_DBSTRING - The database connection string to use (defaults to postgresql://postgres:postgres@localhost:5432/postgres for postgres, or a file path like ./database.sqlite for sqlite)
  • TSGOOSE_MIGRATION_DIR - The directory containing the migration files (defaults to ./migrations)
  • TSGOOSE_TABLE_NAME - The name of the table to use for storing the migration history (defaults to tsgoose.migration)

Using as a Library

You can also use ts-goose programmatically in your TypeScript/Bun projects:

PostgreSQL Example

import { SQL } from "bun";
import { upCommand, PostgresStore, DEFAULT_CONFIG } from "@ssegrera/ts-goose";

// Connect to postgres database
const db = new SQL(DEFAULT_CONFIG.db_url, { adapter: "postgres" });

// Run migrations
await upCommand(db, PostgresStore, {
  migration_dir: DEFAULT_CONFIG.migration_dir,
  table_name: DEFAULT_CONFIG.table_name,
});

// Close connection
await db.end();

This allows you to integrate migration execution into your application startup, tests, or custom deployment scripts.

Development

To install dependencies:

bun install

To run locally:

bun run index.ts [command]

To run tests:

bun test

To build:

bun run build

This project was created using bun init in bun v1.3.0. Bun is a fast all-in-one JavaScript runtime.