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

devhouse-migrate

v1.0.9

Published

Provides simple CLI for persistent mongodb migrations

Downloads

6

Readme

Migration CLI for mongodb

NPM  

npm install -g devhouse-migrate

This module requires nodejs 8.

All migrations staged in database in migrations collection by default (you can change that, see usage). The form of the stored database object:

{
    "_id" : ObjectId("5988679406f2faeaab6a3b2a"),
    "name" : "1484640085344-addCurrentOrderProcessIdToUsers.js",
    "applied" : ISODate("2017-08-07T13:13:56.835Z")
}

The connection string is retrieved from config module. By default db.connectionString property is taken. The module expects to have configuration files in ./config directory

Usage

In order to show usage type

migrate help
usage: 
        
        migrate [keys] arguments [param]
    
    arguments:
        
        create [name]    creates new migration, and the name of the migration [optional] (optional)
        up [name]        migrates from current position up to migration name [optional] (INCLUSIVELY)
        down [name]      downgrades database from current position down to migration name [optional] (INCLUSIVELY)
        applied          show currently applied migrations
        pending          list migration that could be applied
        help             show this help message
    
    keys: 
        
        --migrationsDir='./new-migration'                absolute or relative path to the migrations dir. By default './migrations'
        --collection='db-migrations'                     the name of the collection to persist in the database. By default 'migrations'
        --configConnection='database.connectionString'   the name of the property of the 'config' module to be used as connection string. By default 'db.connectionString'
        --force                                          ignore migration that has no related files in case of down way
        --silence                                        do not ask at all
    

Examples


If you want to show all migration to be applied type

migrate pending

This will returns the full list of migration to apply

The following 6 migrations could be applied:
1: 1484640085344-addCurrentOrderProcessIdToUsers.js
2: 1485165880117-UpdatePropertyBankInfoSchema.js
3: 1497443127517-UpdateUsersBirthdays.js
4: 1497531877195-SetFromAmbitaMark.js
5: 1499927755913-SetFromAmbitaForApartmentOwnersAndUsers.js

In order apply all migration

migration up 

Migrate to specific migration. This will migrate to provided migration inclusively

migration up 1497531877195-SetFromAmbitaMark.js

In order to show currently applied migrations

migrate applied

this will return

The following 7 already applied on the database:
1: 1497443127600-SuperMigration.js
2: 1484640085344-addCurrentOrderProcessIdToUsers.js
3: 1485165880117-UpdatePropertyBankInfoSchema.js
4: 1497443127517-UpdateUsersBirthdays.js
5: 1497531877195-SetFromAmbitaMark.js
6: 1499927755913-SetFromAmbitaForApartmentOwnersAndUsers.js

In order to downgrade to specific migration use

migrate down 1497443127517-UpdateUsersBirthdays.js

And that will downgrate from migration #6 down to #4 inclusively


In some cases you might noticed the following warning

THE FOLLOWING 1 MIGRATIONS ARE IN THE DATABASE BUT NOT IN LOCAL FILES <<<
1: 1497443127600-SuperMigration.js

That means that you cannot downgrade without --force option, that will ignore that migration


In case of up and down migrations you will be asked to approve connection string

with current working environment will be used mongodb://localhost/mongomigrate are you agree with that? [y/n]: y

choose y or n in order to accept/decline

If you don't want to see such messages and reply always yes use --silence key.


In order to create migration use. The name is optional.

migrate create MyNewMigration

This will generate file in you migrations (or --migrationsDir) folder file

file 1502115579733-MyNewMigration.js successfully created

For futher details see

migrate help