diff options
author | Jan-Philipp Litza <jplitza@sylar.(none)> | 2011-12-26 16:04:54 +0100 |
---|---|---|
committer | Jan-Philipp Litza <jplitza@sylar.(none)> | 2011-12-26 16:04:54 +0100 |
commit | 7154097581f231753005aaabdc12d00173b7ce27 (patch) | |
tree | 2fdc6e62e01a8f271c2d249756762e9fd91f7754 /db/update.d/06_Shifts.php | |
parent | bc471460fc8cce0bb9d8b5631e8d57fdec6a3b39 (diff) |
database update script
Diffstat (limited to 'db/update.d/06_Shifts.php')
-rw-r--r-- | db/update.d/06_Shifts.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/db/update.d/06_Shifts.php b/db/update.d/06_Shifts.php new file mode 100644 index 00000000..721d73bc --- /dev/null +++ b/db/update.d/06_Shifts.php @@ -0,0 +1,29 @@ +<?php +if(sql_num_query("SHOW COLUMNS FROM `Shifts` LIKE 'Date_'") == 2) { + if(sql_num_query("DESCRIBE `Shifts` `Len`") != 0) { + if(sql_num_query("SELECT * FROM `Shifts` WHERE DATE_SUB(`DateE`, INTERVAL (`Len`*60) MINUTE) != `DateS`") != 0) + die("Inconsistent data in Shifts table, won't do update " . __FILE__); + else { + sql_query("ALTER TABLE `Shifts` DROP `Len`"); + } + } + sql_query("ALTER TABLE `Shifts` CHANGE `DateS` `start` INT NOT NULL, CHANGE `DateE` `end` INT NOT NULL"); + + $applied = true; +} + +if(sql_num_query("DESCRIBE `Shifts` `Man`") === 1 && sql_num_query("DESCRIBE `Shifts` `name`") === 0) { + sql_query("ALTER TABLE `Shifts` CHANGE `Man` `name` VARCHAR(1024) NULL"); + + $applied = true; +} + +$res = sql_select("DESCRIBE `Shifts` `PSID`"); +if($res[0]['Type'] == 'text') { + sql_query("ALTER TABLE `Shifts` CHANGE `PSID` `PSID` INT NULL"); + + $applied = true; +} +_add_index("Shifts", array("PSID"), "UNIQUE"); +_add_index("Shifts", array("RID")); +?> |