summaryrefslogtreecommitdiff
path: root/database
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2004-08-06 09:49:25 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2004-08-06 09:49:25 +0000
commitcabd6c892cbce8c1483c46fe76ce3885cd5f9e41 (patch)
treea0b9374d46538f7adf74b49833658b13385df349 /database
parentf584cdf74fb734e839cebe40631bd913c766a553 (diff)
downloadbrdo-cabd6c892cbce8c1483c46fe76ce3885cd5f9e41.tar.gz
brdo-cabd6c892cbce8c1483c46fe76ce3885cd5f9e41.tar.bz2
#9810: PostgreSQL updates by Adrian.
Diffstat (limited to 'database')
-rw-r--r--database/database.mysql6
-rw-r--r--database/database.pgsql21
-rw-r--r--database/updates.inc86
3 files changed, 93 insertions, 20 deletions
diff --git a/database/database.mysql b/database/database.mysql
index 69b29e3a1..b630c1734 100644
--- a/database/database.mysql
+++ b/database/database.mysql
@@ -341,9 +341,9 @@ CREATE TABLE node (
KEY node_changed (changed)
) TYPE=MyISAM;
-#
-# Table structure for table `node_access`
-#
+--
+-- Table structure for table `node_access`
+--
CREATE TABLE node_access (
nid int(10) unsigned NOT NULL default '0',
diff --git a/database/database.pgsql b/database/database.pgsql
index a4eaf9af4..d59fa6e6b 100644
--- a/database/database.pgsql
+++ b/database/database.pgsql
@@ -343,6 +343,21 @@ CREATE INDEX node_created ON node(created);
CREATE INDEX node_changed ON node(changed);
--
+-- Table structure for table `node_access`
+--
+
+CREATE TABLE node_access (
+ nid SERIAL,
+ gid integer NOT NULL default '0',
+ realm text NOT NULL default '',
+ grant_view smallint NOT NULL default '0',
+ grant_update smallint NOT NULL default '0',
+ grant_delete smallint NOT NULL default '0',
+ PRIMARY KEY (nid,gid,realm)
+);
+
+
+--
-- Table structure for table 'node_counter'
--
@@ -700,3 +715,9 @@ BEGIN
RETURN random();
END;
' LANGUAGE 'plpgsql';
+
+CREATE FUNCTION "concat"(text, text) RETURNS text AS '
+BEGIN
+ RETURN $1 || $2;
+END;
+' LANGUAGE 'plpgsql';
diff --git a/database/updates.inc b/database/updates.inc
index 7eddd2910..21010b747 100644
--- a/database/updates.inc
+++ b/database/updates.inc
@@ -1090,11 +1090,15 @@ function update_86() {
$ret = array();
$ret[] = update_sql("INSERT INTO {users_roles} (uid, rid) SELECT uid, rid FROM {users}");
// TODO: should we verify the insert above worked before dropping rid?
- $ret[] = update_sql("ALTER TABLE {users} DROP rid");
+ if ($GLOBALS['db_type'] == 'mysql') {
+ //only the most recent versions of postgres support dropping columns
+ $ret[] = update_sql("ALTER TABLE {users} DROP rid");
+ }
return $ret;
}
function update_87() {
+ // Works for both postgres and mysql
$ret = array();
$ret[] = update_sql("ALTER TABLE {comments} ADD name varchar(60) DEFAULT NULL");
$ret[] = update_sql("ALTER TABLE {comments} ADD mail varchar(64) DEFAULT NULL");
@@ -1104,16 +1108,31 @@ function update_87() {
function update_88() {
$ret = array();
- $ret[] = update_sql("ALTER TABLE {menu} DROP status");
- $ret[] = update_sql("ALTER TABLE {menu} DROP visibility");
- $ret[] = update_sql("ALTER TABLE {menu} ADD type INT(2) UNSIGNED DEFAULT '0' NOT NULL");
+
+ if ($GLOBALS['db_type'] == 'mysql') {
+ $ret[] = update_sql("ALTER TABLE {menu} DROP status");
+ $ret[] = update_sql("ALTER TABLE {menu} DROP visibility");
+ $ret[] = update_sql("ALTER TABLE {menu} ADD type INT(2) UNSIGNED DEFAULT '0' NOT NULL");
+ }
+ else {
+ $ret[] = update_sql("ALTER TABLE {menu} ADD type smallint");
+ $ret[] = update_sql("ALTER TABLE {menu} ALTER COLUMN type SET DEFAULT '0'");
+ $ret[] = update_sql("UPDATE {menu} SET type = '0'");
+ $ret[] = update_sql("ALTER TABLE {menu} ALTER COLUMN type SET NOT NULL");
+ }
$ret[] = update_sql("DELETE FROM {menu}");
return $ret;
}
function update_89() {
$ret = array();
- $ret[] = update_sql("ALTER TABLE {node} CHANGE static sticky INT(2) DEFAULT '0' NOT NULL");
+
+ if ($GLOBALS['db_type'] == 'mysql') {
+ $ret[] = update_sql("ALTER TABLE {node} CHANGE static sticky INT(2) DEFAULT '0' NOT NULL");
+ }
+ else {
+ $ret[] = update_sql("ALTER TABLE {node} RENAME static TO sticky;");
+ }
// Change the node settings, so that it uses node_sticky_$type instead of node_static_$type
$result = db_query("SELECT * FROM {variable} WHERE name LIKE 'node_static_%'");
@@ -1128,7 +1147,13 @@ function update_89() {
}
function update_90() {
- $ret[] = update_sql("ALTER TABLE {profile_fields} CHANGE overview visibility INT(1) UNSIGNED DEFAULT '0' NOT NULL");
+
+ if ($GLOBALS['db_type'] == 'mysql') {
+ $ret[] = update_sql("ALTER TABLE {profile_fields} CHANGE overview visibility INT(1) UNSIGNED DEFAULT '0' NOT NULL");
+ }
+ else {
+ $ret[] = update_sql("ALTER TABLE {profile_fields} RENAME overview TO visibility");
+ }
$ret[] = update_sql("UPDATE {profile_fields} SET visibility = 2 WHERE visibility = 1");
$ret[] = update_sql("UPDATE {profile_fields} SET visibility = 1 WHERE visibility = 0");
return $ret;
@@ -1137,7 +1162,7 @@ function update_90() {
function update_91() {
$ret = array();
if ($GLOBALS["db_type"] == "pgsql") {
- $ret[] = update_sql("CREATE INDEX node_created ON {node} (created)");
+ // node_created was created implicitly somewhere else
$ret[] = update_sql("CREATE INDEX node_changed ON {node} (changed)");
}
else {
@@ -1192,15 +1217,34 @@ function update_94() {
function update_95() {
$ret = array();
- $ret[] = update_sql("CREATE TABLE {node_access} (
- nid int(10) unsigned NOT NULL default '0',
- gid int(10) unsigned NOT NULL default '0',
- realm varchar(255) NOT NULL default '',
- grant_view tinyint(1) unsigned NOT NULL default '0',
- grant_update tinyint(1) unsigned NOT NULL default '0',
- grant_delete tinyint(1) unsigned NOT NULL default '0',
- PRIMARY KEY (nid,gid,realm)
- )");
+ if ($GLOBALS['db_type'] == 'mysql') {
+ $ret[] = update_sql("CREATE TABLE {node_access} (
+ nid int(10) unsigned NOT NULL default '0',
+ gid int(10) unsigned NOT NULL default '0',
+ realm varchar(255) NOT NULL default '',
+ grant_view tinyint(1) unsigned NOT NULL default '0',
+ grant_update tinyint(1) unsigned NOT NULL default '0',
+ grant_delete tinyint(1) unsigned NOT NULL default '0',
+ PRIMARY KEY (nid,gid,realm)
+ )");
+ }
+ else {
+ $ret[] = update_sql("CREATE TABLE {node_access} (
+ nid SERIAL,
+ gid integer NOT NULL default '0',
+ realm text NOT NULL default '',
+ grant_view smallint NOT NULL default '0',
+ grant_update smallint NOT NULL default '0',
+ grant_delete smallint NOT NULL default '0',
+ PRIMARY KEY (nid,gid,realm)
+ )");
+
+ $ret[] = update_sql("CREATE FUNCTION \"concat\"(text, text) RETURNS text AS '
+ BEGIN
+ RETURN $1 || $2;
+ END;
+ ' LANGUAGE 'plpgsql';");
+ }
$ret[] = update_sql("INSERT INTO {node_access} VALUES (0, 0, 'all', 1, 0, 0);");
return $ret;
}
@@ -1212,7 +1256,15 @@ function update_96() {
$ret[] = update_sql('ALTER TABLE {accesslog} ADD title VARCHAR(255) DEFAULT NULL');
$ret[] = update_sql('ALTER TABLE {accesslog} ADD path VARCHAR(255) DEFAULT NULL');
- $ret[] = update_sql("ALTER TABLE {menu} ADD description varchar(255) DEFAULT '' NOT NULL");
+ if ($GLOBALS['db_type'] == 'mysql') {
+ $ret[] = update_sql("ALTER TABLE {menu} ADD description varchar(255) DEFAULT '' NOT NULL");
+ }
+ else {
+ $ret[] = update_sql("ALTER TABLE {menu} ADD description smallint");
+ $ret[] = update_sql("ALTER TABLE {menu} ALTER COLUMN description SET DEFAULT '0'");
+ $ret[] = update_sql("UPDATE {menu} SET description = '0'");
+ $ret[] = update_sql("ALTER TABLE {menu} ALTER COLUMN description SET NOT NULL");
+ }
return $ret;
}