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 🙏

© 2024 – Pkg Stats / Ryan Hefner

miracle-migrate

v0.1.9

Published

RethinkDB migration tool

Downloads

11

Readme

Miracle Migrate

Migration suite for RethinkDB, made for MiracleTV.

To start, create a file in your project root directory, called miracle-migrate.json. It has the following schema:

interface MiracleMigrateConfig {
  migrationDir: string;
  connection?: {
    host: string;
    port: number;
    database?: string;
};

Defining migrations

After setting it up, you can use $ miracle-migrate create-migration <name> to create a migration file. It will have two functions, named up and down (similar to knew migrations), that correspond to each individual migration being set up and dismantled.

Each function is supplied with two arguments: db, which is rethinkdb Db istance that you can use to manipulate database, as well as connection option that you can use to actually commit changes to the database. Both up and down expect a promise in return, so if you need to apply multiple alterations in a migrations, either chain them using .then, or wrap them in Promise.all([...]) to return a resolvable promise.

CLI use

To apply all unapplied migrations, you can use $ miracle-migrate up and to dismantle all current migrations, you can use $ miracle-migrate down. Additionally, you can supplement a filename to each of the commands if you wish to rollback to a particular state. Refer to $ miracle-migrate help to see more.

Programmatic use

Additionally, you can import doUp and doDown functions from the package if you wish to use migrations from within your own code (i.e. when starting a server, or to share your project's configuration without duplicating it in the miracle-migrate.json).

Both functions have following signatures:

(
  dbName: string,
  connectionOptions: rdb.ConnectionOptions,
  filename: string = "end"
) => void

Where dbName is the name of your database, and connectionOptions is an object representing your connection to rethinkdb instance. filename is an optional argument that allows you to upgrade or downgrade to a specific migration file.

Database alterations

To keep track of applied migrations and their checksums (in order to help avoid downgrading using a migration file that was altered post-migration), this script creates an additional table within your specified database, called miracle-migrations. Please be aware of this as you model your database structure to avoid collisions.