Wondering what’s next for npm?Check out our public roadmap! »

    @btime/migration

    1.0.0 • Public • Published

    BTime V2 Migration

    📚 Table of Contents

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

    Setup

    Copy enviroment file and configure the variables

    $ cp .env.dist .env
    

    Install dependencies

    $ npm i
    

    Usage

    Generating a migration

    $ ./bin/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:

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

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

    ℹ️ Important The directory must exist in order to be used.

    Running migrations

    $ ./bin/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.

    $ ./bin/migrate --multiple
    

    ℹ️ Important Environment variables prefixed with "MULTIPLE_" are used in order to find target databases.

    Rolling back migrations

    $ ./bin/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:

    $ ./bin/rollback --version [version] --multiple
    

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

    Testing

    Tests are run using Mocha and Chai.

    Run test suite

    $ npm run test
    

    Run coverage report

    $ npm run coverage
    

    Run coverage report in HTML

    $ npm run htmlCoverage
    

    Linting

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

    $ npm run fixStyle
    

    Keywords

    none

    Install

    npm i @btime/migration

    DownloadsWeekly Downloads

    0

    Version

    1.0.0

    License

    ISC

    Unpacked Size

    24.8 kB

    Total Files

    19

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar