|
From: Ken T. <ke...@us...> - 2003-04-19 18:13:11
|
Update of /cvsroot/phpbt/phpbt
In directory sc8-pr-cvs1:/tmp/cvs-serv13800
Modified Files:
config-dist.php config.php upgrade.php
Log Message:
* new database update model
- database schema is versioned
* new assignable-group declaration
- each group has an assignable flag
- configurable by admin/group.php
- updated build_select's owner section
Index: config-dist.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/config-dist.php,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- config-dist.php 8 Apr 2003 14:34:44 -0000 1.23
+++ config-dist.php 19 Apr 2003 18:12:36 -0000 1.24
@@ -34,6 +34,7 @@
// Database Table Config
// you can change either the prefix of the table names or each table name individually
+define ('DB_VERSION', 2); // the version of the database
define ('TBL_PREFIX', '{tbl_prefix}'); // the prefix for all tables, leave empty to use the old style
define ('TBL_ACTIVE_SESSIONS', TBL_PREFIX.'active_sessions');
Index: config.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/config.php,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- config.php 7 Apr 2003 18:55:35 -0000 1.35
+++ config.php 19 Apr 2003 18:12:36 -0000 1.36
@@ -37,6 +37,7 @@
// Database Table Config
// you can change either the prefix of the table names or each table name individually
+define ('DB_VERSION', 2); // the version of the database
define ('TBL_PREFIX', ''); // the prefix for all tables, leave empty to use the old style
define ('TBL_ACTIVE_SESSIONS', TBL_PREFIX.'active_sessions');
define ('TBL_DB_SEQUENCE', TBL_PREFIX.'db_sequence');
Index: upgrade.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/upgrade.php,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- upgrade.php 9 Apr 2003 12:25:18 -0000 1.32
+++ upgrade.php 19 Apr 2003 18:12:37 -0000 1.33
@@ -29,8 +29,9 @@
function upgrade() {
global $db;
- $upgraded = $db->getOne('select varname from '.TBL_CONFIGURATION.' where varname = \'GROUP_ASSIGN_TO\'');
- if (!$upgraded or DB::isError($upgraded)) {
+ $thisvers = $db->getOne('select varvalue from '.TBL_CONFIGURATION.' where varname = \'DB_VERSION\'');
+ if ($thisvers == DB_VERSION) $upgraded = 1;
+ if (!$upgraded or DB::isError($thisvers)) {
if (!@is_writeable('c_templates')) {
include('templates/default/base/templatesperm.html');
exit;
@@ -38,17 +39,34 @@
switch(DB_TYPE) {
case 'pgsql' :
$db->query("create table ".TBL_PROJECT_PERM." ( project_id INT4 NOT NULL DEFAULT '0', user_id INT4 NOT NULL DEFAULT '0' )");
+ //! TBL_AUTH_GROUP
break;
case 'mysql' :
- $db->query("create table ".TBL_PROJECT_PERM." ( project_id int(11) NOT NULL default '0', user_id int(11) NOT NULL default '0' )");
+ $db->query("create table if not exists ".TBL_PROJECT_PERM." ( project_id int(11) NOT NULL default '0', user_id int(11) NOT NULL default '0' )");
+ if ($thisvers < 2)
+ $db->query("alter table ".TBL_AUTH_GROUP." ADD assignable TINYINT DEFAULT 0 NOT NULL AFTER locked");
break;
case 'oci8' :
$db->query("create table ".TBL_PROJECT_PERM." ( project_id number(10) default '0' NOT NULL, user_id number(10) default '0' NOT NULL )");
+ //! TBL_AUTH_GROUP
break;
}
- $db->query("INSERT INTO ".TBL_CONFIGURATION." VALUES ('GROUP_ASSIGN_TO', '3', 'The group to whom bugs can be assigned', 'multi');");
- $db->query("INSERT INTO ".TBL_CONFIGURATION." VALUES ('EMAIL_DISABLED', '0', 'Whether to disable all mail sent from the system', 'bool');");
+ if ($thisvers < 2) {
+ $db->query("DELETE FROM ".TBL_CONFIGURATION." WHERE varname = 'GROUP_ASSIGN_TO'");
+ $db->query("UPDATE ".TBL_AUTH_GROUP." SET assignable = 1 WHERE group_id = 3");
+ $db->query("INSERT INTO ".TBL_CONFIGURATION." VALUES ('EMAIL_DISABLED', '0', 'Whether to disable all mail sent from the system', 'bool');");
+ /* add db-version attribute */
+ $db->query("INSERT INTO ".TBL_CONFIGURATION." VALUES ('DB_VERSION', '".DB_VERSION."', 'Database Version <b>Warning:</b> Changing this might make things go horribly wrong.', 'string')");
+ }
+
+ if ($thisvers < 3) {
+
+ }
+
+ /* update to current DB_VERSION */
+ $db->query("UPDATE ".TBL_CONFIGURATION." SET varvalue = '".DB_VERSION."' WHERE varname = 'DB_VERSION'");
+
}
include 'templates/default/upgrade-finished.html';
}
@@ -59,4 +77,4 @@
include 'templates/default/upgrade.html';
}
-?>
+?>
\ No newline at end of file
|