summaryrefslogtreecommitdiff
path: root/db/update.sql
diff options
context:
space:
mode:
Diffstat (limited to 'db/update.sql')
-rw-r--r--db/update.sql39
1 files changed, 36 insertions, 3 deletions
diff --git a/db/update.sql b/db/update.sql
index 681d2a7c..3dbd613a 100644
--- a/db/update.sql
+++ b/db/update.sql
@@ -1,3 +1,36 @@
+/* more shift infos */
+ALTER TABLE `Shifts` ADD `created_by_user_id` INT NOT NULL ,
+ADD `created_at_timestamp` INT NOT NULL ,
+ADD `edited_by_user_id` INT NOT NULL ,
+ADD `edited_at_timestamp` INT NOT NULL;
+ALTER TABLE `Shifts` ADD INDEX ( `created_by_user_id` );
+ALTER TABLE `Shifts` ADD INDEX ( `edited_by_user_id` );
+ALTER TABLE `Shifts` CHANGE `created_by_user_id` `created_by_user_id` INT( 11 ) NULL ;
+ALTER TABLE `Shifts` CHANGE `edited_by_user_id` `edited_by_user_id` INT( 11 ) NULL ;
+update Shifts set created_by_user_id=null, edited_by_user_id=null;
+ALTER TABLE `Shifts` ADD FOREIGN KEY ( `created_by_user_id` ) REFERENCES `engelsystem`.`User` (`UID`) ON DELETE SET NULL ON UPDATE CASCADE ;
+ALTER TABLE `Shifts` ADD FOREIGN KEY ( `edited_by_user_id` ) REFERENCES `engelsystem`.`User` (`UID`) ON DELETE SET NULL ON UPDATE CASCADE ;
+
+/* Introduce planned departure date */
+ALTER TABLE `User` ADD `planned_departure_date` INT NULL, ADD INDEX ( `planned_departure_date` );
+
+/* Allow longer angeltype names */
+ALTER TABLE `AngelTypes` CHANGE `name` `name` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '';
+
+/* Enable multiple vouchers */
+ALTER TABLE `User` CHANGE `got_voucher` `got_voucher` INT NOT NULL;
+
+/* introduce user arrival date */
+ALTER TABLE `User` ADD `arrival_date` INT NULL ,
+ADD `planned_arrival_date` INT NOT NULL ,
+ADD INDEX ( `arrival_date` , `planned_arrival_date` ) ;
+
+/* fix log */
+ALTER TABLE `LogEntries` CHANGE `nick` `nick` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ;
+
+/* introduce got-voucher flag */
+ALTER TABLE `User` ADD `got_voucher` BOOLEAN NOT NULL;
+
/* introduce shift types */
CREATE TABLE IF NOT EXISTS `ShiftTypes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
@@ -7,8 +40,8 @@ CREATE TABLE IF NOT EXISTS `ShiftTypes` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
ALTER TABLE `ShiftTypes` ADD INDEX ( `angeltype_id` );
-ALTER TABLE `ShiftTypes` ADD FOREIGN KEY ( `angeltype_id` ) REFERENCES `engelsystem`.`AngelTypes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-INSERT INTO `engelsystem`.`Privileges` (`id`, `name`, `desc`) VALUES (NULL , 'shifttypes', 'Administrate shift types');
+ALTER TABLE `ShiftTypes` ADD FOREIGN KEY ( `angeltype_id` ) REFERENCES `AngelTypes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
+INSERT INTO `Privileges` (`id`, `name`, `desc`) VALUES (NULL , 'shifttypes', 'Administrate shift types');
INSERT INTO `GroupPrivileges` SET `group_id`=-5, `privilege_id`=(SELECT `id` FROM `Privileges` WHERE `name`='shifttypes');
ALTER TABLE `Shifts` ADD `shifttype_id` INT NOT NULL AFTER `SID`, ADD INDEX ( `shifttype_id` );
@@ -16,7 +49,7 @@ UPDATE `Shifts` SET `name`='' WHERE `name` IS NULL;
INSERT INTO `ShiftTypes` SELECT DISTINCT NULL , `name` , NULL , '' FROM `Shifts`;
UPDATE `Shifts` SET `shifttype_id`=(SELECT `id` FROM `ShiftTypes` WHERE `ShiftTypes`.`name`=`Shifts`.`name`);
ALTER TABLE `Shifts` ADD `title` TEXT NULL AFTER `SID`;
-ALTER TABLE `Shifts` ADD FOREIGN KEY ( `shifttype_id` ) REFERENCES `engelsystem`.`ShiftTypes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
+ALTER TABLE `Shifts` ADD FOREIGN KEY ( `shifttype_id` ) REFERENCES `ShiftTypes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `Shifts` DROP `name`;
/* cleanup */