X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=dbinstall.php;h=f333bd3a00e937ff5e76b4168a9497f3d08c0ef9;hb=08bbf671649fd5419fe4d38fab621e053472e8ce;hp=07cb37d765dc689be506a1d491f7edd1d41621a6;hpb=7bafd815e19a8c4535a3684c01955fe7b789982d;p=timetracker.git
diff --git a/dbinstall.php b/dbinstall.php
index 07cb37d7..f333bd3a 100755
--- a/dbinstall.php
+++ b/dbinstall.php
@@ -32,6 +32,8 @@ require_once('initialize.php');
import('ttUserHelper');
import('ttTaskHelper');
+// setChange - executes an sql statement. TODO: rename this function to something better.
+// Better yet, redo the entire thing and make an installer.
function setChange($sql) {
print "
".$sql." ";
$mdb2 = getConnection();
@@ -42,6 +44,7 @@ function setChange($sql) {
print "successful update \n";
}
+
if ($request->isGet()) {
echo('Environment Checks ');
@@ -152,6 +155,16 @@ if ($request->isGet()) {
} else {
echo('There are no tables in database. Execute step 1 - Create database structure. ');
}
+
+ $sql = "select param_value from tt_site_config where param_name = 'version_db'";
+ $res = $conn->query($sql);
+ if (is_a($res, 'MDB2_Error')) {
+ echo('Error: database schema version query failed. '.$res->getMessage().' ');
+ } else {
+ $val = $res->fetchRow();
+ echo('Database version is: '.$val['param_value'].'.');
+ }
+
$conn->disconnect();
}
@@ -709,7 +722,7 @@ if ($_POST) {
setChange("ALTER TABLE `tt_log` ADD `paid` tinyint(4) NULL default '0' AFTER `billable`");
}
- if ($_POST["convert11400to11719"]) {
+ if ($_POST["convert11400to11735"]) {
setChange("ALTER TABLE `tt_teams` DROP `address`");
setChange("ALTER TABLE `tt_fav_reports` ADD `report_spec` text default NULL AFTER `user_id`");
setChange("ALTER TABLE `tt_fav_reports` ADD `paid_status` tinyint(4) default NULL AFTER `invoice`");
@@ -725,6 +738,20 @@ if ($_POST) {
setChange("UPDATE `tt_monthly_quotas` SET `minutes` = 60 * `quota`");
setChange("ALTER TABLE `tt_monthly_quotas` DROP `quota`");
setChange("ALTER TABLE `tt_teams` DROP `uncompleted_indicators`");
+ setChange("ALTER TABLE `tt_users` MODIFY `timestamp` timestamp default CURRENT_TIMESTAMP");
+ setChange("ALTER TABLE `tt_teams` MODIFY `timestamp` timestamp default CURRENT_TIMESTAMP");
+ setChange("ALTER TABLE `tt_log` MODIFY `timestamp` timestamp default CURRENT_TIMESTAMP");
+ setChange("ALTER TABLE `tt_tmp_refs` MODIFY `timestamp` timestamp default CURRENT_TIMESTAMP");
+ setChange("CREATE TABLE `tt_roles` (`id` int(11) NOT NULL auto_increment, `team_id` int(11) NOT NULL, `name` varchar(80) default NULL, `rank` int(11) default 0, `rights` text default NULL, `status` tinyint(4) default 1, PRIMARY KEY (`id`))");
+ setChange("create unique index role_idx on tt_roles(team_id, rank, status)");
+ setChange("ALTER TABLE `tt_roles` ADD `description` varchar(255) default NULL AFTER `name`");
+ setChange("ALTER TABLE `tt_users` ADD `role_id` int(11) default NULL AFTER `role`");
+ setChange("CREATE TABLE `tt_site_config` (`param_name` varchar(32) NOT NULL, `param_value` text default NULL, `created` datetime default NULL, `updated` datetime default NULL, PRIMARY KEY (`param_name`))");
+ setChange("INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.17.34', now())");
+ setChange("INSERT INTO `tt_roles` (`team_id`, `name`, `rank`, `rights`) VALUES (0, 'Site administrator', 1024, 'administer_site')");
+ setChange("INSERT INTO `tt_roles` (`team_id`, `name`, `rank`, `rights`) VALUES (0, 'Top manager', 512, 'data_entry,view_own_data,manage_own_settings,view_users,on_behalf_data_entry,view_data,override_punch_mode,swap_roles,approve_timesheets,manage_users,manage_projects,manage_tasks,manage_custom_fields,manage_clients,manage_invoices,manage_features,manage_basic_settings,manage_advanced_settings,manage_roles,export_data,manage_subgroups')");
+ setChange("UPDATE `tt_site_config` SET `param_value` = '1.17.35' where param_name = 'version_db'");
+ setChange("update `tt_users` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.17.35') set role_id = (select id from tt_roles where rank = 1024) where role = 1024");
}
if ($_POST["cleanup"]) {
@@ -757,6 +784,7 @@ if ($_POST) {
setChange("OPTIMIZE TABLE tt_tmp_refs");
setChange("OPTIMIZE TABLE tt_user_project_binds");
setChange("OPTIMIZE TABLE tt_users");
+ setChange("OPTIMIZE TABLE tt_roles");
}
print "done. \n";
@@ -769,7 +797,7 @@ if ($_POST) {
DB Install
@@ -805,8 +833,8 @@ if ($_POST) {
- Update database structure (v1.14 to v1.17.19)
-
+ Update database structure (v1.14 to v1.17.35)
+