Necessary Pigeonholing Mechanism

    sequelize-migration-wrapper
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.1 • Public • Published

    sequelize-migration-wrapper

    A wrapper for migrating databases using Sequelize and Umzug.

    Table of Contents

    Requirements

    This module is tested with Node.js 14. It might work with Node.js >= 12, but is not tested.

    Install

    npm install --save sequelize-migration-wrapper
    

    Usage

    Initialization

    import { setupMigration } from 'sequelize-migration-wrapper'; // TypeScript
    const { setupMigration } = require('sequelize-migration-wrapper'); // CommonJS
    
    const sequelize = new Sequelize({...});
    
    setupMigration({
      sequelize,
      path: 'path/to/migration/scripts',
      filePattern: /\.js$/
    });

    Options

    • sequelize (no default, must be a Sequelize instance; required),
    • path (no default; required),
    • filePattern (default: /\.js$/)

    API

    migrate()

    Runs through all migration scripts in the configured folder. Umzug automatically saves which migration scripts have already been run, so it will not re-run those.

    await migrateDb.migrate();

    getStatus()

    Get the current status of the migration

    const status = await migrateDb.getStatus();

    migrateNext()

    Iteratively run through migration scripts.

    for (const i in numberOfScriptsOrSomething) {
      await migrateDb.migrateNext();
    }

    reset()

    Undo the last migration using Umzug's down function. This will only work if your migration scripts provide a down function. See Umzug's documentation for more details.

    await migrateDb.reset();

    resetPrev()

    Iteratively undo a migration. This will only work if your migration scripts provide a down function. See Umzug's documentation for more details.

    for (const i in numberOfScriptsOrSomething) {
      await migrateDb.resetPrev();
    }

    Release Notes

    1.0.1

    • Security updates

    1.0.0

    • Complete rewrite in TypeScript
    • Support for Sequelize 6

    0.1.1

    • Update dependencies to fix security vulnerabilities

    0.1.0

    • Initial release

    Maintainer

    This modules is maintained by Alex Seifert (Website, Github).

    Install

    npm i sequelize-migration-wrapper

    DownloadsWeekly Downloads

    84

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    11.8 kB

    Total Files

    5

    Last publish

    Collaborators

    • eiskalteschatten