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

knex-mig

v0.1.4

Published

Relational Database migration tool - built on top of knex.js

Downloads

71

Readme

Features

  • Atomic operations
  • Automatic rollback on error
  • Seeding
  • Transaction support
  • Migration locking
  • Multi environment support
  • Selective/Partial migration

Installation

npm install -g knex-mig

Usage

To get started, run mg -h to see the available commands and options.

  1. To get the directories needed for the migrator to function properly, run mg setup. This will create some directories in your $USER_HOME directory.
mg setup
  1. To setup a connection to a new database, we need to generate a new configuration file. Run mg env generate <filename> to generate a new configuration file. This will generate a new sample.env file from where you ran the command.
mg env g local-db
  1. Open up the generated file and fill in the necessary details for your database connection.

  2. Once you're done editing the necessary details, run mg env add <filename> to add the configuration to the migrator context. This will copy the file into the migrator's configuration directory. Note: Once added, you can always run a command to edit the file directly in the migrator config directory.

# we can use the -d flag to also automatically set the new file as the current configuration/context
mg env a ./local-db.env -d
  1. Now the file is added to the migrator context, however we need to set it as the current context. To do this, run mg env set <filename>.
mg env set local-db.env
  1. To generate a new migration file, run mg make <name>. This will generate a new migration file in the migrations directory that you specified in the .env file.
mg make users
  1. Edit the generated file as necessary
  2. To see a list of available migrations, and their current state run mg state.
mg ss
  1. To run a migration file, do mg up <filename>. This will run the migration file and update the state of the migration in the database.
# we can use the file number instead of the name (in this case it would be `mg up 1` since it's our first migration)
mg up users

For more information on the available commands, run mg -h.

Feature Roadmap:

  • mg seed make <name> - Create a new seed migration (should give user option to create .json or .js file)
  • add support for .sql files
  • mg make <name> - this exists but need to add option to create a .sql file