fixed various bug in DB update scripts
This commit is contained in:
parent
60810251e5
commit
e90e6085df
|
@ -7,7 +7,8 @@ if(sql_num_query("DESCRIBE `FAQ` `Sprache`") === 0) {
|
|||
while($row = mysql_fetch_assoc($res)) {
|
||||
$question = explode('<br>', $row['Frage'], 2);
|
||||
$answer = explode('<br>', $row['Antwort'], 2);
|
||||
sql_query("INSERT INTO `FAQ` (`Frage`, `Antwort`, `Sprache`) VALUES ('" . sql_escape(trim($question[1])) . "', '" . sql_escape(trim($answer[1])) . "', 'en')");
|
||||
if(count($question) == 2 && count($answer) == 2)
|
||||
sql_query("INSERT INTO `FAQ` (`Frage`, `Antwort`, `Sprache`) VALUES ('" . sql_escape(trim($question[1])) . "', '" . sql_escape(trim($answer[1])) . "', 'en')");
|
||||
sql_query("UPDATE `FAQ` SET `Frage` = '" . sql_escape(trim($question[0])) . "', `Antwort` = '" . sql_escape(trim($answer[0])) . "', `Sprache` = 'de' WHERE `FID` = " . $row['FID']);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ if(sql_num_query("SHOW COLUMNS FROM `Shifts` LIKE 'Date_'") == 2) {
|
|||
sql_query("ALTER TABLE `Shifts` DROP `Len`");
|
||||
}
|
||||
}
|
||||
_datetime_to_int("Shifts", "DateS");
|
||||
_datetime_to_int("Shifts", "DateE");
|
||||
sql_query("ALTER TABLE `Shifts` CHANGE `DateS` `start` INT NOT NULL, CHANGE `DateE` `end` INT NOT NULL");
|
||||
|
||||
$applied = true;
|
||||
|
|
|
@ -29,5 +29,24 @@ if(sql_num_query("SHOW TABLES LIKE 'NeededAngelTypes'") === 0) {
|
|||
|
||||
$applied = true;
|
||||
}
|
||||
|
||||
if(sql_num_query("SELECT * FROM `ShiftEntry` WHERE `UID` = 0")) {
|
||||
$data = sql_query("
|
||||
INSERT INTO `NeededAngelTypes` (`shift_id`, `angel_type_id`, `count`)
|
||||
SELECT se.`SID`, se.`TID`, se.`count` FROM (
|
||||
SELECT `SID`, `TID`, COUNT(`TID`) AS `count`
|
||||
FROM `ShiftEntry`
|
||||
GROUP BY `SID`, `TID`
|
||||
) AS se
|
||||
INNER JOIN `Shifts` AS s ON s.`SID` = se.`SID`
|
||||
INNER JOIN `Room` AS r ON s.`RID` = r.`RID`
|
||||
LEFT JOIN `NeededAngelTypes` AS nat ON (nat.`room_id` = r.`RID` AND nat.`angel_type_id` = se.`TID`)
|
||||
WHERE nat.`count` IS NULL OR nat.`count` != se.`count`
|
||||
");
|
||||
|
||||
sql_query("DELETE FROM `ShiftEntry` WHERE `UID` = 0 AND `Comment` IS NULL");
|
||||
|
||||
$applied = true;
|
||||
}
|
||||
_add_index("Room", array("Name"));
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue