diff options
author | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-11-07 09:55:20 +0000 |
---|---|---|
committer | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-11-07 09:55:20 +0000 |
commit | e799f02051e5c6019f0669da2ce816bce8af46f5 (patch) | |
tree | a9289b11d3552640fcff3819a3581d3606e00314 | |
parent | 6c507c4a687eb78c3f6589b026dcb7e3ad639eb2 (diff) | |
download | brdo-e799f02051e5c6019f0669da2ce816bce8af46f5.tar.gz brdo-e799f02051e5c6019f0669da2ce816bce8af46f5.tar.bz2 |
#124979 by bjaspan: fix PostgreSQL upgrade path, keeping the primary key on the node_comment_statistics table
-rw-r--r-- | modules/system/system.install | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/system/system.install b/modules/system/system.install index 1714424f4..97f32e095 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -4418,7 +4418,23 @@ function system_update_6032() { function system_update_6033() { $ret = array(); if (db_table_exists('node_comment_statistics')) { + // On pgsql but not mysql, db_change_field() drops all keys + // involving the changed field, which in this case is the primary + // key. The normal approach is explicitly drop the pkey, change the + // field, and re-create the pkey. + // + // Unfortunately, in this case that won't work on mysql; we CANNOT + // drop the pkey because on mysql auto-increment fields must be + // included in at least one key or index. + // + // Since we cannot drop the pkey before db_change_field(), after + // db_change_field() we may or may not still have a pkey. The + // simple way out is to re-create the pkey only when using pgsql. + // Realistic requirements trump idealistic purity. db_change_field($ret, 'node_comment_statistics', 'nid', 'nid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)); + if ($GLOBALS['db_type'] == 'pgsql') { + db_add_primary_key($ret, 'node_comment_statistics', array('nid')); + } } return $ret; } |