Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix: port PR #290 from Propel

  • Loading branch information...
commit f1ccfc26b0d29a2a8780525738299a7c63e7dd67 1 parent beae90b
@K-Phoen K-Phoen authored
View
7 src/Propel/Generator/Manager/MigrationManager.php
@@ -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();
View
11 src/Propel/Generator/Task/PropelSQLDiffTask.php
@@ -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) {
Please sign in to comment.
Something went wrong with that request. Please try again.