return "{$tableName}_{$columnName}_idx";
}
+ /**
+ * MySQL doesn't take 'DROP CONSTRAINT', need to treat primary keys as
+ * if they were indexes here, but can use 'PRIMARY KEY' special name.
+ *
+ * @param array $phrase
+ */
+ function appendAlterDropPrimary(array &$phrase)
+ {
+ $phrase[] = 'DROP PRIMARY KEY';
+ }
/**
* MySQL doesn't take 'DROP CONSTRAINT', need to treat unique keys as
$this->appendAlterDropUnique($phrase, $keyName);
}
+ if (isset($old['primary key']) && (!isset($def['primary key']) || $def['primary key'] != $old['primary key'])) {
+ $this->appendAlterDropPrimary($phrase);
+ }
+
foreach ($fields['add'] as $columnName) {
$this->appendAlterAddColumn($phrase, $columnName,
$def['fields'][$columnName]);
$this->appendAlterDropColumn($phrase, $columnName);
}
+ if (isset($def['primary key']) && (!isset($old['primary key']) || $old['primary key'] != $def['primary key'])) {
+ $this->appendAlterAddPrimary($phrase, $def['primary key']);
+ }
+
foreach ($uniques['mod'] + $uniques['add'] as $keyName) {
$this->appendAlterAddUnique($phrase, $keyName, $def['unique keys'][$keyName]);
}
$phrase[] = implode(' ', $sql);
}
+ function appendAlterAddPrimary(array &$phrase, array $def)
+ {
+ $sql = array();
+ $sql[] = 'ADD';
+ $this->appendPrimaryKeyDef($sql, $def);
+ $phrase[] = implode(' ', $sql);
+ }
+
+ function appendAlterDropPrimary(array &$phrase)
+ {
+ $phrase[] = 'DROP CONSTRAINT PRIMARY KEY';
+ }
+
function appendAlterDropUnique(array &$phrase, $keyName)
{
$phrase[] = 'DROP CONSTRAINT ' . $keyName;