{"size": 713, "ext": "js", "max_stars_repo_path": "lib/migrate.js", "max_stars_repo_name": "nyxtom/mongoose-migrate", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/migrate.js", "max_issues_repo_name": "nyxtom/mongoose-migrate", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/migrate.js", "max_forks_repo_name": "nyxtom/mongoose-migrate", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.6060606061, "max_line_length": 75, "alphanum_fraction": 0.6283309958}
/*!
 * migrate
 * Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
 * MIT Licensed
 */

/**
 * Module dependencies.
 */

import { Migration } from './migration.js';
import { Set } from './set.js';

/**
 * Expose the migrate function.
 */

export function migrate(title, up, down) {
  // migration
  if ('string' == typeof title && up && down) {
    migrate.set.migrations.push(new Migration(title, up, down));
    // specify migration file
  } else if ('string' == typeof title) {
    migrate.set = new Set(title);
    // no migration path
  } else if (!migrate.set) {
    throw new Error('must invoke migrate(path) before running migrations');
    // run migrations
  } else {
    return migrate.set;
  }
}
