LazyRecord\Command\MigrateAutomaticCommand::execute PHP Method

execute() public method

public execute ( )
    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.');
    }