@eepos/migrations
TypeScript icon, indicating that this package has built-in type declarations

0.9.6 • Public • Published

A simple generic database migration library

Usage

// Create a migration context. You can use one of the provided contexts for postgres and mongodb or write you own
const context = { /*...*/ }

// Define your migrations
const migrations = [
  {
    from: NO_VERSION, // Special version for uninitialized databases
    to: "v1",
    migrate(database) {
      database.doStuff() // The actual migration code
    }
  },
  {
    from: "v1",
    to: "v2",
    migrate(database) {
      database.doOtherStuff()
    }
  },
  /*...*/
]

// Perform the migration to a specific version
// The optimal migration path will automatically be used
await migrate(context, migrations, "v2")

/@eepos/migrations/

    Package Sidebar

    Install

    npm i @eepos/migrations

    Weekly Downloads

    9

    Version

    0.9.6

    License

    MIT

    Unpacked Size

    22.8 kB

    Total Files

    26

    Last publish

    Collaborators

    • david.bellingroth