public function action($argv) { $command = $argv[1]; if ($command == 'migrate' || $command == '-m') { $migration = new Migration(); $migration->up(); } elseif ($command == 'rollback' || $command == '-r') { $migration = new Migration(); $migration->rollback(); } elseif ($command == 'status' || $command == '-s') { $migration = new Migration(); $migration->printStatus(); } elseif ($command === 'help' || $command == '-h') { Debug::out('Command: -h (help)'); Debug::out('migrate or -m'); Debug::out('rollback or -r'); Debug::out('status or -s'); } else { Debug::out('Command unknown. Try -h for help.'); } }
/** * Runs a single migration. * * @param Migration $migration * * @return int */ protected function runMigration(Migration $migration) { $result = $migration->up(); $class = get_class($migration); $this->runStack[$class] = $migration; return $result; }
function load_file($filepath) { $rootPath = getcwd() . "/.."; if (file_exists($rootPath . $filepath)) { require_once $rootPath . $filepath; return 1; } else { return 0; } } //Migrate load_file('/config/config_local.php'); load_file('/library/debug.php'); load_file('/library/naming_convention.php'); load_file('/app/exception/database_exception.php'); load_file('/library/db/db.php'); load_file('/library/active_record.php'); load_file('/library/migration.php'); $migration = new Migration(); $migration->up(); //Seeds load_file('/library/object.php'); load_file('/library/db/db_obj.php'); load_file('/library/db/db_model.php'); load_file('/library/db/repository.php'); load_file('/db/seed.php'); echo '== creating seed' . "\n"; $seed = new Seed(); $seed->create(); echo '== setup done' . "\n";