public function run($options = array()) { global $migrateCommand; global $migrateVariables; self::fillOptions($options); $migrateCommand = $this; if ($options['dump-queries'] !== true) { Yentu::greet(); } $this->driver = ChangeLogger::wrap(DatabaseManipulator::create()); $this->driver->setDumpQueriesOnly($options['dump-queries']); $this->driver->setDryRun($options['dry']); $totalOperations = 0; $filter = self::FILTER_UNRUN; $this->setupOptions($options, $filter); DatabaseItem::setDriver($this->driver); \yentu\Timer::start(); $migrationPaths = Yentu::getMigrationPathsInfo(); foreach ($migrationPaths as $path) { $this->setDefaultSchema($path); $migrateVariables = $path['variables']; $migrations = $this->filter(Yentu::getMigrations($path['home']), $filter); $this->announceMigration($migrations, $path); $this->currentPath = $path; foreach ($migrations as $migration) { $this->countOperations("{$path['home']}/{$migration['file']}"); $this->driver->setVersion($migration['timestamp']); $this->driver->setMigration($migration['migration']); ClearIce::output("\nApplying '{$migration['migration']}' migration\n"); require "{$path['home']}/{$migration['file']}"; DatabaseItem::purge(); ClearIce::output("\n"); $totalOperations += $this->driver->resetOperations(); } } if ($this->driver->getChanges()) { $elapsed = \yentu\Timer::stop(); ClearIce::output("\nMigration took " . \yentu\Timer::pretty($elapsed) . "\n"); ClearIce::output($this->driver->getChanges() . " operations performed\n"); ClearIce::output($totalOperations - $this->driver->getChanges() . " operations skipped\n"); } $this->driver->disconnect(); }