|
From: Benjamin C. <bc...@us...> - 2002-03-18 15:54:42
|
Update of /cvsroot/phpbt/phpbt
In directory usw-pr-cvs1:/tmp/cvs-serv16557
Modified Files:
upgrade.php
Log Message:
Updated for 0.8.0
Index: upgrade.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/upgrade.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- upgrade.php 17 Mar 2002 01:44:24 -0000 1.11
+++ upgrade.php 18 Mar 2002 15:54:39 -0000 1.12
@@ -28,17 +28,24 @@
function upgrade() {
global $db;
- $upgraded = $db->getOne('select varvalue from '.TBL_CONFIGURATION.
- " where varname = 'PROMOTE_VOTES'");
- if (!$upgraded) {
- // Add the bug_vote table and insert the new configuration options
+ $upgraded = $db->getOne('select count(*) from '.TBL_BUG.'_seq');
+ if (!$upgraded or DB::isError($upgraded)) {
+ // Convert the sequences
+ if (DB_TYPE == 'mysql') {
+ // Just in case we have someone who started using phpbt a long time ago...
+ $db->query('update '.TBL_DB_SEQUENCE.' set seq_name = lower(seq_name)');
+ }
+ $rs = $db->query("select * from ".TBL_DB_SEQUENCE);
if (DB_TYPE == 'pgsql') {
- $db->query("CREATE TABLE ".TBL_BUG_VOTE." ( user_id INT4 NOT NULL DEFAULT '0', bug_id INT4 NOT NULL DEFAULT '0', created_date INT8 NOT NULL DEFAULT '0', PRIMARY KEY (user_id,bug_id) );");
+ while ($rs->fetchInto($row)) {
+ $db->query("create sequence {$row['seq_name']}_seq start {$row['nextid']}");
+ }
} else {
- $db->query("create table ".TBL_BUG_VOTE." ( user_id int(10) unsigned NOT NULL default '0', bug_id int(10) unsigned NOT NULL default '0', created_date bigint(20) unsigned NOT NULL default '0', PRIMARY KEY (user_id, bug_id), KEY bug_id (bug_id) )");
+ while ($rs->fetchInto($row)) {
+ $db->query("create table {$row['seq_name']}_seq (id int unsigned auto_increment not null primary key)");
+ $db->query("insert into {$row['seq_name']}_seq values ({$row['nextid']})");
+ }
}
- $db->query("INSERT INTO ".TBL_CONFIGURATION." VALUES ('PROMOTE_VOTES', 5, 'The number of votes required to promote a bug from Unconfirmed to New (Set to 0 to disable promotions by voting)', 'string')");
- $db->query("INSERT INTO ".TBL_CONFIGURATION." VALUES ('MAX_USER_VOTES', 5, 'The maximum number of votes a user can cast across all bugs (Set to 0 to have no limit)', 'string')");
}
include 'templates/default/upgrade-finished.html';
}
|