Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Don't create a diff if there are no mapping information changes #106

Closed
wants to merge 1 commit into from

5 participants

@StuBez

Although there is code to not generate a diff if there are no mapping information changes, there is always a statement (the abort statement if the database platform doesn't match) so a migration file is always created. This patch addresses that.

Mentioned in #41 and #104

@YetiCGN

+1

@StuBez

Does anyone have any feedback on this?

@asakurayoh

+1
Would be VERY useful. Tired to do a migration and migrate it to see it contain nothing :(

@c960657

Fixed by #160.

@stof stof closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
12 lib/Doctrine/DBAL/Migrations/Tools/Console/Command/DiffCommand.php
@@ -115,15 +115,21 @@ public function execute(InputInterface $input, OutputInterface $output)
private function buildCodeFromSql(Configuration $configuration, array $sql)
{
$currentPlatform = $configuration->getConnection()->getDatabasePlatform()->getName();
- $code = array(
- "\$this->abortIf(\$this->connection->getDatabasePlatform()->getName() != \"$currentPlatform\");", "",
- );
+ $abortCode = "\$this->abortIf(\$this->connection->getDatabasePlatform()->getName() != \"$currentPlatform\");";
+
+ $code = array();
foreach ($sql as $query) {
if (strpos($query, $configuration->getMigrationsTableName()) !== false) {
continue;
}
$code[] = "\$this->addSql(\"$query\");";
}
+
+ if (empty($code)) {
+ return;
+ }
+
+ array_unshift($code, $abortCode, "");
return implode("\n", $code);
}
}
Something went wrong with that request. Please try again.