good-migrations-knex

1.0.0 • Public • Published

Good migrations for knex

Migrate anything and store the migration status in your database, using knex as the database client.

import createMigrator from 'good-migrations-knex';
import knex from 'knex';

const db = knex({
	client: 'sqlite3',
	connection: {
		filename: ':memory:'
	}
});

const migrate = await createMigrator(db, 'baking a cake');

// You migrations don't have to be sql-related.
await migrate([
	()=>cake.addFlour(),
	()=>cake.addSugar(),
	()=>cake.addEggs(),
	()=>oven.add(cake)
]);

Dependencies

  • good-migrations: ^1.0.1

gmKnex

gmKnex~migratorFactory ⇒ Migrator

Create a migrator function

Kind: inner property of gmKnex Returns: Migrator - Migrator function

Param Type Description
knex Knex Knex instance
key string Key to identify this set of migrations

gmKnex~Migrator : function

Kind: inner typedef of gmKnex

Param Type Default Description
migrations Array.<function()> Array of migration functions to run
[startIndex] Number 0 The version number of the first migration

/good-migrations-knex/

    Package Sidebar

    Install

    npm i good-migrations-knex

    Weekly Downloads

    0

    Version

    1.0.0

    License

    ISC

    Unpacked Size

    7.06 kB

    Total Files

    7

    Last publish

    Collaborators

    • paulkiddle