Skip to content

Commit

Permalink
Dropped indexes can have constraints, drop those first if they exist
Browse files Browse the repository at this point in the history
  • Loading branch information
bartv2 committed Jul 18, 2013
1 parent 380f5a9 commit 25e8568
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,27 @@ public function getAlterTableSQL(TableDiff $diff)
return array_merge($sql, $tableSql, $columnSql);
}


/**
* {@inheritDoc}
*/
protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff)
{
$sql = array();
$table = $diff->name;
foreach ($diff->changedIndexes as $changedKey => $changedIndex) {

$sql[] = $this->getDropConstraintSQL('IF EXISTS '. $changedIndex->getName(), $table);
$sql[] = $this->getDropIndexSQL('IF EXISTS '. $changedIndex->getName(), $table);
$diff->addedIndexes[$changedKey] = $diff->changedIndexes[$changedKey];
unset($diff->changedIndexes[$changedKey]);
}

$sql = array_merge($sql, parent::getPreAlterTableIndexForeignKeySQL($diff));

return $sql;
}

/**
* {@inheritDoc}
*/
Expand Down

0 comments on commit 25e8568

Please sign in to comment.