Dumplie\Metadata\Infrastructure\Doctrine\Dbal\DoctrineStorage::diff PHP Method

diff() public method

public diff ( Schema $schema ) : ChangeSet
$schema Dumplie\Metadata\Schema
return Dumplie\Metadata\Schema\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);
    }