mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-01 19:22:42 +01:00
Work around an issue in MariaDB where dropping a column from a UNIQUE KEY fails
Summary: See T13193. See T13077. If we drop a column which is part of a UNIQUE KEY, MariaDB raises an error. This is probably a bad idea on our side anyway, but in this case it wasn't an obviously bad idea. To get around this: - Drop the unique key, if it exists, before dropping the column. - Explicitly add the new unique key afterward. Test Plan: Ran `bin/storage upgrade` locally without issue, but I'm on MySQL. Will follow up on T13193. Reviewers: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Differential Revision: https://secure.phabricator.com/D19624
This commit is contained in:
parent
75a0455152
commit
0a77b0e53e
3 changed files with 23 additions and 1 deletions
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// See T13193. We're about to drop the "documentID" column, which is part of
|
||||||
|
// a UNIQUE KEY. In MariaDB, we must first drop the "documentID" key or we get
|
||||||
|
// into deep trouble.
|
||||||
|
|
||||||
|
// There's no "IF EXISTS" modifier for "ALTER TABLE" so run this as a PHP patch
|
||||||
|
// instead of an SQL patch.
|
||||||
|
|
||||||
|
$table = new PhrictionContent();
|
||||||
|
$conn = $table->establishConnection('w');
|
||||||
|
|
||||||
|
try {
|
||||||
|
queryfx(
|
||||||
|
$conn,
|
||||||
|
'ALTER TABLE %T DROP KEY documentID',
|
||||||
|
$table->getTableName());
|
||||||
|
} catch (AphrontQueryException $ex) {
|
||||||
|
// Ignore.
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE {$NAMESPACE}_phriction.phriction_content
|
||||||
|
ADD UNIQUE KEY `key_version` (documentPHID, version);
|
|
@ -34,7 +34,7 @@ final class PhrictionContent
|
||||||
'description' => 'text',
|
'description' => 'text',
|
||||||
),
|
),
|
||||||
self::CONFIG_KEY_SCHEMA => array(
|
self::CONFIG_KEY_SCHEMA => array(
|
||||||
'documentID' => array(
|
'key_version' => array(
|
||||||
'columns' => array('documentPHID', 'version'),
|
'columns' => array('documentPHID', 'version'),
|
||||||
'unique' => true,
|
'unique' => true,
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue