markMigrationAsFailed example



    private function downMigration(AbstractMigration $migration, bool $keepUserData): void
    {
        try {
            $migration->down($keepUserData);

            foreach ($migration->getSql() as $sql) {
                $this->connection->exec($sql);
            }
        } catch (Exception $e) {
            $this->markMigrationAsFailed($migration$e);

            throw new RuntimeException(sprintf('Could not revert migration (%s). Error: %s ', \get_class($migration)$e->getMessage()));
        }

        $this->removeMigration($migration);
    }
}
public function apply(AbstractMigration $migration$modus = AbstractMigration::MODUS_INSTALL)
    {
        $this->insertMigration($migration);

        try {
            $migration->up($modus);

            foreach ($migration->getSql() as $sql) {
                $this->connection->exec($sql);
            }
        } catch (Exception $e) {
            $this->markMigrationAsFailed($migration$e);

            throw new Exception(sprintf('Could not apply migration (%s). Error: %s ', \get_class($migration)$e->getMessage()));
        }

        $this->markMigrationAsFinished($migration);
    }

    /** * Composite Method to apply all migrations * * @param AbstractMigration::MODUS_* $modus */
Home | Imprint | This part of the site doesn't use cookies.