LazyRecord\Migration\MigrationRunner::runUpgradeAutomatically PHP Метод

runUpgradeAutomatically() публичный Метод

public runUpgradeAutomatically ( Connection $conn, BaseDriver $driver, array $schemas, OptionResult $options = null )
$conn LazyRecord\Connection
$driver SQLBuilder\Driver\BaseDriver
$schemas array
$options GetOptionKit\OptionResult
    public function runUpgradeAutomatically(Connection $conn, BaseDriver $driver, array $schemas, OptionResult $options = null)
    {
        $script = new AutomaticMigration($conn, $driver, $this->logger, $options);
        try {
            $this->logger->info('Begining transaction...');
            $conn->beginTransaction();
            // where to find the schema?
            $script->upgrade($schemas);
            $this->logger->info('Committing...');
            $conn->commit();
        } catch (Exception $e) {
            $this->logger->error('Exception was thrown: ' . $e->getMessage());
            $this->logger->warn('Rolling back ...');
            $conn->rollback();
            $this->logger->warn('Recovered, escaping...');
            throw $e;
        }
    }

Usage Example

 public function execute()
 {
     $dsId = $this->getCurrentDataSourceId();
     $container = ServiceContainer::getInstance();
     $runner = new MigrationRunner($dsId);
     $runner->runUpgradeAutomatically($this->options);
     $this->logger->info('Done.');
 }
All Usage Examples Of LazyRecord\Migration\MigrationRunner::runUpgradeAutomatically