Created
February 3, 2014 12:25
-
-
Save anonymous/8782990 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$schemaGenerator = new SchemaGenerator(...); | |
$platform = new Doctrine\DBAL\Platforms\MySqlPlatform(); | |
$schema = $schemaGenerator->createSchema(...); | |
$sqls = []; | |
if (file_exists(__DIR__ . '/schema.log')) { | |
$fromSchema = unserialize(file_get_contents(__DIR__ . '/schema.log')); | |
$sqls = $schema->getMigrateFromSql($fromSchema, $platform); | |
} else { | |
$sqls = $schema->toSql($platform); | |
} | |
// Save schema | |
file_put_contents('schema.log', serialize($schema)); | |
if (count($sqls) > 0) { | |
foreach ($sqls as $sql) | |
{ | |
$connection->query($sql); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment