|
@@ 723-739 (lines=17) @@
|
| 720 |
|
$tableName = $diff->getName($this)->getQuotedName($this); |
| 721 |
|
|
| 722 |
|
// Dropping primary keys requires to unset autoincrement attribute on the particular column first. |
| 723 |
|
foreach ($index->getColumns() as $columnName) { |
| 724 |
|
if (! $diff->fromTable->hasColumn($columnName)) { |
| 725 |
|
continue; |
| 726 |
|
} |
| 727 |
|
|
| 728 |
|
$column = $diff->fromTable->getColumn($columnName); |
| 729 |
|
|
| 730 |
|
if ($column->getAutoincrement() === true) { |
| 731 |
|
$column->setAutoincrement(false); |
| 732 |
|
|
| 733 |
|
$sql[] = 'ALTER TABLE ' . $tableName . ' MODIFY ' . |
| 734 |
|
$this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray()); |
| 735 |
|
|
| 736 |
|
// original autoincrement information might be needed later on by other parts of the table alteration |
| 737 |
|
$column->setAutoincrement(true); |
| 738 |
|
} |
| 739 |
|
} |
| 740 |
|
|
| 741 |
|
return $sql; |
| 742 |
|
} |
|
@@ 757-773 (lines=17) @@
|
| 754 |
|
foreach ($diff->changedIndexes as $changedIndex) { |
| 755 |
|
// Changed primary key |
| 756 |
|
if ($changedIndex->isPrimary() && $diff->fromTable instanceof Table) { |
| 757 |
|
foreach ($diff->fromTable->getPrimaryKeyColumns() as $columnName) { |
| 758 |
|
$column = $diff->fromTable->getColumn($columnName); |
| 759 |
|
|
| 760 |
|
// Check if an autoincrement column was dropped from the primary key. |
| 761 |
|
if ($column->getAutoincrement() && ! in_array($columnName, $changedIndex->getColumns())) { |
| 762 |
|
// The autoincrement attribute needs to be removed from the dropped column |
| 763 |
|
// before we can drop and recreate the primary key. |
| 764 |
|
$column->setAutoincrement(false); |
| 765 |
|
|
| 766 |
|
$sql[] = 'ALTER TABLE ' . $table . ' MODIFY ' . |
| 767 |
|
$this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray()); |
| 768 |
|
|
| 769 |
|
// Restore the autoincrement attribute as it might be needed later on |
| 770 |
|
// by other parts of the table alteration. |
| 771 |
|
$column->setAutoincrement(true); |
| 772 |
|
} |
| 773 |
|
} |
| 774 |
|
} |
| 775 |
|
} |
| 776 |
|
|