Skip to content

Instantly share code, notes, and snippets.

Created February 3, 2014 12:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/8782990 to your computer and use it in GitHub Desktop.
Save anonymous/8782990 to your computer and use it in GitHub Desktop.
$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