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

surrealigrate

v2.0.0

Published

A CLI migration tool for SurrealDB

Readme

surrealigrate

SurrealDB CLI Migrations for Node.js:

  • Edit your database in Surrealist, then generate a migration with Surrealigrate
  • Versioned migration files such as 0001.do.sql, 0002.undo.sql, etc.
  • Migrate to the latest version or a specific version
  • Rollback to previous migration or a specific version
  • Display current migration status with pending migrations
  • Built-in help
  • Supports YAML configuration files, environment variables, and a combination of both

Development Workflow

  1. Create your database
  2. Run npx surrealdb info to verify your database
  3. Run npx surrealdb extract to create an introspection snapshot
  4. Make changes to your database schema in Surrealist
  5. Run npx surrealdb generate -n test to create a migration files, such as 0001.do.test.surql and 0001.undo.test.surql
  6. Run npx surrealdb fastforward to do a version only migration (you already made the changes manually)
  7. Use npx surrealdb rollback followed by npx surrealdb migrate to test your migration
  8. Repeat steps 3 - 7

Production Workflow

  1. Create your database
  2. Run npx surrealdb info to verify your database
  3. Run npx surrealdb migrate

Migrations Folder

The migrations folder defaults to ./migrations but can be configured using the -d or --dir option with any command or in a configuration file.

Migration File Naming Convention

  • The migration file naming convention is 0001.do.surql for the first migration, 0002.do.surql for the second migration, and so on.
  • You can also use a title in the migration file name, such as 0001.do.posts.surql and 0002.undo.posts.surql.
  • The version number is padded with leading zeros to ensure proper sorting order, you can use any number of leading zeros as long as they are consistent throughout the migration files.
  • Version numbers simplify to an integer, so you can use --to 3 to specify a migration file that uses 003 in the file name.
  • Version numbers can be configured using the digits setting for generated migrations to follow your naming convention.
  • The do or undo segment indicates whether the file is for a migration (do) or a rollback (undo).

Configuration

YAML

database:
  url: 'http://127.0.0.1:8000/rpc'
  user: 'myuser'
  pass: 'mypassword'
  namespace: 'myNamespace'
  dbname: 'myDatabase'
migrations:
  folder: './migrations'
  digits: 4

Environment variables

SURREAL_URL=http://127.0.0.1:8000/rpc
SURREAL_USER=myuser
SURREAL_PASS=mypassword
SURREAL_NAMESPACE=myNamespace
SURREAL_DATABASE=myDatabase
SURREAL_MIGRATIONS_DIGITS=4
SURREAL_MIGRATIONS_FOLDER='./migrations'

Usage

Help

npx surrealdb --help

Command Help

Extract Help

npx surrealdb extract --help

Generate Help

npx surrealdb generate --help

Migrate Help

npx surrealdb migrate -- --help

Rollback Help

npx surrealdb rollback --help

Info Help

npx surreald info --help

Extract a Snapshot

  • Creates an introspection snapshot to be used when generating the next migration
  • Must be manually ran between each generated migration
npx surrealdb extract

Generate a Migration

  • Can be ran multiple times to override a new migration during development
  • Requires a snapshot of the previous migration to be created using extract
npx surrealdb generate

Migrate to the Latest Version

npx surreald migrate

Migrate to a Specific Version

npx surreald migrate --to 3
  • 3 is migration up to 0003.do.surql
  • Includes any migrations prior to the specified version

Fast Forward

  • Migrate version without changing database schema
  • Useful during development; generate a migration from introspection, then skip to the correct migration status with fastforward
npx surrealdb fastforward

Rollback the Last Migration

  • Useful during development; fastforward then use rollback, finally perform a test migration
npx surreald rollback

Rollback to a Specific Version

npx surreald rollback --to 2
  • 2 rollsback down to 0002.undo.surql
  • Removes any migrations after the specified version

Using default configuration

npx surreald migrate

Using a YAML config file

npx surreald migrate -c ./config.yml

Environment variables will override other configurations

DB_USER=admin DB_PASS=secretpassword npx surreald migrate

Logs

A migrations.log file will be created in the `/logs folder to log all migration activity.

License

Surrealigrate is licensed under the MIT License. You are free to use it in your projects, commercial or non-commercial, as long as you retain the copyright notice and license text. Please note that the authors of Surrealigrate are not responsible for any damages or losses caused by the use of this software. See the LICENSE file for more details.

Copyright

Copyright (c) 2024-2025 David Dyess II and contributors. All rights reserved.