public function apply(Application $app)
    {
        $applied = [];

        foreach ($this->upgrades as $upgrade) {
            if ($upgrade->isApplyable($app)) {
                try {
                    $upgrade->apply(
                        $app['orm.em'],
                        $app['phraseanet.appbox'],
                        $app['doctrine-migration.configuration']
                    );
                    $applied[] = $upgrade;
                } catch (\Exception $e) {
                    $upgrade->rollback(
                        $app['orm.em'],
                        $app['phraseanet.appbox'],
                        $app['doctrine-migration.configuration']
                    );
                    foreach (array_reverse($applied) as $done) {
                        $done->rollback(
                            $app['orm.em'],
                            $app['phraseanet.appbox'],
                            $app['doctrine-migration.configuration']
                        );
                    }
                    throw $e;
                }
            }
        }
    }