public function execute() { $dsId = $this->getCurrentDataSourceId(); $container = ServiceContainer::getInstance(); $runner = new MigrationRunner($dsId); $runner->runUpgradeAutomatically($this->options); $this->logger->info('Done.'); }
public function testRunner() { $connm = LazyRecord\ConnectionManager::getInstance(); $connm->addDataSource('default', array('dsn' => 'sqlite::memory:')); $runner = new LazyRecord\Migration\MigrationRunner('default'); $runner->load('tests/migrations'); $runner->runUpgradeAutomatically(); }
public function execute() { $dsId = $this->getCurrentDataSourceId(); $container = ServiceContainer::getInstance(); $conn = $this->getCurrentConnection(); $driver = $this->getCurrentQueryDriver(); if ($this->options->backup) { if (!$driver instanceof PDOMySQLDriver) { $this->logger->error('backup is only supported for MySQL'); return false; } $this->logger->info('Backing up database...'); $backup = new MySQLBackup(); if ($dbname = $backup->incrementalBackup($conn)) { $this->logger->info("Backup at {$dbname}"); } } $runner = new MigrationRunner($this->logger, $dsId); $this->logger->info("Performing automatic upgrade over data source: {$dsId}"); $tableSchemas = SchemaLoader::loadSchemaTableMap(); $runner->runUpgradeAutomatically($conn, $driver, $tableSchemas, $this->options); $this->logger->info('Done.'); }