|
@@ 867-872 (lines=6) @@
|
| 864 |
|
$instructions = $this->beginAlterByCopyTable($table->getName()); |
| 865 |
|
|
| 866 |
|
$tableName = $table->getName(); |
| 867 |
|
$instructions->addPostStep(function ($state) use ($column) { |
| 868 |
|
$sql = preg_replace("/(`$column`)\s+\w+\s+((NOT )?NULL)/", '$1 INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT', $state['createSQL'], 1); |
| 869 |
|
$this->execute($sql); |
| 870 |
|
|
| 871 |
|
return $state; |
| 872 |
|
}); |
| 873 |
|
|
| 874 |
|
$instructions->addPostStep(function ($state) { |
| 875 |
|
$columns = $this->fetchAll(sprintf('pragma table_info(%s)', $this->quoteTableName($state['tmpTableName']))); |
|
@@ 900-909 (lines=10) @@
|
| 897 |
|
return $newState + $state; |
| 898 |
|
}); |
| 899 |
|
|
| 900 |
|
$instructions->addPostStep(function ($state) { |
| 901 |
|
$search = "/(,?\s*PRIMARY KEY\s*\([^\)]*\)|\s+PRIMARY KEY(\s+AUTOINCREMENT)?)/"; |
| 902 |
|
$sql = preg_replace($search, '', $state['createSQL'], 1); |
| 903 |
|
|
| 904 |
|
if ($sql) { |
| 905 |
|
$this->execute($sql); |
| 906 |
|
} |
| 907 |
|
|
| 908 |
|
return $state; |
| 909 |
|
}); |
| 910 |
|
|
| 911 |
|
return $this->copyAndDropTmpTable($instructions, $table->getName()); |
| 912 |
|
} |