Ejemplo n.º 1
0
 public function testBackup()
 {
     $this->conn->query('DROP DATABASE IF EXISTS backup_test');
     $this->conn->query('CREATE DATABASE IF NOT EXISTS backup_test CHARSET utf8;');
     $dest = Connection::create(['dsn' => 'mysql:host=localhost;dbname=backup_test', 'user' => 'root', 'pass' => null, 'connection_options' => [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']]);
     $backup = new MySQLBackup();
     $backup->backup($this->conn, $dest);
 }
 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.');
 }