protected function getMigrationConfiguration()
    {
        $this->output = [];
        $that = $this;
        $outputWriter = new OutputWriter(
            function ($message) use ($that) {
                $that->output[] = $message;
            }
        );

        /** @var \Doctrine\DBAL\Connection $connection */
        $connection = $this->entityManager->getConnection();
        $schemaManager = $connection->getSchemaManager();
        if ($schemaManager->tablesExist(['flow3_doctrine_migrationstatus']) === true) {
            $schemaManager->renameTable('flow3_doctrine_migrationstatus', self::DOCTRINE_MIGRATIONSTABLENAME);
        }

        $configuration = new Configuration($connection, $outputWriter);
        $configuration->setMigrationsNamespace('Neos\Flow\Persistence\Doctrine\Migrations');
        $configuration->setMigrationsDirectory(Files::concatenatePaths([FLOW_PATH_DATA, 'DoctrineMigrations']));
        $configuration->setMigrationsTableName(self::DOCTRINE_MIGRATIONSTABLENAME);

        $configuration->createMigrationTable();

        $databasePlatformName = $this->getDatabasePlatformName();
        /** @var PackageInterface $package */
        foreach ($this->packageManager->getAvailablePackages() as $package) {
            $path = Files::concatenatePaths([
                $package->getPackagePath(),
                'Migrations',
                $databasePlatformName
            ]);
            if (is_dir($path)) {
                $configuration->registerMigrationsFromDirectory($path);
            }
        }

        return $configuration;
    }