Commit d7f3ace2 authored by Dries's avatar Dries
Browse files

- Patch #62478 by Cvbge: fixed some database inconsistencies with PostgreSQL.

parent 8c8af42c
......@@ -419,13 +419,14 @@ CREATE TABLE node (
promote integer NOT NULL default '0',
moderate integer NOT NULL default '0',
sticky integer NOT NULL default '0',
PRIMARY KEY (nid)
PRIMARY KEY (nid, vid)
);
CREATE INDEX node_nid_idx ON node(nid);
CREATE INDEX node_type_idx ON node(type);
CREATE INDEX node_title_type_idx ON node(title,type);
CREATE INDEX node_status_idx ON node(status);
CREATE INDEX node_uid_idx ON node(uid);
CREATE INDEX node_vid_idx ON node(vid);
CREATE UNIQUE INDEX node_vid_idx ON node(vid);
CREATE INDEX node_moderate_idx ON node (moderate);
CREATE INDEX node_promote_status_idx ON node (promote, status);
CREATE INDEX node_created_idx ON node(created);
......
......@@ -1964,7 +1964,9 @@ function system_update_179() {
function system_update_180() {
$ret = array();
if ($GLOBALS['db_type'] == 'mysql') {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {node} DROP PRIMARY KEY");
$ret[] = update_sql("ALTER TABLE {node} ADD PRIMARY KEY (nid, vid)");
$ret[] = update_sql("ALTER TABLE {node} DROP INDEX vid");
......@@ -1972,9 +1974,14 @@ function system_update_180() {
$ret[] = update_sql("ALTER TABLE {node} ADD INDEX (nid)");
$ret[] = update_sql("ALTER TABLE {node_counter} CHANGE nid nid INT(10) NOT NULL DEFAULT '0'");
}
else { // pgsql
// Insert queries here.
break;
case 'pgsql':
$ret[] = update_sql("ALTER TABLE {node} DROP CONSTRAINT {node}_pkey"); // Change PK
$ret[] = update_sql("ALTER TABLE {node} ADD PRIMARY KEY (nid, vid)");
$ret[] = update_sql('DROP INDEX {node}_vid_idx'); // Change normal index to UNIQUE index
$ret[] = update_sql('CREATE UNIQUE INDEX {node}_vid_idx ON {node}(vid)');
$ret[] = update_sql('CREATE INDEX {node}_nid_idx ON {node}(nid)'); // Add index on nid
break;
}
return $ret;
......@@ -1988,7 +1995,7 @@ function system_update_181() {
$ret[] = update_sql("ALTER TABLE {profile_fields} ADD autocomplete TINYINT(1) NOT NULL AFTER visibility ;");
break;
case 'pgsql':
db_add_column($ret, 'profile_fields', 'autocomplete', 'smallint');
db_add_column($ret, 'profile_fields', 'autocomplete', 'smallint', array('not null' => TRUE, 'default' => 0));
break;
}
return $ret;
......@@ -2001,7 +2008,7 @@ function system_update_182() {
$ret = array();
if ($GLOBALS['db_type'] == 'pgsql') {
$ret[] = update_sql('ALTER TABLE {locales_target} DROP CONSTRAINT {locales_target}_lid_idx');
$ret[] = update_sql('ALTER TABLE {locales_target} DROP CONSTRAINT {locales_target}_lid_key');
$ret[] = update_sql('CREATE INDEX {locales_target}_lid_idx ON {locales_target} (lid)');
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment