Add primary key to revision database table

Fixes #218
This commit is contained in:
Fedor A. Fetisov 2018-01-12 01:07:34 +03:00
parent 5921115af0
commit 0cf963ac5e
2 changed files with 27 additions and 1 deletions

View File

@ -226,7 +226,7 @@ operatorstatistics:
revision:
fields:
id: "INT NOT NULL"
id: "INT NOT NULL PRIMARY KEY"
# Contains relations between operators and groups
operatortoopgroup:

View File

@ -439,4 +439,30 @@ class Updater
return true;
}
/**
* Performs all database updates needed for 3.1.0.
*
* @return boolean True if the updates have been applied successfully and
* false otherwise.
*/
protected function update30100()
{
$db = $this->getDatabase();
if (!$db) {
return false;
}
try {
// Alter plugin table.
$db->query('ALTER TABLE {revision} ADD PRIMARY KEY (id)');
} catch (\Exception $e) {
$this->errors[] = getlocal('Cannot update tables: {0}', $e->getMessage());
return false;
}
return true;
}
}