Skip to content

Instantly share code, notes, and snippets.

@docteurklein
Created April 30, 2020 06:26
Show Gist options
  • Save docteurklein/deb8fd757822cd00f8432ac7a6c61d1d to your computer and use it in GitHub Desktop.
Save docteurklein/deb8fd757822cd00f8432ac7a6c61d1d to your computer and use it in GitHub Desktop.
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\DriverManager;
$connFrom = DriverManager::getConnection([
'url' => "mysql://root:[email protected]/test1",
], new Configuration);
$connTo = DriverManager::getConnection([
'url' => "mysql://root:[email protected]/test2",
], new Configuration);
$diff = Comparator::compareSchemas(
$connFrom->getSchemaManager()->createSchema(),
$connTo->getSchemaManager()->createSchema(),
);
echo implode(";\n", $diff->toSql($connTo->getDatabasePlatform()));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment