From 33da2184e93fd19c3f29762c309464a3d4c4ad6d Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Sat, 14 Dec 2002 13:07:55 +0000 Subject: [PATCH] Nearly there git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@3190 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/update_to_204.php | 170 +++++++++++++++++++++++----------------- 1 file changed, 100 insertions(+), 70 deletions(-) diff --git a/phpBB/update_to_204.php b/phpBB/update_to_204.php index 1488a03162..095978ca9c 100644 --- a/phpBB/update_to_204.php +++ b/phpBB/update_to_204.php @@ -23,15 +23,14 @@ function _sql($sql, &$errored, &$error_ary, $echo_dot = true) { global $db; - if( !($result = $db->sql_query($sql)) ) + if (!($result = $db->sql_query($sql))) { $errored = true; - $error_ary['sql'][] = ( is_array($sql) ) ? $sql[$i] : $sql; + $error_ary['sql'][] = (is_array($sql)) ? $sql[$i] : $sql; $error_ary['error_code'][] = $db->sql_error(); } -//echo "\n\n

\n\n$sql\n\n

\n\n"; - if ( $echo_dot ) + if ($echo_dot) { echo ". \n"; flush(); @@ -111,7 +110,7 @@ echo '

Database type    :: ' . SQL_LAYER . '
'; $sql = "SELECT config_value FROM " . CONFIG_TABLE . " WHERE config_name = 'version'"; -if ( !($result = $db->sql_query($sql)) ) +if (!($result = $db->sql_query($sql))) { die("Couldn't obtain version info"); } @@ -120,7 +119,7 @@ $row = $db->sql_fetchrow($result); $sql = array(); -switch ( $row['config_value'] ) +switch ($row['config_value']) { case '': echo 'Previous version :: < RC-3


'; @@ -138,10 +137,13 @@ switch ( $row['config_value'] ) echo 'Updated version  :: 2' . $updates_to_version . '

' ."\n"; -switch ( $row['config_value'] ) +// +// Schema updates +// +switch ($row['config_value']) { case '': - switch ( SQL_LAYER ) + switch (SQL_LAYER) { case 'mysql': case 'mysql4': @@ -379,7 +381,7 @@ switch ( $row['config_value'] ) case 'RC-3': case 'RC-4': case '.0.0': - switch ( SQL_LAYER ) + switch (SQL_LAYER) { case 'mysql': case 'mysql4': @@ -421,7 +423,7 @@ switch ( $row['config_value'] ) } case '.0.1': - switch ( SQL_LAYER ) + switch (SQL_LAYER) { case 'mysql': case 'mysql4': @@ -456,48 +458,58 @@ switch ( $row['config_value'] ) case '.0.3': - if (empty($batch)) + // Add indexes to post_id in search match table (+ word_id for MS Access) + switch (SQL_LAYER) { - // Add indexes to post_id in search match table ( + word_id for MS Access) - switch (SQL_LAYER) - { - case 'mysql': - case 'mysql4': - $sql[] = "ALTER TABLE " . SEARCH_MATCH_TABLE . " ADD INDEX post_id (post_id)"; - break; + case 'mysql': + case 'mysql4': + $sql[] = "ALTER TABLE " . SEARCH_MATCH_TABLE . " ADD INDEX post_id (post_id)"; + break; - case 'postgresql': - $sql[] = "CREATE INDEX post_id_" . SEARCH_MATCH_TABLE . " ON " . SEARCH_MATCH_TABLE . " (post_id)"; - break; + case 'postgresql': + $sql[] = "CREATE INDEX post_id_" . SEARCH_MATCH_TABLE . " ON " . SEARCH_MATCH_TABLE . " (post_id)"; + break; - case 'msaccess': - $sql[] = "CREATE INDEX " . SEARCH_MATCH_TABLE . " ON " . SEARCH_MATCH_TABLE . " ([post_id])"; - $sql[] = "CREATE INDEX " . SEARCH_MATCH_TABLE . "_1 ON " . SEARCH_MATCH_TABLE . " ([word_id])"; - break; - } - - // Regenerate groups table with incremented group_id for pgsql - // ... missing in 2.0.3 ... - switch (SQL_LAYER) - { - case 'postgresql': - $sql[] = "CREATE SEQUENCE " . GROUPS_TABLE . "_id_seq start 3 increment 1 maxvalue 2147483647 minvalue 1 cache 1"; - $sql[] = "CREATE TABLE tmp_" . GROUPS_TABLE . " AS SELECT group_id, group_name, group_type, group_description, group_moderator, group_single_user FROM " . GROUPS_TABLE; - $sql[] = "DROP TABLE " . GROUPS_TABLE; - $sql[] = "CREATE TABLE phpbb_groups (group_id int DEFAULT nextval('" . GROUPS_TABLE . "_id_seq'::text) NOT NULL, group_name varchar(40) NOT NULL, group_type int2 DEFAULT '1' NOT NULL, group_description varchar(255) NOT NULL, group_moderator int4 DEFAULT '0' NOT NULL, group_single_user int2 DEFAULT '0' NOT NULL, CONSTRAINT phpbb_groups_pkey PRIMARY KEY (group_id))"; - $sql[] = "INSERT INTO " . GROUPS_TABLE . " (group_id, group_name, group_type, group_description, group_moderator, group_single_user) SELECT group_id, group_name, group_type, group_description, group_moderator, group_single_user FROM tmp_" . GROUPS_TABLE; - $sql[] = "DROP TABLE tmp_" . GROUPS_TABLE; - break; - } + case 'msaccess': + $sql[] = "CREATE INDEX " . SEARCH_MATCH_TABLE . " ON " . SEARCH_MATCH_TABLE . " ([post_id])"; + $sql[] = "CREATE INDEX " . SEARCH_MATCH_TABLE . "_1 ON " . SEARCH_MATCH_TABLE . " ([word_id])"; + break; + } + + // Regenerate groups table with incremented group_id for pgsql + // ... missing in 2.0.3 ... + switch (SQL_LAYER) + { + case 'postgresql': + $sql[] = "CREATE SEQUENCE " . GROUPS_TABLE . "_id_seq start 3 increment 1 maxvalue 2147483647 minvalue 1 cache 1"; + $sql[] = "CREATE TABLE tmp_" . GROUPS_TABLE . " AS SELECT group_id, group_name, group_type, group_description, group_moderator, group_single_user FROM " . GROUPS_TABLE; + $sql[] = "DROP TABLE " . GROUPS_TABLE; + $sql[] = "CREATE TABLE phpbb_groups (group_id int DEFAULT nextval('" . GROUPS_TABLE . "_id_seq'::text) NOT NULL, group_name varchar(40) NOT NULL, group_type int2 DEFAULT '1' NOT NULL, group_description varchar(255) NOT NULL, group_moderator int4 DEFAULT '0' NOT NULL, group_single_user int2 DEFAULT '0' NOT NULL, CONSTRAINT phpbb_groups_pkey PRIMARY KEY (group_id))"; + $sql[] = "INSERT INTO " . GROUPS_TABLE . " (group_id, group_name, group_type, group_description, group_moderator, group_single_user) SELECT group_id, group_name, group_type, group_description, group_moderator, group_single_user FROM tmp_" . GROUPS_TABLE; + $sql[] = "DROP TABLE tmp_" . GROUPS_TABLE; + break; + } - // Modify user_timezone to decimal(5,2) for mysql ... mysql4/mssql/pgsql/msaccess - // should be completely unaffected - switch (SQL_LAYER) - { - case 'mysql': - $sql[] = "ALTER TABLE " . USERS_TABLE . " MODIFY COLUMN user_timezone decimal(5,2) DEFAULT '0' NOT NULL"; - break; - } + // Modify user_timezone to decimal(5,2) for mysql ... mysql4/mssql/pgsql/msaccess + // should be completely unaffected + // Change default user_notify to 0 + switch (SQL_LAYER) + { + case 'mysql': + $sql[] = "ALTER TABLE " . USERS_TABLE . " + MODIFY COLUMN user_timezone decimal(5,2) DEFAULT '0' NOT NULL, + MODIFY COLUMN user_notify tinyint(1) DEFAULT '0' NOT NULL"; + break; + + case 'mssql': + case 'mssql-odbc': + break; + + case 'msaccess': + break; + + case 'postgresql': + break; } } @@ -507,20 +519,20 @@ flush(); $error_ary = array(); $errored = false; -if ( count($sql) ) +if (count($sql)) { - for($i = 0; $i < count($sql); $i++) + for ($i = 0; $i < count($sql); $i++) { _sql($sql[$i], $errored, $error_ary); } echo " Done
Result   :: \n"; - if ( $errored ) + if ($errored) { echo " Some queries failed, the statements and errors are listing below\n