/**
* @param Schema $schema
* @return ChangeSet
*/
public function diff(Schema $schema) : ChangeSet
{
$currentSchema = $this->connection->getSchemaManager()->createSchema();
$targetSchema = clone $currentSchema;
foreach ($schema->types() as $type) {
$tableName = $this->tableName($schema->name(), $type->name());
if ($targetSchema->hasTable($tableName)) {
$targetSchema->dropTable($tableName);
}
$this->createTable($targetSchema, $schema->name(), $type);
}
$queries = $currentSchema->getMigrateToSql($targetSchema, $this->connection->getDatabasePlatform());
return new ChangeSet($queries);
}