Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.2.0-ALPHA2
-
Fix Version/s: 1.2.0-ALPHA3
-
Component/s: Migrations
-
Labels:None
Description
Hello,
Currently if within a single migration class one uses the automation methods $this->table() and $this->foreignKey() the process will fail when moving down because the system will execute the down direction in the same order as the up direction. For example:
public function migrate($direction) {
$this->table($direction, 'mytable', ...);
$this->table($direction, 'myrelatedtable', ... );
$this->foreignKey($direction, 'mytable', 'myfkname', ...);
}
Going up, everything is fine. The tables are created and the FK is applied. Going down, however will error out since by the time the FK is going to be removed the table it belons to is gone.
Hmm. Would this fix the problem? I am unsure if this would cause any other problems.
Index: lib/Doctrine/Migration.php =================================================================== --- lib/Doctrine/Migration.php (revision 6437) +++ lib/Doctrine/Migration.php (working copy) @@ -499,6 +499,9 @@ if ($migration->getNumChanges() > 0) { $changes = $migration->getChanges(); + if ($direction == 'down') { + $changes = array_reverse($changes); + } foreach ($changes as $value) { list($type, $change) = $value; $funcName = 'process' . Doctrine_Inflector::classify($type);