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

@edirect/migration

v1.0.1

Published

## Usage

Downloads

25

Readme

BTime V2 Migration

:books: Table of Contents

  1. Installation
  2. Usage
  3. Testing
  4. Linting

Installation

NPM Repository

$ npm i -S @btime/migration

GitHub Repository

$ npm i -S github:Btime/btime-migration

Copy the enviroment file to your project root and configure it

$ cp ./{PACKAGE_ROOT}/.env.dist {PROJECT_ROOT}/.env

:bulb: TIP Both migrate and rollback allows for the specification of a custom env file, through the --env flag.

Usage

To facilitate the use of this CLI tool, you might install it globally or map its commands to the package.json scripts, as follows:

"scripts": {
    "generate": "./node_modules/.bin/generate",
    "migrate": "./node_modules/.bin/migrate",
    "rollback": "./node_modules/.bin/rollback"
}

:information_source: IMPORTANT Don't forget that the mapping above requires you to invoke such scripts as npm run <script>. More on NPM scripts.

Generating a migration

$ generate -t sql

Example output: Generated new migration file: /home/user/projects/btime-migration/migrations/Version20181002114415382.js

All run migrations get versioned, based on it's name - which reflects a unique timestamp. That's the version used when rolling back the migration.

By default, migration files are created at ./migrations (project root). You can specify a custom directory by utilizing the --workdir flag:

$ generate -t sql --workdir ./custom-mirations-dir

The generate, migrate and rollback commands support a custom directory to be specified.

:information_source: IMPORTANT The directory must exist in order to be used.

Running migrations

$ migrate

The above command will run (up) all migration files, considering default options (flags).

Hitting multiple databases

The migration process might target multiple databases through the "--multiple" flag.

$ migrate --multiple

:information_source: IMPORTANT Environment variables prefixed with "MULTIPLE_" are used in order to find target databases.

Rolling back migrations

$ rollback --version [version]

The above command will run (down) the specified migration, considering default options (flags).

Just like the migrate command, you can make use of the --multiple flag and target multiple databases:

$ rollback --version [version] --multiple

All commands come with a --help flag, which displays useful information about it's usage options.

Pushing versions - SemVer

All pushes must come with a new tag. The tag usage must consider semantic versions.

[major version: incompatible changes].[minor version: compatible with major].[patch version: bug fixes]

Before pushing each version, type:

  • For patch changes: npm version patch
  • For minor changes: npm version minor
  • For major changes: npm version major

The version set must also be set in package.json file, at version field.

Testing

Tests are run using Mocha and Chai. Coverage is provided by Istanbul CLI.

Run test suite (coverage included)

$ npm test

Linting

To scan the code base and "auto-fix" all that violates the defined lint rules, run:

$ npm run fixStyle