1.0.0 • Published 3 years ago

good-migrations-knex v1.0.0

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
3 years ago

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

ParamTypeDescription
knexKnexKnex instance
keystringKey to identify this set of migrations

gmKnex~Migrator : function

Kind: inner typedef of gmKnex

ParamTypeDefaultDescription
migrationsArray.<function()>Array of migration functions to run
startIndexNumber0The version number of the first migration
1.0.0

3 years ago