diff options
author | Brice Maron <brice@bmaron.net> | 2012-10-26 15:54:16 +0000 |
---|---|---|
committer | Brice Maron <brice@bmaron.net> | 2012-10-26 15:56:53 +0000 |
commit | db2d1f6822fbb3c34a5834dda10c7ce57c0153cc (patch) | |
tree | 93ef78c4d62e79728bcc555484778fa10e5018e3 | |
parent | 1888ac0d41823d9d15e28279d3a701412c679460 (diff) | |
download | nextcloud-server-db2d1f6822fbb3c34a5834dda10c7ce57c0153cc.tar.gz nextcloud-server-db2d1f6822fbb3c34a5834dda10c7ce57c0153cc.zip |
Fix migration problems for postgresql with MDB2 fix owncloud/apps#21
Ref of MDB2 bug is 19676
-rw-r--r-- | 3rdparty/MDB2/Driver/Manager/pgsql.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/3rdparty/MDB2/Driver/Manager/pgsql.php b/3rdparty/MDB2/Driver/Manager/pgsql.php index f2c2137dc8b..3e70f3a3b25 100644 --- a/3rdparty/MDB2/Driver/Manager/pgsql.php +++ b/3rdparty/MDB2/Driver/Manager/pgsql.php @@ -363,6 +363,7 @@ class MDB2_Driver_Manager_pgsql extends MDB2_Driver_Manager_Common return MDB2_OK; } + $unquoted_name = $name; $name = $db->quoteIdentifier($name, true); if (!empty($changes['remove']) && is_array($changes['remove'])) { @@ -398,6 +399,7 @@ class MDB2_Driver_Manager_pgsql extends MDB2_Driver_Manager_Common if (!empty($changes['change']) && is_array($changes['change'])) { foreach ($changes['change'] as $field_name => $field) { + $unquoted_field_name = $field_name; $field_name = $db->quoteIdentifier($field_name, true); if (!empty($field['definition']['type'])) { $server_info = $db->getServerVersion(); @@ -419,7 +421,14 @@ class MDB2_Driver_Manager_pgsql extends MDB2_Driver_Manager_Common return $result; } } - if (array_key_exists('default', $field['definition'])) { + if (array_key_exists('autoincrement', $field['definition'])) { + $query = "ALTER $field_name SET DEFAULT nextval(".$db->quote($unquoted_name.'_'.$unquoted_field_name.'_seq', 'text').")"; + $result = $db->exec("ALTER TABLE $name $query"); + if (PEAR::isError($result)) { + return $result; + } + } + elseif (array_key_exists('default', $field['definition'])) { $query = "ALTER $field_name SET DEFAULT ".$db->quote($field['definition']['default'], $field['definition']['type']); $result = $db->exec("ALTER TABLE $name $query"); if (PEAR::isError($result)) { |