src/Migrator.php
public function run(CapsuleInterface $capsule = null): ?MigrationInterface
    {
        if (!$this->isConfigured()) {
            throw new MigrationException("Unable to run migration, Migrator not configured");
        }

        foreach ($this->getMigrations() as $migration) {
            if ($migration->getState()->getStatus() != State::STATUS_PENDING) {
                continue;
            }

            $capsule = $capsule ?? new Capsule($this->dbal->database($migration->getDatabase()));
            $capsule->getDatabase($migration->getDatabase())->transaction(function () use ($migration, $capsule) {
                $migration->withCapsule($capsule)->up();
            });

            $this->migrationTable($migration->getDatabase())->insertOne([
                'migration'     => $migration->getState()->getName(),
                'time_executed' => new \DateTime('now')
            ]);

            return $migration->withState($this->resolveState($migration));
        }

        return null;
    }
public function run(CapsuleInterface $capsule = null): ?MigrationInterface
    {
        if (!$this->isConfigured()) {
            throw new MigrationException("Unable to run migration, Migrator not configured");
        }

        foreach ($this->getMigrations() as $migration) {
            if ($migration->getState()->getStatus() != State::STATUS_PENDING) {
                continue;
            }

            $capsule = $capsule ?? new Capsule($this->dbal->database($migration->getDatabase()));
            $capsule->getDatabase($migration->getDatabase())->transaction(function () use ($migration, $capsule) {
                $migration->withCapsule($capsule)->up();
            });

            $this->migrationTable($migration->getDatabase())->insertOne([
                'migration'     => $migration->getState()->getName(),
                'time_executed' => new \DateTime('now')
            ]);

            return $migration->withState($this->resolveState($migration));
        }

        return null;
    }
Execute one migration and return it's instance.

@param CapsuleInterface $capsule
@return null|MigrationInterface

@throws \Throwable