# HG changeset patch # User Dan Fuhry # Date 1278030259 14400 # Node ID 49db7495f6b812b523b8da9ad0d6822371ab6ac6 # Parent d972b1276d95c7c643327af18ee4dacf476f62fc First shot at switching to database revision numbers separate from release version number. There are probably bugs, especially related to migration. diff -r d972b1276d95 -r 49db7495f6b8 includes/common.php --- a/includes/common.php Thu Jul 01 18:25:04 2010 -0400 +++ b/includes/common.php Thu Jul 01 20:24:19 2010 -0400 @@ -45,6 +45,12 @@ // You'll want to change this for custom distributions. $version = '1.1.8'; +// Database schema version +// This is incremented each time a change to the database structure is made. +// If it doesn't match the version in the DB, the user will be asked to upgrade. +// This must match install/includes/common.php! +$db_version = 1125; + /** * Returns a floating-point number with the current UNIX timestamp in microseconds. Defined very early because we gotta call it * from very early on in the script to measure the starting time of Enano. @@ -263,10 +269,29 @@ return true; } -// Now that we have the config, check the Enano version. -if ( enano_version(false, true) != $version && !defined('IN_ENANO_UPGRADE') ) +// Now that we have the config, check the database version. +// ...We do have a database version, right? This was only added in 1.1.8, so assign +// a database revision number if there isn't one in the config already. +if ( getConfig('db_version') === false ) +{ + generate_db_version(); +} +if ( ($current_db_revision = getConfig('db_version', 0)) < $db_version && !defined('IN_ENANO_UPGRADE') ) { - grinding_halt('Version mismatch', '

It seems that the Enano release we\'re trying to run ('.$version.') is different from the version specified in your database ('.enano_version().'). Perhaps you need to upgrade?

'); + grinding_halt('Database out of date', '

Your Enano database is out of date and needs to be upgraded. To do this, use the upgrade script.

' + . "

Your database version: $current_db_revision
Latest version: $db_version

"); +} +else if ( $current_db_revision > $db_version ) +{ + grinding_halt('Database newer than Enano', '

Your Enano database is a newer revision than what this Enano release calls for. Please upgrade your Enano files.

' + . "

Your database version: $current_db_revision
Latest version: $db_version

"); +} + +// If we made it here, DB is up to date. +if ( getConfig('enano_version') !== $version && !preg_match('/^upg-/', getConfig('enano_version')) ) +{ + setConfig('enano_version', $version); + setConfig('newly_upgraded', 1); } // Set our CDN path diff -r d972b1276d95 -r 49db7495f6b8 includes/functions.php --- a/includes/functions.php Thu Jul 01 18:25:04 2010 -0400 +++ b/includes/functions.php Thu Jul 01 20:24:19 2010 -0400 @@ -1422,6 +1422,41 @@ } /** + * Set the database revision number if we don't have one. + */ + +function generate_db_version() +{ + if ( getConfig('db_version') !== false ) + return; + + $dbversions = array( + '1.0' => 1000, + '1.0.1' => 1010, + '1.0.2b1' => 1019, + '1.0.2' => 1020, + '1.0.3' => 1030, + '1.0.4' => 1040, + '1.0.5' => 1050, + '1.0.6' => 1060, + '1.0.6pl1' => 1070, + '1.1.1' => 1119, + '1.1.2' => 1120, + '1.1.3' => 1121, + '1.1.4' => 1122, + '1.1.5' => 1123, + '1.1.6' => 1124, + '1.1.7' => 1125, + '1.1.7pl1' => 1125, + '1.1.8' => 1125 + ); + if ( isset($dbversions[ enano_version(true, false) ]) ) + { + setConfig('db_version', $dbversions[ enano_version(true, false) ]); + } +} + +/** * Badly named function to send back eval'able Javascript code with an error message. Deprecated, use JSON instead. * @param string Message to send */ diff -r d972b1276d95 -r 49db7495f6b8 install/includes/common.php --- a/install/includes/common.php Thu Jul 01 18:25:04 2010 -0400 +++ b/install/includes/common.php Thu Jul 01 20:24:19 2010 -0400 @@ -21,6 +21,12 @@ // 'sub' => '3' will produce Enano 1.1.1a3 / Enano 1.1.1 alpha 3 ); +// Database schema version +// This is incremented each time a change to the database structure is made. +// If it doesn't match the version in the DB, the user will be asked to upgrade. +// This must match includes/common.php! +$db_version = 1125; + function installer_enano_version($long = false) { global $installer_version; diff -r d972b1276d95 -r 49db7495f6b8 install/includes/libenanoinstall.php --- a/install/includes/libenanoinstall.php Thu Jul 01 18:25:04 2010 -0400 +++ b/install/includes/libenanoinstall.php Thu Jul 01 20:24:19 2010 -0400 @@ -116,7 +116,7 @@ exit; } -function enano_perform_upgrade($target_branch) +function enano_perform_upgrade($target_rev) { global $db, $session, $paths, $template, $plugins; // Common objects // Import version info @@ -133,64 +133,52 @@ return true; } + // // Main upgrade stage - - // Init vars - list($major_version, $minor_version) = explode('.', installer_enano_version()); - $installer_branch = "$major_version.$minor_version"; - $installer_branch = preg_replace('/^upg-/', '', $installer_branch); - $target_branch = preg_replace('/^upg-/', '', $target_branch); - - $version_flipped = array_flip($enano_versions[$target_branch]); - $version_curr = enano_version(); - // Change this to be the last version in the current branch. - // If we're just upgrading within this branch, use the version the installer library - // reports to us. Else, use the latest in the old (current target) branch. - // $version_target = installer_enano_version(); - $version_target = ( $target_branch === $installer_branch ) ? installer_enano_version() : $enano_versions[$target_branch][ count($enano_versions[$target_branch]) - 1 ]; + // // Calculate which scripts to run - if ( !isset($version_flipped[$version_curr]) ) + $versions_avail = array(); + + $dir = ENANO_ROOT . "/install/schemas/upgrade/$dbdriver/"; + if ( $dh = @opendir($dir) ) { - echo '

ERROR: Unsupported version

'; - $ui->show_footer(); - exit; - } - if ( !isset($version_flipped[$version_target]) ) - { - echo '

ERROR: Upgrader doesn\'t support its own version

'; - $ui->show_footer(); - exit; + while ( $di = @readdir($dh) ) + { + if ( preg_match('/^[0-9]+\.sql$/', $di) ) + $versions_avail[] = intval($di); + } } - $upg_queue = array(); - for ( $i = $version_flipped[$version_curr]; $i < $version_flipped[$version_target]; $i++ ) + else { - if ( !isset($enano_versions[$target_branch][$i + 1]) ) - { - echo '

ERROR: Unsupported intermediate version

'; - $ui->show_footer(); - exit; - } - $ver_this = $enano_versions[$target_branch][$i]; - $ver_next = $enano_versions[$target_branch][$i + 1]; - $upg_queue[] = array($ver_this, $ver_next); + return false; } - // Verify that all upgrade scripts are usable - foreach ( $upg_queue as $verset ) + // sort version list numerically + asort($versions_avail); + $versions_avail = array_values($versions_avail); + + $last_rev = $versions_avail[ count($versions_avail) - 1 ]; + + $current_rev = getConfig('db_version', 0); + + if ( $last_rev <= $current_rev ) + return true; + + foreach ( $versions_avail as $i => $ver ) { - $file = ENANO_ROOT . "/install/schemas/upgrade/{$verset[0]}-{$verset[1]}-$dbdriver.sql"; - if ( !file_exists($file) ) + if ( $ver > $current_rev ) { - echo "

ERROR: Couldn't find required schema file: $file

"; - $ui->show_footer(); - exit; + $upg_queue = array_slice($versions_avail, $i); + break; } } + // Perform upgrade - foreach ( $upg_queue as $verset ) + foreach ( $upg_queue as $version ) { - $file = ENANO_ROOT . "/install/schemas/upgrade/{$verset[0]}-{$verset[1]}-$dbdriver.sql"; + $file = "{$dir}$version.sql"; + try { $parser = new SQL_Parser($file); @@ -210,7 +198,7 @@ { // It's empty, report success for this version // See below for explanation of why setConfig() is called here - setConfig('enano_version', $verset[1]); + setConfig('db_version', $version); continue; } @@ -231,7 +219,7 @@ } // Is there an additional script (logic) to be run after the schema? - $postscript = ENANO_ROOT . "/install/schemas/upgrade/{$verset[0]}-{$verset[1]}.php"; + $postscript = ENANO_ROOT . "/install/schemas/upgrade/$version.php"; if ( file_exists($postscript) ) @include($postscript); @@ -242,7 +230,7 @@ // need some sort of query-numbering system that tracks in-progress // upgrades. - setConfig('enano_version', $verset[1]); + setConfig('db_version', $version); } } diff -r d972b1276d95 -r 49db7495f6b8 install/includes/payload.php --- a/install/includes/payload.php Thu Jul 01 18:25:04 2010 -0400 +++ b/install/includes/payload.php Thu Jul 01 20:24:19 2010 -0400 @@ -154,6 +154,10 @@ return false; } } + + global $db_version; + setConfig('db_version', $db_version); + return true; } @@ -569,13 +573,16 @@ { global $db, $session, $paths, $template, $plugins; // Common objects // log the upgrade + global $db_version; $q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,author_uid,page_text,edit_summary) VALUES' - . '(\'security\', \'upgrade_enano\', ' . time() . ', \'[DEPRECATED]\', \'' . $db->escape($session->username) . '\', ' . $session->user_id . ', \'' . $db->escape(installer_enano_version()) . '\', \'' . $db->escape($_SERVER['REMOTE_ADDR']) . '\');'); + . '(\'security\', \'upgrade_enano\', ' . time() . ', \'[DEPRECATED]\', \'' . $db->escape($session->username) . '\', ' . $session->user_id . ', \'' . $db->escape($db_version) . '\', \'' . $db->escape($_SERVER['REMOTE_ADDR']) . '\');'); if ( !$q ) { $db->_die(); return false; } + setConfig('db_version', $db_version); setConfig('enano_version', installer_enano_version()); + setConfig('newly_upgraded', 1); return true; } diff -r d972b1276d95 -r 49db7495f6b8 install/index.php --- a/install/index.php Thu Jul 01 18:25:04 2010 -0400 +++ b/install/index.php Thu Jul 01 20:24:19 2010 -0400 @@ -101,7 +101,7 @@ diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.0-1.0.1-mysql.sql --- a/install/schemas/upgrade/1.0-1.0.1-mysql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ --- Enano CMS --- Upgrade schema - Enano 1.0 - 1.0.1 - --- Fix for obnoxious $_GET issue -UPDATE {{TABLE_PREFIX}}sidebar SET block_type=1,block_content='

$INPUT_AUTH$

' WHERE block_name='Search' AND item_id=4; --- Added on advice from Neal --- Remember that 1 = AUTH_DENY. -INSERT INTO {{TABLE_PREFIX}}acl(target_type,target_id,page_id,namespace,rules) VALUES(2,1,'Memberlist','Special','read=1;mod_misc=1;upload_files=1;upload_new_version=1;create_page=1;edit_acl=1;'); --- Bugfix for MySQL 5.0.45, see http://forum.enanocms.org/viewtopic.php?f=5&t=8 -ALTER TABLE {{TABLE_PREFIX}}pages MODIFY COLUMN delvote_ips text DEFAULT NULL; -CREATE TABLE {{TABLE_PREFIX}}page_groups( pg_id mediumint(8) NOT NULL auto_increment, pg_type tinyint(2) NOT NULL DEFAULT 1, pg_name varchar(255) NOT NULL DEFAULT '', pg_target varchar(255) DEFAULT NULL, PRIMARY KEY ( pg_id ) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; -CREATE TABLE {{TABLE_PREFIX}}page_group_members( pg_member_id int(12) NOT NULL auto_increment, pg_id mediumint(8) NOT NULL, page_id varchar(63) NOT NULL, namespace varchar(63) NOT NULL DEFAULT 'Article', PRIMARY KEY ( pg_member_id ) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; -CREATE TABLE {{TABLE_PREFIX}}tags( tag_id int(12) NOT NULL auto_increment, tag_name varchar(63) NOT NULL DEFAULT 'bla', page_id varchar(255) NOT NULL, namespace varchar(255) NOT NULL, user mediumint(8) NOT NULL DEFAULT 1, PRIMARY KEY ( tag_id ) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; -UPDATE {{TABLE_PREFIX}}acl SET rules=CONCAT(rules,'tag_create=4;tag_delete_own=4;tag_delete_other=4;') WHERE target_type=1 AND target_id=2; -DELETE FROM {{TABLE_PREFIX}}search_cache; - diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.0.1-1.0.2b1-mysql.sql --- a/install/schemas/upgrade/1.0.1-1.0.2b1-mysql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ - diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.0.2-1.0.3-mysql.sql --- a/install/schemas/upgrade/1.0.2-1.0.3-mysql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ - diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.0.2b1-1.0.2-mysql.sql --- a/install/schemas/upgrade/1.0.2b1-1.0.2-mysql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ --- Enano CMS --- Upgrade schema - Enano 1.0.2 beta 1 - 1.0.2 release - --- This is really optional, but could reduce confusion if regex page groups get truncated for no apparent reason. -ALTER TABLE {{TABLE_PREFIX}}page_groups MODIFY COLUMN pg_target text DEFAULT NULL; - --- I have no idea how or why, but the f'ing index didn't get created for who-knows-how-many releases. --- We'll attempt to create it here, but don't die if it fails -@ALTER TABLE {{TABLE_PREFIX}}page_text ENGINE = MYISAM, COLLATE = utf8_bin, CHARSET = utf8; -ALTER TABLE {{TABLE_PREFIX}}search_index CHARSET = utf8, COLLATE = utf8_bin, MODIFY COLUMN word varchar(64) NOT NULL; - --- The search cache is no longer needed because of the new unified search engine (it's too f'ing fast to need a cache :-D) -@DROP TABLE {{TABLE_PREFIX}}search_cache; - --- Yes, it appears we need pages with names this long after all -ALTER TABLE {{TABLE_PREFIX}}pages MODIFY COLUMN urlname varchar(255), MODIFY COLUMN name varchar(255); - --- Make page_text a little more efficient to deal with -ALTER TABLE {{TABLE_PREFIX}}page_text MODIFY COLUMN page_id varchar(255), MODIFY COLUMN namespace varchar(63), MODIFY COLUMN page_text longtext; - --- Now recreate the fulltext index -@CREATE FULLTEXT INDEX {{TABLE_PREFIX}}page_search_idx ON {{TABLE_PREFIX}}page_text(page_id, namespace, page_text); - --- Addition of new file types -UPDATE {{TABLE_PREFIX}}config SET config_value='cbf:len=185;crc=55fb6f14;data=0[1],1[4],0[3],1[1],0[22],1[1],0[16],1[3],0[16],1[1],0[1],1[2],0[6],1[1],0[1],1[1],0[4],1[2],0[3],1[1],0[48],1[2],0[2],1[1],0[4],1[1],0[37]|end' WHERE config_name = 'allowed_mime_types' AND config_value='cbf:len=168;crc=c3dcad3f;data=0[1],1[4],0[3],1[1],0[2],1[1],0[11],1[1],0[7],1[1],0[9],1[1],0[6],1[3],0[10],1[1],0[2],1[2],0[1],1[1],0[1],1[2],0[6],1[3],0[1],1[1],0[2],1[4],0[1],1[2],0[3],1[1],0[4],1[2],0[26],1[5],0[6],1[2],0[2],1[1],0[4],1[1],0[10],1[2],0[1],1[1],0[6]|end'; - --- Reinforcement of "stable release" mentality -@UPDATE {{TABLE_PREFIX}}users SET theme='oxygen', style='bleu' WHERE user_id = 2; - diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.0.3-1.0.4-mysql.sql --- a/install/schemas/upgrade/1.0.3-1.0.4-mysql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ - diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.0.4-1.0.5-mysql.sql --- a/install/schemas/upgrade/1.0.4-1.0.5-mysql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ - diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.0.5-1.0.6-mysql.sql --- a/install/schemas/upgrade/1.0.5-1.0.6-mysql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ - diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.0.6-1.0.6pl1-mysql.sql --- a/install/schemas/upgrade/1.0.6-1.0.6pl1-mysql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ - diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.1.1-1.1.2-mysql.sql --- a/install/schemas/upgrade/1.1.1-1.1.2-mysql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ --- Enano CMS --- Upgrade schema - Enano 1.1.1 - 1.1.2 - -ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN log_id int(15) NOT NULL auto_increment, ADD PRIMARY KEY ( log_id ); -ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN is_draft tinyint(1) NOT NULL DEFAULT 0; - -ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_rank int(12) UNSIGNED NOT NULL DEFAULT 1; -ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_timezone int(12) UNSIGNED NOT NULL DEFAULT 1440; - -@ALTER TABLE {{TABLE_PREFIX}}tags CHANGE user user_id mediumint(8) NOT NULL DEFAULT 1; -ALTER TABLE {{TABLE_PREFIX}}themes - ADD COLUMN group_list text DEFAULT NULL, - ADD COLUMN group_policy ENUM('allow', 'deny') NOT NULL DEFAULT 'deny'; - -CREATE TABLE {{TABLE_PREFIX}}ranks( - rank_id int(12) NOT NULL auto_increment, - rank_title varchar(63) NOT NULL DEFAULT '', - rank_style varchar(255) NOT NULL DEFAULT '', - PRIMARY KEY ( rank_id ) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - -CREATE TABLE {{TABLE_PREFIX}}captcha( - code_id int(12) NOT NULL auto_increment, - session_id varchar(40) NOT NULL DEFAULT '', - code varchar(64) NOT NULL DEFAULT '', - session_data text, - source_ip varchar(39), - user_id int(12), - PRIMARY KEY ( code_id ) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - -INSERT INTO {{TABLE_PREFIX}}ranks(rank_id, rank_title, rank_style) VALUES - (1, 'user_rank_member', ''), - (2, 'user_rank_mod', 'font-weight: bold; color: #00AA00;'), - (3, 'user_rank_admin', 'font-weight: bold; color: #AA0000;'); - diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.1.1-1.1.2-postgresql.sql --- a/install/schemas/upgrade/1.1.1-1.1.2-postgresql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ --- Enano CMS --- Upgrade schema - Enano 1.1.1 - 1.1.2 - -ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN log_id SERIAL, ADD PRIMARY KEY ( log_id ); -ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN is_draft smallint NOT NULL DEFAULT 0; - -ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_rank int NOT NULL DEFAULT 1; -@ALTER TABLE {{TABLE_PREFIX}}users DROP user_timezone; -ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_timezone int NOT NULL DEFAULT 1440; - -ALTER TABLE {{TABLE_PREFIX}}themes - ADD COLUMN group_list text DEFAULT NULL, - ADD COLUMN group_policy varchar(5) NOT NULL DEFAULT 'deny', - ADD CHECK (group_policy IN ('allow', 'deny')); - -CREATE TABLE {{TABLE_PREFIX}}ranks( - rank_id SERIAL, - rank_title varchar(63) NOT NULL DEFAULT '', - rank_style varchar(255) NOT NULL DEFAULT '', - PRIMARY KEY ( rank_id ) -); - -CREATE TABLE {{TABLE_PREFIX}}captcha( - code_id SERIAL, - session_id varchar(40) NOT NULL DEFAULT '', - code varchar(64) NOT NULL DEFAULT '', - session_data text, - source_ip varchar(39), - user_id int, - PRIMARY KEY ( code_id ) -); - -INSERT INTO {{TABLE_PREFIX}}ranks(rank_id, rank_title, rank_style) VALUES - (1, 'user_rank_member', ''), - (2, 'user_rank_mod', 'font-weight: bold; color: #00AA00;'), - (3, 'user_rank_admin', 'font-weight: bold; color: #AA0000;'); - --- For some reason this is required, it came up in my QA testing on a2hosting -SELECT NEXTVAL('{{TABLE_PREFIX}}ranks_rank_id_seq'::regclass); - diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.1.2-1.1.3-mysql.sql --- a/install/schemas/upgrade/1.1.2-1.1.3-mysql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ --- Enano CMS --- Upgrade schema: 1.1.2 - 1.1.3 - --- Storing obscenely huge integers as strings since that's how php processes them. - -CREATE TABLE {{TABLE_PREFIX}}diffiehellman ( - key_id int(12) NOT NULL auto_increment, - private_key text, - public_key text, - PRIMARY KEY ( key_id ) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - -ALTER TABLE {{TABLE_PREFIX}}session_keys MODIFY COLUMN source_ip varchar(39) NOT NULL DEFAULT '127.0.0.1'; -ALTER TABLE {{TABLE_PREFIX}}themes MODIFY COLUMN group_policy ENUM('allow_all', 'whitelist', 'blacklist') NOT NULL DEFAULT 'allow_all'; -UPDATE {{TABLE_PREFIX}}themes SET group_policy = 'allow_all'; diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.1.2-1.1.3-postgresql.sql --- a/install/schemas/upgrade/1.1.2-1.1.3-postgresql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ --- Enano CMS --- Upgrade schema: 1.1.2 - 1.1.3 - --- Storing obscenely huge integers as strings since that's how php processes them. - -CREATE TABLE {{TABLE_PREFIX}}diffiehellman ( - key_id SERIAL, - private_key text, - public_key text, - PRIMARY KEY ( key_id ) -); - -ALTER TABLE {{TABLE_PREFIX}}themes DROP group_policy, ADD COLUMN group_policy varchar(9) NOT NULL DEFAULT 'allow_all', ADD CHECK ( group_policy IN ('allow_all', 'whitelist', 'blacklist') ); - -ALTER TABLE {{TABLE_PREFIX}}session_keys ALTER COLUMN source_ip TYPE varchar(39), - ADD CHECK ( source_ip IS NOT NULL ), - ALTER COLUMN source_ip SET DEFAULT '127.0.0.1'; - diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.1.3-1.1.4-mysql.sql --- a/install/schemas/upgrade/1.1.3-1.1.4-mysql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ --- This is really honestly a better way to handle plugins. - -CREATE TABLE {{TABLE_PREFIX}}plugins ( - plugin_id int(12) NOT NULL auto_increment, - plugin_filename varchar(63), - plugin_flags int(12), - plugin_version varchar(16), - PRIMARY KEY ( plugin_id ) -) ENGINE `MyISAM` CHARACTER SET `utf8` COLLATE `utf8_bin`; - -ALTER TABLE {{TABLE_PREFIX}}search_index ADD COLUMN word_lcase varchar(64) NOT NULL; - --- User title -ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_title varchar(64) DEFAULT NULL; -ALTER TABLE {{TABLE_PREFIX}}users MODIFY COLUMN user_rank int(12) unsigned DEFAULT NULL; -ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_group mediumint(5) NOT NULL DEFAULT 1; -UPDATE {{TABLE_PREFIX}}users SET user_rank = NULL; - --- The "guest" rank --- No frontend to this yet so ranks should not have been created. -DELETE FROM {{TABLE_PREFIX}}ranks WHERE rank_id = 4; -INSERT INTO {{TABLE_PREFIX}}ranks(rank_id, rank_title, rank_style) VALUES - (4, 'user_rank_guest', ''); - --- Other rank-related columns -ALTER TABLE {{TABLE_PREFIX}}groups ADD COLUMN group_rank int(12) unsigned DEFAULT NULL; - --- Disable JS effects column -ALTER TABLE {{TABLE_PREFIX}}users_extra ADD COLUMN disable_js_fx tinyint(1) NOT NULL DEFAULT 0; - --- Add "grv" avatar type -ALTER TABLE {{TABLE_PREFIX}}users MODIFY COLUMN avatar_type ENUM('png', 'gif', 'jpg', 'grv'); diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.1.3-1.1.4-postgresql.sql --- a/install/schemas/upgrade/1.1.3-1.1.4-postgresql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ --- This is really honestly a better way to handle plugins. - -CREATE TABLE {{TABLE_PREFIX}}plugins ( - plugin_id SERIAL, - plugin_filename varchar(63), - plugin_flags int, - plugin_version varchar(16), - PRIMARY KEY ( plugin_id ) -); - --- User title -ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_title varchar(64) DEFAULT NULL; - --- Modifications to user_rank column --- http://pgsqld.active-venture.com/ddl-alter.html#AEN1984 -ALTER TABLE {{TABLE_PREFIX}}users ALTER COLUMN user_rank DROP NOT NULL, - ALTER COLUMN user_rank DROP DEFAULT; -ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_group int NOT NULL DEFAULT 1; -UPDATE {{TABLE_PREFIX}}users SET user_rank = NULL; - --- Aggregate function array_accum --- http://www.postgresql.org/docs/current/static/xaggr.html - -CREATE AGGREGATE {{TABLE_PREFIX}}array_accum (anyelement) -( - sfunc = array_append, - stype = anyarray, - initcond = '{}' -); - --- The "guest" rank --- No frontend to this yet so ranks should not have been created. -DELETE FROM {{TABLE_PREFIX}}ranks WHERE rank_id = 4; -INSERT INTO {{TABLE_PREFIX}}ranks(rank_id, rank_title, rank_style) VALUES - (4, 'user_rank_guest', ''); - --- For some reason this is required, it came up in my QA testing on a2hosting -SELECT NEXTVAL('{{TABLE_PREFIX}}ranks_rank_id_seq'::regclass); - --- Other rank-related columns -ALTER TABLE {{TABLE_PREFIX}}groups ADD COLUMN group_rank int DEFAULT NULL; - --- Disable JS effects column -ALTER TABLE {{TABLE_PREFIX}}users_extra ADD COLUMN disable_js_fx smallint NOT NULL DEFAULT 0; - --- Add "grv" avatar type -ALTER TABLE {{TABLE_PREFIX}}users DROP CONSTRAINT {{TABLE_PREFIX}}users_avatar_type_check; -ALTER TABLE {{TABLE_PREFIX}}users ADD CONSTRAINT {{TABLE_PREFIX}}users_avatar_type_check CHECK ( avatar_type IN ( 'png', 'gif', 'jpg', 'grv' ) ); diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.1.4-1.1.5-mysql.sql --- a/install/schemas/upgrade/1.1.4-1.1.5-mysql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -ALTER TABLE {{TABLE_PREFIX}}session_keys ADD COLUMN key_type tinyint(1) NOT NULL DEFAULT 0; -UPDATE {{TABLE_PREFIX}}session_keys SET key_type = 2 WHERE auth_level > 2; -ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_dst varchar(11) NOT NULL DEFAULT '0;0;0;0;60'; -ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_rank_userset tinyint(1) NOT NULL DEFAULT 0; diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.1.4-1.1.5-postgresql.sql --- a/install/schemas/upgrade/1.1.4-1.1.5-postgresql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -ALTER TABLE {{TABLE_PREFIX}}session_keys ADD COLUMN key_type smallint NOT NULL DEFAULT 0; -UPDATE {{TABLE_PREFIX}}session_keys SET key_type = 2 WHERE auth_level > 2; -ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_dst varchar(11) NOT NULL DEFAULT '0;0;0;0;60'; -ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_rank_userset smallint NOT NULL DEFAULT 0; diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.1.5-1.1.6-mysql.sql --- a/install/schemas/upgrade/1.1.5-1.1.6-mysql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN password_salt varchar(40) NOT NULL DEFAULT ''; -ALTER TABLE {{TABLE_PREFIX}}pages ADD COLUMN page_format varchar(16) NOT NULL DEFAULT 'wikitext'; -ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN page_format varchar(16) NOT NULL DEFAULT 'wikitext'; - --- Make page_id and namespace column sizes consistent (former bug) - -ALTER TABLE {{TABLE_PREFIX}}comments MODIFY COLUMN page_id varchar(512) NOT NULL, - MODIFY COLUMN namespace varchar(16) NOT NULL; - -ALTER TABLE {{TABLE_PREFIX}}logs MODIFY COLUMN page_id varchar(512) NOT NULL, - MODIFY COLUMN namespace varchar(16) NOT NULL; - -ALTER TABLE {{TABLE_PREFIX}}page_text MODIFY COLUMN page_id varchar(512) NOT NULL; - -ALTER TABLE {{TABLE_PREFIX}}pages MODIFY COLUMN urlname varchar(512) NOT NULL; - -ALTER TABLE {{TABLE_PREFIX}}hits MODIFY COLUMN page_id varchar(512) NOT NULL, - MODIFY COLUMN namespace varchar(16) NOT NULL; - -ALTER TABLE {{TABLE_PREFIX}}acl MODIFY COLUMN page_id varchar(512), - MODIFY COLUMN namespace varchar(16); - -ALTER TABLE {{TABLE_PREFIX}}page_group_members MODIFY COLUMN page_id varchar(512) NOT NULL, - MODIFY COLUMN namespace varchar(16) NOT NULL; - -ALTER TABLE {{TABLE_PREFIX}}tags MODIFY COLUMN page_id varchar(512) NOT NULL, - MODIFY COLUMN namespace varchar(16) NOT NULL; - --- Added in 1.1.6: Indices for several tables --- The size of 317 is a trial-and-error-produced value based on MySQL's index column size limit --- of 1000 bytes. It's low like that because of the UTF-8 character set being used. - -@ALTER TABLE {{TABLE_PREFIX}}logs ADD INDEX {{TABLE_PREFIX}}logs_page_idx (page_id(317), namespace); -@ALTER TABLE {{TABLE_PREFIX}}logs ADD INDEX {{TABLE_PREFIX}}logs_time_idx (time_id); -@ALTER TABLE {{TABLE_PREFIX}}logs ADD INDEX {{TABLE_PREFIX}}logs_action_idx (log_type, action); -@ALTER TABLE {{TABLE_PREFIX}}comments ADD INDEX {{TABLE_PREFIX}}comments_page_idx (page_id(317), namespace); -@ALTER TABLE {{TABLE_PREFIX}}hits ADD INDEX {{TABLE_PREFIX}}hits_time_idx ( time ); -@ALTER TABLE {{TABLE_PREFIX}}hits ADD INDEX {{TABLE_PREFIX}}hits_page_idx (page_id(317), namespace); -@ALTER TABLE {{TABLE_PREFIX}}pages ADD INDEX {{TABLE_PREFIX}}pages_page_idx (urlname(317), namespace); -@ALTER TABLE {{TABLE_PREFIX}}page_text ADD INDEX {{TABLE_PREFIX}}page_text_page_idx (page_id(317), namespace); - diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.1.5-1.1.6-postgresql.sql --- a/install/schemas/upgrade/1.1.5-1.1.6-postgresql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN password_salt varchar(40) NOT NULL DEFAULT ''; -ALTER TABLE {{TABLE_PREFIX}}pages ADD COLUMN page_format varchar(16) NOT NULL DEFAULT 'wikitext'; -ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN page_format varchar(16) NOT NULL DEFAULT 'wikitext'; - --- --- Make page_id and namespace column sizes consistent (former bug) --- Yes, this is a PITA in PostgreSQL. --- - --- comments -ALTER TABLE {{TABLE_PREFIX}}comments ADD COLUMN page_id_new varchar(512) NOT NULL DEFAULT ''; -UPDATE {{TABLE_PREFIX}}comments SET page_id_new = page_id; -ALTER TABLE {{TABLE_PREFIX}}comments DROP page_id; -ALTER TABLE {{TABLE_PREFIX}}comments RENAME page_id_new TO page_id; - -ALTER TABLE {{TABLE_PREFIX}}comments ADD COLUMN namespace_new varchar(16) NOT NULL DEFAULT ''; -UPDATE {{TABLE_PREFIX}}comments SET namespace_new = namespace; -ALTER TABLE {{TABLE_PREFIX}}comments DROP namespace; -ALTER TABLE {{TABLE_PREFIX}}comments RENAME namespace_new TO namespace; - --- logs -ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN page_id_new varchar(512) NOT NULL DEFAULT ''; -UPDATE {{TABLE_PREFIX}}logs SET page_id_new = page_id; -ALTER TABLE {{TABLE_PREFIX}}logs DROP page_id; -ALTER TABLE {{TABLE_PREFIX}}logs RENAME page_id_new TO page_id; - -ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN namespace_new varchar(16) NOT NULL DEFAULT ''; -UPDATE {{TABLE_PREFIX}}logs SET namespace_new = namespace; -ALTER TABLE {{TABLE_PREFIX}}logs DROP namespace; -ALTER TABLE {{TABLE_PREFIX}}logs RENAME namespace_new TO namespace; - --- page_text -ALTER TABLE {{TABLE_PREFIX}}page_text ADD COLUMN page_id_new varchar(512) NOT NULL DEFAULT ''; -UPDATE {{TABLE_PREFIX}}page_text SET page_id_new = page_id; -ALTER TABLE {{TABLE_PREFIX}}page_text DROP page_id; -ALTER TABLE {{TABLE_PREFIX}}page_text RENAME page_id_new TO page_id; - --- pages -ALTER TABLE {{TABLE_PREFIX}}pages ADD COLUMN urlname_new varchar(512) NOT NULL DEFAULT ''; -UPDATE {{TABLE_PREFIX}}pages SET urlname_new = urlname; -ALTER TABLE {{TABLE_PREFIX}}pages DROP urlname; -ALTER TABLE {{TABLE_PREFIX}}pages RENAME urlname_new TO urlname; - --- hits -ALTER TABLE {{TABLE_PREFIX}}hits ADD COLUMN page_id_new varchar(512) NOT NULL DEFAULT ''; -UPDATE {{TABLE_PREFIX}}hits SET page_id_new = page_id; -ALTER TABLE {{TABLE_PREFIX}}hits DROP page_id; -ALTER TABLE {{TABLE_PREFIX}}hits RENAME page_id_new TO page_id; - -ALTER TABLE {{TABLE_PREFIX}}hits ADD COLUMN namespace_new varchar(16) NOT NULL DEFAULT ''; -UPDATE {{TABLE_PREFIX}}hits SET namespace_new = namespace; -ALTER TABLE {{TABLE_PREFIX}}hits DROP namespace; -ALTER TABLE {{TABLE_PREFIX}}hits RENAME namespace_new TO namespace; - --- acl -ALTER TABLE {{TABLE_PREFIX}}acl ADD COLUMN page_id_new varchar(512) DEFAULT NULL; -UPDATE {{TABLE_PREFIX}}acl SET page_id_new = page_id; -ALTER TABLE {{TABLE_PREFIX}}acl DROP page_id; -ALTER TABLE {{TABLE_PREFIX}}acl RENAME page_id_new TO page_id; - -ALTER TABLE {{TABLE_PREFIX}}acl ADD COLUMN namespace_new varchar(16) DEFAULT NULL; -UPDATE {{TABLE_PREFIX}}acl SET namespace_new = namespace; -ALTER TABLE {{TABLE_PREFIX}}acl DROP namespace; -ALTER TABLE {{TABLE_PREFIX}}acl RENAME namespace_new TO namespace; - --- page_group_members -ALTER TABLE {{TABLE_PREFIX}}page_group_members ADD COLUMN page_id_new varchar(512) NOT NULL DEFAULT ''; -UPDATE {{TABLE_PREFIX}}page_group_members SET page_id_new = page_id; -ALTER TABLE {{TABLE_PREFIX}}page_group_members DROP page_id; -ALTER TABLE {{TABLE_PREFIX}}page_group_members RENAME page_id_new TO page_id; - -ALTER TABLE {{TABLE_PREFIX}}page_group_members ADD COLUMN namespace_new varchar(16) NOT NULL DEFAULT ''; -UPDATE {{TABLE_PREFIX}}page_group_members SET namespace_new = namespace; -ALTER TABLE {{TABLE_PREFIX}}page_group_members DROP namespace; -ALTER TABLE {{TABLE_PREFIX}}page_group_members RENAME namespace_new TO namespace; - --- tags -ALTER TABLE {{TABLE_PREFIX}}tags ADD COLUMN page_id_new varchar(512) NOT NULL DEFAULT ''; -UPDATE {{TABLE_PREFIX}}tags SET page_id_new = page_id; -ALTER TABLE {{TABLE_PREFIX}}tags DROP page_id; -ALTER TABLE {{TABLE_PREFIX}}tags RENAME page_id_new TO page_id; - -ALTER TABLE {{TABLE_PREFIX}}tags ADD COLUMN namespace_new varchar(16) NOT NULL DEFAULT ''; -UPDATE {{TABLE_PREFIX}}tags SET namespace_new = namespace; -ALTER TABLE {{TABLE_PREFIX}}tags DROP namespace; -ALTER TABLE {{TABLE_PREFIX}}tags RENAME namespace_new TO namespace; diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.1.5-1.1.6.php --- a/install/schemas/upgrade/1.1.5-1.1.6.php Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -sql_query('UPDATE ' . table_prefix . "users SET old_encryption = 2 WHERE user_id > 1 AND old_encryption = 0;"); -if ( !$q ) - $db->_die(); - -$q = $db->sql_query('SELECT user_id, password FROM ' . table_prefix . "users WHERE user_id > 1 AND old_encryption = 2;"); -if ( !$q ) - $db->_die(); - -while ( $row = $db->fetchrow($q) ) -{ - $password = $session->pk_decrypt($row['password']); - if ( empty($password) ) - { - global $ui; - echo '

1.1.5-1.1.6 migration script: ERROR: bad password returned from $session->pk_decrypt()

'; - $ui->show_footer(); - exit; - } - $hmac_secret = hexencode(AESCrypt::randkey(20), '', ''); - $password = hmac_sha1($password, $hmac_secret); - $e = $db->sql_query('UPDATE ' . table_prefix . "users SET password = '{$password}', password_salt = '{$hmac_secret}', old_encryption = 0 WHERE user_id = {$row['user_id']};"); - if ( !$e ) - $db->_die(); -} - - diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.1.6-1.1.7-mysql.sql --- a/install/schemas/upgrade/1.1.6-1.1.7-mysql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -ALTER TABLE {{TABLE_PREFIX}}users_extra ADD COLUMN date_format varchar(32) NOT NULL DEFAULT 'F d, Y'; -ALTER TABLE {{TABLE_PREFIX}}users_extra ADD COLUMN time_format varchar(32) NOT NULL DEFAULT 'G:i'; -ALTER TABLE {{TABLE_PREFIX}}lockout ADD COLUMN username varchar(255) NOT NULL DEFAULT ''; -ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN author_uid mediumint(8) NOT NULL DEFAULT 1; -UPDATE {{TABLE_PREFIX}}logs SET author_uid = 1; diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.1.6-1.1.7-postgresql.sql --- a/install/schemas/upgrade/1.1.6-1.1.7-postgresql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -ALTER TABLE {{TABLE_PREFIX}}users_extra ADD COLUMN date_format varchar(32) NOT NULL DEFAULT 'F d, Y'; -ALTER TABLE {{TABLE_PREFIX}}users_extra ADD COLUMN time_format varchar(32) NOT NULL DEFAULT 'G:i'; -ALTER TABLE {{TABLE_PREFIX}}lockout ADD COLUMN username varchar(255) NOT NULL DEFAULT ''; -ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN author_uid int NOT NULL DEFAULT 1; -UPDATE {{TABLE_PREFIX}}logs SET author_uid = 1; diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.1.6-1.1.7.php --- a/install/schemas/upgrade/1.1.6-1.1.7.php Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -sql_query('SELECT user_id, username FROM ' . table_prefix . 'users;'); -if ( !$q ) - $db->_die(); - -$map = array(); -while($row = $db->fetchrow()) -{ - $map[ $row['username'] ] = $row['user_id']; -} -$db->free_result(); - -$q = $db->sql_query('SELECT author FROM ' . table_prefix . 'logs WHERE author_uid = 1;'); -if ( !$q ) - $db->_die(); - -$updated = array(); - -while ( $row = $db->fetchrow($q) ) -{ - if ( isset($map[ $row['author'] ]) && !is_valid_ip($row['author']) && !in_array($row['author'], $updated) ) - { - $author = $db->escape($row['author']); - $sql = "UPDATE " . table_prefix . "logs SET author_uid = {$map[ $row['author'] ]} WHERE author = '$author';"; - if ( !$db->sql_query($sql) ) - $db->_die(); - $updated[] = $row['author']; - } -} - diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.1.7-1.1.8-mysql.sql --- a/install/schemas/upgrade/1.1.7-1.1.8-mysql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ - diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1.1.7-1.1.8-postgresql.sql --- a/install/schemas/upgrade/1.1.7-1.1.8-postgresql.sql Thu Jul 01 18:25:04 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ - diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1124.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/1124.php Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,35 @@ +sql_query('UPDATE ' . table_prefix . "users SET old_encryption = 2 WHERE user_id > 1 AND old_encryption = 0;"); +if ( !$q ) + $db->_die(); + +$q = $db->sql_query('SELECT user_id, password FROM ' . table_prefix . "users WHERE user_id > 1 AND old_encryption = 2;"); +if ( !$q ) + $db->_die(); + +while ( $row = $db->fetchrow($q) ) +{ + $password = $session->pk_decrypt($row['password']); + if ( empty($password) ) + { + global $ui; + echo '

1.1.5-1.1.6 migration script: ERROR: bad password returned from $session->pk_decrypt()

'; + $ui->show_footer(); + exit; + } + $hmac_secret = hexencode(AESCrypt::randkey(20), '', ''); + $password = hmac_sha1($password, $hmac_secret); + $e = $db->sql_query('UPDATE ' . table_prefix . "users SET password = '{$password}', password_salt = '{$hmac_secret}', old_encryption = 0 WHERE user_id = {$row['user_id']};"); + if ( !$e ) + $db->_die(); +} + + diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/1125.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/1125.php Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,35 @@ +sql_query('SELECT user_id, username FROM ' . table_prefix . 'users;'); +if ( !$q ) + $db->_die(); + +$map = array(); +while($row = $db->fetchrow()) +{ + $map[ $row['username'] ] = $row['user_id']; +} +$db->free_result(); + +$q = $db->sql_query('SELECT author FROM ' . table_prefix . 'logs WHERE author_uid = 1;'); +if ( !$q ) + $db->_die(); + +$updated = array(); + +while ( $row = $db->fetchrow($q) ) +{ + if ( isset($map[ $row['author'] ]) && !is_valid_ip($row['author']) && !in_array($row['author'], $updated) ) + { + $author = $db->escape($row['author']); + $sql = "UPDATE " . table_prefix . "logs SET author_uid = {$map[ $row['author'] ]} WHERE author = '$author';"; + if ( !$db->sql_query($sql) ) + $db->_die(); + $updated[] = $row['author']; + } +} + diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/mysql/1010.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/mysql/1010.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,16 @@ +-- Enano CMS +-- Upgrade schema - Enano 1.0 - 1.0.1 + +-- Fix for obnoxious $_GET issue +UPDATE {{TABLE_PREFIX}}sidebar SET block_type=1,block_content='

$INPUT_AUTH$

' WHERE block_name='Search' AND item_id=4; +-- Added on advice from Neal +-- Remember that 1 = AUTH_DENY. +INSERT INTO {{TABLE_PREFIX}}acl(target_type,target_id,page_id,namespace,rules) VALUES(2,1,'Memberlist','Special','read=1;mod_misc=1;upload_files=1;upload_new_version=1;create_page=1;edit_acl=1;'); +-- Bugfix for MySQL 5.0.45, see http://forum.enanocms.org/viewtopic.php?f=5&t=8 +ALTER TABLE {{TABLE_PREFIX}}pages MODIFY COLUMN delvote_ips text DEFAULT NULL; +CREATE TABLE {{TABLE_PREFIX}}page_groups( pg_id mediumint(8) NOT NULL auto_increment, pg_type tinyint(2) NOT NULL DEFAULT 1, pg_name varchar(255) NOT NULL DEFAULT '', pg_target varchar(255) DEFAULT NULL, PRIMARY KEY ( pg_id ) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; +CREATE TABLE {{TABLE_PREFIX}}page_group_members( pg_member_id int(12) NOT NULL auto_increment, pg_id mediumint(8) NOT NULL, page_id varchar(63) NOT NULL, namespace varchar(63) NOT NULL DEFAULT 'Article', PRIMARY KEY ( pg_member_id ) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; +CREATE TABLE {{TABLE_PREFIX}}tags( tag_id int(12) NOT NULL auto_increment, tag_name varchar(63) NOT NULL DEFAULT 'bla', page_id varchar(255) NOT NULL, namespace varchar(255) NOT NULL, user mediumint(8) NOT NULL DEFAULT 1, PRIMARY KEY ( tag_id ) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; +UPDATE {{TABLE_PREFIX}}acl SET rules=CONCAT(rules,'tag_create=4;tag_delete_own=4;tag_delete_other=4;') WHERE target_type=1 AND target_id=2; +DELETE FROM {{TABLE_PREFIX}}search_cache; + diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/mysql/1019.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/mysql/1019.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,29 @@ +-- Enano CMS +-- Upgrade schema - Enano 1.0.2 beta 1 - 1.0.2 release + +-- This is really optional, but could reduce confusion if regex page groups get truncated for no apparent reason. +ALTER TABLE {{TABLE_PREFIX}}page_groups MODIFY COLUMN pg_target text DEFAULT NULL; + +-- I have no idea how or why, but the f'ing index didn't get created for who-knows-how-many releases. +-- We'll attempt to create it here, but don't die if it fails +@ALTER TABLE {{TABLE_PREFIX}}page_text ENGINE = MYISAM, COLLATE = utf8_bin, CHARSET = utf8; +ALTER TABLE {{TABLE_PREFIX}}search_index CHARSET = utf8, COLLATE = utf8_bin, MODIFY COLUMN word varchar(64) NOT NULL; + +-- The search cache is no longer needed because of the new unified search engine (it's too f'ing fast to need a cache :-D) +@DROP TABLE {{TABLE_PREFIX}}search_cache; + +-- Yes, it appears we need pages with names this long after all +ALTER TABLE {{TABLE_PREFIX}}pages MODIFY COLUMN urlname varchar(255), MODIFY COLUMN name varchar(255); + +-- Make page_text a little more efficient to deal with +ALTER TABLE {{TABLE_PREFIX}}page_text MODIFY COLUMN page_id varchar(255), MODIFY COLUMN namespace varchar(63), MODIFY COLUMN page_text longtext; + +-- Now recreate the fulltext index +@CREATE FULLTEXT INDEX {{TABLE_PREFIX}}page_search_idx ON {{TABLE_PREFIX}}page_text(page_id, namespace, page_text); + +-- Addition of new file types +UPDATE {{TABLE_PREFIX}}config SET config_value='cbf:len=185;crc=55fb6f14;data=0[1],1[4],0[3],1[1],0[22],1[1],0[16],1[3],0[16],1[1],0[1],1[2],0[6],1[1],0[1],1[1],0[4],1[2],0[3],1[1],0[48],1[2],0[2],1[1],0[4],1[1],0[37]|end' WHERE config_name = 'allowed_mime_types' AND config_value='cbf:len=168;crc=c3dcad3f;data=0[1],1[4],0[3],1[1],0[2],1[1],0[11],1[1],0[7],1[1],0[9],1[1],0[6],1[3],0[10],1[1],0[2],1[2],0[1],1[1],0[1],1[2],0[6],1[3],0[1],1[1],0[2],1[4],0[1],1[2],0[3],1[1],0[4],1[2],0[26],1[5],0[6],1[2],0[2],1[1],0[4],1[1],0[10],1[2],0[1],1[1],0[6]|end'; + +-- Reinforcement of "stable release" mentality +@UPDATE {{TABLE_PREFIX}}users SET theme='oxygen', style='bleu' WHERE user_id = 2; + diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/mysql/1020.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/mysql/1020.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,1 @@ + diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/mysql/1030.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/mysql/1030.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,1 @@ + diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/mysql/1040.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/mysql/1040.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,1 @@ + diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/mysql/1050.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/mysql/1050.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,1 @@ + diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/mysql/1060.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/mysql/1060.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,1 @@ + diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/mysql/1061.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/mysql/1061.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,1 @@ + diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/mysql/1120.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/mysql/1120.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,36 @@ +-- Enano CMS +-- Upgrade schema - Enano 1.1.1 - 1.1.2 + +ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN log_id int(15) NOT NULL auto_increment, ADD PRIMARY KEY ( log_id ); +ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN is_draft tinyint(1) NOT NULL DEFAULT 0; + +ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_rank int(12) UNSIGNED NOT NULL DEFAULT 1; +ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_timezone int(12) UNSIGNED NOT NULL DEFAULT 1440; + +@ALTER TABLE {{TABLE_PREFIX}}tags CHANGE user user_id mediumint(8) NOT NULL DEFAULT 1; +ALTER TABLE {{TABLE_PREFIX}}themes + ADD COLUMN group_list text DEFAULT NULL, + ADD COLUMN group_policy ENUM('allow', 'deny') NOT NULL DEFAULT 'deny'; + +CREATE TABLE {{TABLE_PREFIX}}ranks( + rank_id int(12) NOT NULL auto_increment, + rank_title varchar(63) NOT NULL DEFAULT '', + rank_style varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY ( rank_id ) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + +CREATE TABLE {{TABLE_PREFIX}}captcha( + code_id int(12) NOT NULL auto_increment, + session_id varchar(40) NOT NULL DEFAULT '', + code varchar(64) NOT NULL DEFAULT '', + session_data text, + source_ip varchar(39), + user_id int(12), + PRIMARY KEY ( code_id ) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + +INSERT INTO {{TABLE_PREFIX}}ranks(rank_id, rank_title, rank_style) VALUES + (1, 'user_rank_member', ''), + (2, 'user_rank_mod', 'font-weight: bold; color: #00AA00;'), + (3, 'user_rank_admin', 'font-weight: bold; color: #AA0000;'); + diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/mysql/1121.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/mysql/1121.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,15 @@ +-- Enano CMS +-- Upgrade schema: 1.1.2 - 1.1.3 + +-- Storing obscenely huge integers as strings since that's how php processes them. + +CREATE TABLE {{TABLE_PREFIX}}diffiehellman ( + key_id int(12) NOT NULL auto_increment, + private_key text, + public_key text, + PRIMARY KEY ( key_id ) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + +ALTER TABLE {{TABLE_PREFIX}}session_keys MODIFY COLUMN source_ip varchar(39) NOT NULL DEFAULT '127.0.0.1'; +ALTER TABLE {{TABLE_PREFIX}}themes MODIFY COLUMN group_policy ENUM('allow_all', 'whitelist', 'blacklist') NOT NULL DEFAULT 'allow_all'; +UPDATE {{TABLE_PREFIX}}themes SET group_policy = 'allow_all'; diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/mysql/1122.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/mysql/1122.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,32 @@ +-- This is really honestly a better way to handle plugins. + +CREATE TABLE {{TABLE_PREFIX}}plugins ( + plugin_id int(12) NOT NULL auto_increment, + plugin_filename varchar(63), + plugin_flags int(12), + plugin_version varchar(16), + PRIMARY KEY ( plugin_id ) +) ENGINE `MyISAM` CHARACTER SET `utf8` COLLATE `utf8_bin`; + +ALTER TABLE {{TABLE_PREFIX}}search_index ADD COLUMN word_lcase varchar(64) NOT NULL; + +-- User title +ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_title varchar(64) DEFAULT NULL; +ALTER TABLE {{TABLE_PREFIX}}users MODIFY COLUMN user_rank int(12) unsigned DEFAULT NULL; +ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_group mediumint(5) NOT NULL DEFAULT 1; +UPDATE {{TABLE_PREFIX}}users SET user_rank = NULL; + +-- The "guest" rank +-- No frontend to this yet so ranks should not have been created. +DELETE FROM {{TABLE_PREFIX}}ranks WHERE rank_id = 4; +INSERT INTO {{TABLE_PREFIX}}ranks(rank_id, rank_title, rank_style) VALUES + (4, 'user_rank_guest', ''); + +-- Other rank-related columns +ALTER TABLE {{TABLE_PREFIX}}groups ADD COLUMN group_rank int(12) unsigned DEFAULT NULL; + +-- Disable JS effects column +ALTER TABLE {{TABLE_PREFIX}}users_extra ADD COLUMN disable_js_fx tinyint(1) NOT NULL DEFAULT 0; + +-- Add "grv" avatar type +ALTER TABLE {{TABLE_PREFIX}}users MODIFY COLUMN avatar_type ENUM('png', 'gif', 'jpg', 'grv'); diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/mysql/1123.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/mysql/1123.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,4 @@ +ALTER TABLE {{TABLE_PREFIX}}session_keys ADD COLUMN key_type tinyint(1) NOT NULL DEFAULT 0; +UPDATE {{TABLE_PREFIX}}session_keys SET key_type = 2 WHERE auth_level > 2; +ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_dst varchar(11) NOT NULL DEFAULT '0;0;0;0;60'; +ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_rank_userset tinyint(1) NOT NULL DEFAULT 0; diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/mysql/1124.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/mysql/1124.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,41 @@ +ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN password_salt varchar(40) NOT NULL DEFAULT ''; +ALTER TABLE {{TABLE_PREFIX}}pages ADD COLUMN page_format varchar(16) NOT NULL DEFAULT 'wikitext'; +ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN page_format varchar(16) NOT NULL DEFAULT 'wikitext'; + +-- Make page_id and namespace column sizes consistent (former bug) + +ALTER TABLE {{TABLE_PREFIX}}comments MODIFY COLUMN page_id varchar(512) NOT NULL, + MODIFY COLUMN namespace varchar(16) NOT NULL; + +ALTER TABLE {{TABLE_PREFIX}}logs MODIFY COLUMN page_id varchar(512) NOT NULL, + MODIFY COLUMN namespace varchar(16) NOT NULL; + +ALTER TABLE {{TABLE_PREFIX}}page_text MODIFY COLUMN page_id varchar(512) NOT NULL; + +ALTER TABLE {{TABLE_PREFIX}}pages MODIFY COLUMN urlname varchar(512) NOT NULL; + +ALTER TABLE {{TABLE_PREFIX}}hits MODIFY COLUMN page_id varchar(512) NOT NULL, + MODIFY COLUMN namespace varchar(16) NOT NULL; + +ALTER TABLE {{TABLE_PREFIX}}acl MODIFY COLUMN page_id varchar(512), + MODIFY COLUMN namespace varchar(16); + +ALTER TABLE {{TABLE_PREFIX}}page_group_members MODIFY COLUMN page_id varchar(512) NOT NULL, + MODIFY COLUMN namespace varchar(16) NOT NULL; + +ALTER TABLE {{TABLE_PREFIX}}tags MODIFY COLUMN page_id varchar(512) NOT NULL, + MODIFY COLUMN namespace varchar(16) NOT NULL; + +-- Added in 1.1.6: Indices for several tables +-- The size of 317 is a trial-and-error-produced value based on MySQL's index column size limit +-- of 1000 bytes. It's low like that because of the UTF-8 character set being used. + +@ALTER TABLE {{TABLE_PREFIX}}logs ADD INDEX {{TABLE_PREFIX}}logs_page_idx (page_id(317), namespace); +@ALTER TABLE {{TABLE_PREFIX}}logs ADD INDEX {{TABLE_PREFIX}}logs_time_idx (time_id); +@ALTER TABLE {{TABLE_PREFIX}}logs ADD INDEX {{TABLE_PREFIX}}logs_action_idx (log_type, action); +@ALTER TABLE {{TABLE_PREFIX}}comments ADD INDEX {{TABLE_PREFIX}}comments_page_idx (page_id(317), namespace); +@ALTER TABLE {{TABLE_PREFIX}}hits ADD INDEX {{TABLE_PREFIX}}hits_time_idx ( time ); +@ALTER TABLE {{TABLE_PREFIX}}hits ADD INDEX {{TABLE_PREFIX}}hits_page_idx (page_id(317), namespace); +@ALTER TABLE {{TABLE_PREFIX}}pages ADD INDEX {{TABLE_PREFIX}}pages_page_idx (urlname(317), namespace); +@ALTER TABLE {{TABLE_PREFIX}}page_text ADD INDEX {{TABLE_PREFIX}}page_text_page_idx (page_id(317), namespace); + diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/mysql/1125.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/mysql/1125.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,5 @@ +ALTER TABLE {{TABLE_PREFIX}}users_extra ADD COLUMN date_format varchar(32) NOT NULL DEFAULT 'F d, Y'; +ALTER TABLE {{TABLE_PREFIX}}users_extra ADD COLUMN time_format varchar(32) NOT NULL DEFAULT 'G:i'; +ALTER TABLE {{TABLE_PREFIX}}lockout ADD COLUMN username varchar(255) NOT NULL DEFAULT ''; +ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN author_uid mediumint(8) NOT NULL DEFAULT 1; +UPDATE {{TABLE_PREFIX}}logs SET author_uid = 1; diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/postgresql/1120.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/postgresql/1120.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,40 @@ +-- Enano CMS +-- Upgrade schema - Enano 1.1.1 - 1.1.2 + +ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN log_id SERIAL, ADD PRIMARY KEY ( log_id ); +ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN is_draft smallint NOT NULL DEFAULT 0; + +ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_rank int NOT NULL DEFAULT 1; +@ALTER TABLE {{TABLE_PREFIX}}users DROP user_timezone; +ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_timezone int NOT NULL DEFAULT 1440; + +ALTER TABLE {{TABLE_PREFIX}}themes + ADD COLUMN group_list text DEFAULT NULL, + ADD COLUMN group_policy varchar(5) NOT NULL DEFAULT 'deny', + ADD CHECK (group_policy IN ('allow', 'deny')); + +CREATE TABLE {{TABLE_PREFIX}}ranks( + rank_id SERIAL, + rank_title varchar(63) NOT NULL DEFAULT '', + rank_style varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY ( rank_id ) +); + +CREATE TABLE {{TABLE_PREFIX}}captcha( + code_id SERIAL, + session_id varchar(40) NOT NULL DEFAULT '', + code varchar(64) NOT NULL DEFAULT '', + session_data text, + source_ip varchar(39), + user_id int, + PRIMARY KEY ( code_id ) +); + +INSERT INTO {{TABLE_PREFIX}}ranks(rank_id, rank_title, rank_style) VALUES + (1, 'user_rank_member', ''), + (2, 'user_rank_mod', 'font-weight: bold; color: #00AA00;'), + (3, 'user_rank_admin', 'font-weight: bold; color: #AA0000;'); + +-- For some reason this is required, it came up in my QA testing on a2hosting +SELECT NEXTVAL('{{TABLE_PREFIX}}ranks_rank_id_seq'::regclass); + diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/postgresql/1121.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/postgresql/1121.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,18 @@ +-- Enano CMS +-- Upgrade schema: 1.1.2 - 1.1.3 + +-- Storing obscenely huge integers as strings since that's how php processes them. + +CREATE TABLE {{TABLE_PREFIX}}diffiehellman ( + key_id SERIAL, + private_key text, + public_key text, + PRIMARY KEY ( key_id ) +); + +ALTER TABLE {{TABLE_PREFIX}}themes DROP group_policy, ADD COLUMN group_policy varchar(9) NOT NULL DEFAULT 'allow_all', ADD CHECK ( group_policy IN ('allow_all', 'whitelist', 'blacklist') ); + +ALTER TABLE {{TABLE_PREFIX}}session_keys ALTER COLUMN source_ip TYPE varchar(39), + ADD CHECK ( source_ip IS NOT NULL ), + ALTER COLUMN source_ip SET DEFAULT '127.0.0.1'; + diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/postgresql/1122.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/postgresql/1122.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,48 @@ +-- This is really honestly a better way to handle plugins. + +CREATE TABLE {{TABLE_PREFIX}}plugins ( + plugin_id SERIAL, + plugin_filename varchar(63), + plugin_flags int, + plugin_version varchar(16), + PRIMARY KEY ( plugin_id ) +); + +-- User title +ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_title varchar(64) DEFAULT NULL; + +-- Modifications to user_rank column +-- http://pgsqld.active-venture.com/ddl-alter.html#AEN1984 +ALTER TABLE {{TABLE_PREFIX}}users ALTER COLUMN user_rank DROP NOT NULL, + ALTER COLUMN user_rank DROP DEFAULT; +ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_group int NOT NULL DEFAULT 1; +UPDATE {{TABLE_PREFIX}}users SET user_rank = NULL; + +-- Aggregate function array_accum +-- http://www.postgresql.org/docs/current/static/xaggr.html + +CREATE AGGREGATE {{TABLE_PREFIX}}array_accum (anyelement) +( + sfunc = array_append, + stype = anyarray, + initcond = '{}' +); + +-- The "guest" rank +-- No frontend to this yet so ranks should not have been created. +DELETE FROM {{TABLE_PREFIX}}ranks WHERE rank_id = 4; +INSERT INTO {{TABLE_PREFIX}}ranks(rank_id, rank_title, rank_style) VALUES + (4, 'user_rank_guest', ''); + +-- For some reason this is required, it came up in my QA testing on a2hosting +SELECT NEXTVAL('{{TABLE_PREFIX}}ranks_rank_id_seq'::regclass); + +-- Other rank-related columns +ALTER TABLE {{TABLE_PREFIX}}groups ADD COLUMN group_rank int DEFAULT NULL; + +-- Disable JS effects column +ALTER TABLE {{TABLE_PREFIX}}users_extra ADD COLUMN disable_js_fx smallint NOT NULL DEFAULT 0; + +-- Add "grv" avatar type +ALTER TABLE {{TABLE_PREFIX}}users DROP CONSTRAINT {{TABLE_PREFIX}}users_avatar_type_check; +ALTER TABLE {{TABLE_PREFIX}}users ADD CONSTRAINT {{TABLE_PREFIX}}users_avatar_type_check CHECK ( avatar_type IN ( 'png', 'gif', 'jpg', 'grv' ) ); diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/postgresql/1123.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/postgresql/1123.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,4 @@ +ALTER TABLE {{TABLE_PREFIX}}session_keys ADD COLUMN key_type smallint NOT NULL DEFAULT 0; +UPDATE {{TABLE_PREFIX}}session_keys SET key_type = 2 WHERE auth_level > 2; +ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_dst varchar(11) NOT NULL DEFAULT '0;0;0;0;60'; +ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_rank_userset smallint NOT NULL DEFAULT 0; diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/postgresql/1124.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/postgresql/1124.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,86 @@ +ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN password_salt varchar(40) NOT NULL DEFAULT ''; +ALTER TABLE {{TABLE_PREFIX}}pages ADD COLUMN page_format varchar(16) NOT NULL DEFAULT 'wikitext'; +ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN page_format varchar(16) NOT NULL DEFAULT 'wikitext'; + +-- +-- Make page_id and namespace column sizes consistent (former bug) +-- Yes, this is a PITA in PostgreSQL. +-- + +-- comments +ALTER TABLE {{TABLE_PREFIX}}comments ADD COLUMN page_id_new varchar(512) NOT NULL DEFAULT ''; +UPDATE {{TABLE_PREFIX}}comments SET page_id_new = page_id; +ALTER TABLE {{TABLE_PREFIX}}comments DROP page_id; +ALTER TABLE {{TABLE_PREFIX}}comments RENAME page_id_new TO page_id; + +ALTER TABLE {{TABLE_PREFIX}}comments ADD COLUMN namespace_new varchar(16) NOT NULL DEFAULT ''; +UPDATE {{TABLE_PREFIX}}comments SET namespace_new = namespace; +ALTER TABLE {{TABLE_PREFIX}}comments DROP namespace; +ALTER TABLE {{TABLE_PREFIX}}comments RENAME namespace_new TO namespace; + +-- logs +ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN page_id_new varchar(512) NOT NULL DEFAULT ''; +UPDATE {{TABLE_PREFIX}}logs SET page_id_new = page_id; +ALTER TABLE {{TABLE_PREFIX}}logs DROP page_id; +ALTER TABLE {{TABLE_PREFIX}}logs RENAME page_id_new TO page_id; + +ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN namespace_new varchar(16) NOT NULL DEFAULT ''; +UPDATE {{TABLE_PREFIX}}logs SET namespace_new = namespace; +ALTER TABLE {{TABLE_PREFIX}}logs DROP namespace; +ALTER TABLE {{TABLE_PREFIX}}logs RENAME namespace_new TO namespace; + +-- page_text +ALTER TABLE {{TABLE_PREFIX}}page_text ADD COLUMN page_id_new varchar(512) NOT NULL DEFAULT ''; +UPDATE {{TABLE_PREFIX}}page_text SET page_id_new = page_id; +ALTER TABLE {{TABLE_PREFIX}}page_text DROP page_id; +ALTER TABLE {{TABLE_PREFIX}}page_text RENAME page_id_new TO page_id; + +-- pages +ALTER TABLE {{TABLE_PREFIX}}pages ADD COLUMN urlname_new varchar(512) NOT NULL DEFAULT ''; +UPDATE {{TABLE_PREFIX}}pages SET urlname_new = urlname; +ALTER TABLE {{TABLE_PREFIX}}pages DROP urlname; +ALTER TABLE {{TABLE_PREFIX}}pages RENAME urlname_new TO urlname; + +-- hits +ALTER TABLE {{TABLE_PREFIX}}hits ADD COLUMN page_id_new varchar(512) NOT NULL DEFAULT ''; +UPDATE {{TABLE_PREFIX}}hits SET page_id_new = page_id; +ALTER TABLE {{TABLE_PREFIX}}hits DROP page_id; +ALTER TABLE {{TABLE_PREFIX}}hits RENAME page_id_new TO page_id; + +ALTER TABLE {{TABLE_PREFIX}}hits ADD COLUMN namespace_new varchar(16) NOT NULL DEFAULT ''; +UPDATE {{TABLE_PREFIX}}hits SET namespace_new = namespace; +ALTER TABLE {{TABLE_PREFIX}}hits DROP namespace; +ALTER TABLE {{TABLE_PREFIX}}hits RENAME namespace_new TO namespace; + +-- acl +ALTER TABLE {{TABLE_PREFIX}}acl ADD COLUMN page_id_new varchar(512) DEFAULT NULL; +UPDATE {{TABLE_PREFIX}}acl SET page_id_new = page_id; +ALTER TABLE {{TABLE_PREFIX}}acl DROP page_id; +ALTER TABLE {{TABLE_PREFIX}}acl RENAME page_id_new TO page_id; + +ALTER TABLE {{TABLE_PREFIX}}acl ADD COLUMN namespace_new varchar(16) DEFAULT NULL; +UPDATE {{TABLE_PREFIX}}acl SET namespace_new = namespace; +ALTER TABLE {{TABLE_PREFIX}}acl DROP namespace; +ALTER TABLE {{TABLE_PREFIX}}acl RENAME namespace_new TO namespace; + +-- page_group_members +ALTER TABLE {{TABLE_PREFIX}}page_group_members ADD COLUMN page_id_new varchar(512) NOT NULL DEFAULT ''; +UPDATE {{TABLE_PREFIX}}page_group_members SET page_id_new = page_id; +ALTER TABLE {{TABLE_PREFIX}}page_group_members DROP page_id; +ALTER TABLE {{TABLE_PREFIX}}page_group_members RENAME page_id_new TO page_id; + +ALTER TABLE {{TABLE_PREFIX}}page_group_members ADD COLUMN namespace_new varchar(16) NOT NULL DEFAULT ''; +UPDATE {{TABLE_PREFIX}}page_group_members SET namespace_new = namespace; +ALTER TABLE {{TABLE_PREFIX}}page_group_members DROP namespace; +ALTER TABLE {{TABLE_PREFIX}}page_group_members RENAME namespace_new TO namespace; + +-- tags +ALTER TABLE {{TABLE_PREFIX}}tags ADD COLUMN page_id_new varchar(512) NOT NULL DEFAULT ''; +UPDATE {{TABLE_PREFIX}}tags SET page_id_new = page_id; +ALTER TABLE {{TABLE_PREFIX}}tags DROP page_id; +ALTER TABLE {{TABLE_PREFIX}}tags RENAME page_id_new TO page_id; + +ALTER TABLE {{TABLE_PREFIX}}tags ADD COLUMN namespace_new varchar(16) NOT NULL DEFAULT ''; +UPDATE {{TABLE_PREFIX}}tags SET namespace_new = namespace; +ALTER TABLE {{TABLE_PREFIX}}tags DROP namespace; +ALTER TABLE {{TABLE_PREFIX}}tags RENAME namespace_new TO namespace; diff -r d972b1276d95 -r 49db7495f6b8 install/schemas/upgrade/postgresql/1125.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/schemas/upgrade/postgresql/1125.sql Thu Jul 01 20:24:19 2010 -0400 @@ -0,0 +1,5 @@ +ALTER TABLE {{TABLE_PREFIX}}users_extra ADD COLUMN date_format varchar(32) NOT NULL DEFAULT 'F d, Y'; +ALTER TABLE {{TABLE_PREFIX}}users_extra ADD COLUMN time_format varchar(32) NOT NULL DEFAULT 'G:i'; +ALTER TABLE {{TABLE_PREFIX}}lockout ADD COLUMN username varchar(255) NOT NULL DEFAULT ''; +ALTER TABLE {{TABLE_PREFIX}}logs ADD COLUMN author_uid int NOT NULL DEFAULT 1; +UPDATE {{TABLE_PREFIX}}logs SET author_uid = 1; diff -r d972b1276d95 -r 49db7495f6b8 install/upgrade.php --- a/install/upgrade.php Thu Jul 01 18:25:04 2010 -0400 +++ b/install/upgrade.php Thu Jul 01 20:24:19 2010 -0400 @@ -20,6 +20,8 @@ $enano_versions['1.0'] = array('1.0', '1.0.1', '1.0.2b1', '1.0.2', '1.0.3', '1.0.4', '1.0.5', '1.0.6', '1.0.6pl1'); $enano_versions['1.1'] = array('1.1.1', '1.1.2', '1.1.3', '1.1.4', '1.1.5', '1.1.6', '1.1.7', '1.1.8'); +define('BANSHEE_LATEST_DBREV', 1061); + // If true, this will do a full langimport instead of only adding new strings. // Will probably be left on, but some change probably needs to be made to mark // strings as customized in the DB. @@ -71,7 +73,7 @@ $stg_finish = $ui->add_stage($lang->get('upgrade_stg_finish'), true); // Version check -if ( enano_version() == installer_enano_version() ) +if ( getConfig('db_version') === $db_version && !preg_match('/^upg-/', getConfig('enano_version')) ) { $ui->show_header(); $link_home = makeUrl(get_main_page(), false, true); @@ -237,7 +239,7 @@ if ( $target_branch != $current_branch ) { // First upgrade to the latest revision of the current branch - enano_perform_upgrade($current_branch); + enano_perform_upgrade(BANSHEE_LATEST_DBREV); // Branch migration could be tricky and is often highly specific between // major branches, so just include a custom migration script. require(ENANO_ROOT . "/install/schemas/upgrade/migration/{$current_branch}-{$target_branch}.php"); @@ -248,10 +250,11 @@ $ui->show_footer(); exit; } + setConfig('db_version', BANSHEE_LATEST_DBREV + 1); } // Do the actual upgrade - enano_perform_upgrade($target_branch); + enano_perform_upgrade($db_version); // Mark as upgrade-in-progress setConfig('enano_version', 'upg-' . installer_enano_version()); @@ -313,7 +316,7 @@ { ?>

get('upgrade_confirm_title'); ?>

-

get('upgrade_confirm_body', array('enano_version' => installer_enano_version())); ?>

+

get('upgrade_confirm_body', array('enano_version' => installer_enano_version(), 'db_version' => $db_version)); ?>