Skip to content

Instantly share code, notes, and snippets.

@docteurklein
Created April 30, 2020 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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:root@127.0.0.1/test1",
], new Configuration);
$connTo = DriverManager::getConnection([
'url' => "mysql://root:root@127.0.0.1/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