Permalink
Browse files

Fix: port PR #290 from Propel

  • Loading branch information...
K-Phoen committed Mar 30, 2012
1 parent beae90b commit f1ccfc26b0d29a2a8780525738299a7c63e7dd67
@@ -37,7 +37,7 @@ class MigrationManager extends AbstractManager
/**
* @var string
- */
+ */
protected $migrationTable;
/**
@@ -238,6 +238,11 @@ public function getValidMigrationTimestamps()
return $migrationTimestamps;
}
+ public function hasPendingMigrations()
+ {
+ return array() !== $this->getValidMigrationTimestamps();
+ }
+
public function getAlreadyExecutedMigrationTimestamps()
{
$oldestMigrationTimestamp = $this->getOldestDatabaseVersion();
@@ -104,6 +104,14 @@ public function main()
if (!$connections) {
throw new Exception('You must define database connection settings in a buildtime-conf.xml file to use diff');
}
+ $manager = new PropelMigrationManager();
+ $manager->setConnections($connections);
+ $manager->setMigrationDir($this->getOutputDirectory());
+
+ if ($manager->hasPendingMigrations()) {
+ throw new Exception('Uncommitted migrations have been found ; you should either execute or delete them before rerunning the \'diff\' task');
+ }
+
$totalNbTables = 0;
$ad = new AppData();
foreach ($connections as $name => $params) {
@@ -136,9 +144,6 @@ public function main()
// comparing models
$this->log('Comparing models...');
- $manager = new MigrationManager();
- $manager->setConnections($connections);
- $manager->setMigrationDir($this->getOutputDirectory());
$migrationsUp = array();
$migrationsDown = array();
foreach ($ad->getDatabases() as $database) {

0 comments on commit f1ccfc2

Please sign in to comment.