1.0.0 • Published 3 years ago
good-migrations-knex v1.0.0
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
- ~Migrator : function
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 |
1.0.0
3 years ago