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

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

Each data source has it's own migration timestamp, we use the data source ID to get the migration timestamp and filter the migration script.
public getUpgradeScripts ( Connection $conn, BaseDriver $driver )
$conn LazyRecord\Connection
$driver SQLBuilder\Driver\BaseDriver
    public function getUpgradeScripts(Connection $conn, BaseDriver $driver)
    {
        $lastMigrationId = $this->getLastMigrationId($conn, $driver);
        $this->logger->debug("Found last migration id: {$lastMigrationId}");
        $scripts = $this->loadMigrationScripts();
        return array_filter($scripts, function ($class) use($lastMigrationId) {
            $id = $class::getId();
            return $id > $lastMigrationId;
        });
    }

Usage Example

Пример #1
0
 public function execute()
 {
     $dsId = $this->getCurrentDataSourceId();
     $runner = new MigrationRunner($dsId);
     $runner->load('db/migrations');
     $scripts = $runner->getUpgradeScripts($dsId);
     $count = count($scripts);
     $this->logger->info("Found " . $count . ($count > 1 ? ' migration scripts' : ' migration script') . ' to be executed.');
     foreach ($scripts as $script) {
         $this->logger->info('- ' . $script, 1);
     }
 }
All Usage Examples Of LazyRecord\Migration\MigrationRunner::getUpgradeScripts