Abstract Migrator class. This class should be be instantiated directly.
- function (db,directory,opts){
- this.db = db;
- this.directory = directory;
- opts = opts || {};
- this.table = opts.table || this._static.DEFAULT_SCHEMA_TABLE;
- this.column = opts.column || this._static.DEFAULT_SCHEMA_COLUMN;
- this._opts = opts;
- }
Migrates the database using migration files found in the supplied directory. See patio#migrate
ExampleArguments
- var DB = patio.connect("my://connection/string");
- patio. migrate(DB, __dirname + "/timestamp_migration").chain(function(){
- console.log("done migrating!");
- });
- patio. migrate(DB, __dirname + "/timestamp_migration", {target : 0}).chain(function(){
- console.log("done migrating down!");
- });
the database to migrate
directory that the migration files reside in
{}
] : optional parameters.
String
: the column in the table that version information should be stored.
String
: the table that version information should be stored.
Number
: the target migration(i.e the migration to migrate up/down to).
String
: the version that the database is currently at if the current version is not provided it is retrieved from the database.
Promise
a promise that is resolved once the migration is complete.
- function (db,directory,opts,cb){
- if (isFunction(opts)) {
- cb = opts;
- opts = {};
- } else {
- opts = opts || {};
- }
- opts = opts || {};
- return this.__getMigrator(directory).chain(function (Migrator) {
- return new Migrator(db, directory, opts).run();
- }).classic(cb);
- }
Runs the migration and returns a promise.
Source
- function (){
- throw new NotImplemented("patio.migrations.Migrator#run");
- }