From 7c6d0f1f6b09a5acbf80d26404ac0d4390026da9 Mon Sep 17 00:00:00 2001 From: Tim Repke <timmothey@gmx.de> Date: Fri, 14 Oct 2016 00:54:46 +0200 Subject: [PATCH] SQL Script to remove waitlist this script moves and converts all entries in the waitlist table into the bachelor table and then deletes the deprecated waitlist table --- .../other/sqlDumps/update_20161013.sql | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 registration-system/other/sqlDumps/update_20161013.sql diff --git a/registration-system/other/sqlDumps/update_20161013.sql b/registration-system/other/sqlDumps/update_20161013.sql new file mode 100644 index 0000000..fb141e2 --- /dev/null +++ b/registration-system/other/sqlDumps/update_20161013.sql @@ -0,0 +1,33 @@ +-- this update merges the waitlist table with the bachelor table + +-- first add necessary columns to the bachelor table +ALTER TABLE `bachelor` + ADD `on_waitlist` int(11) NOT NULL DEFAULT 0, + ADD `transferred` int(11) DEFAULT NULL; + +-- first move those, that are not transferred yet +INSERT INTO `bachelor` +(`bachelor_id`, `fahrt_id`, `anm_time`, `forname`, `sirname`, + `anday`, `abday`, `antyp`,`abtyp`, `pseudo`, + `mehl`, `essen`,`public`, `virgin`, `studityp`, `comment`, + `transferred`, `on_waitlist`, `version`, + `paid`, `repaid`, `backstepped`) + SELECT `waitlist_id` AS `bachelor_id`, + `fahrt_id`, `anm_time`, `forname`, `sirname`, + `anday`, `abday`, `antyp`,`abtyp`, `pseudo`, + `mehl`, `essen`,`public`, `virgin`, `studityp`, `comment`, + NULL AS `transferred`, 1 AS `on_waitlist`, 0 AS `version`, + NULL AS `paid`, NULL AS `repaid`, NULL AS `backstepped` + FROM `waitlist` WHERE `transferred` IS NULL; + +-- now update those, that were transferred already +UPDATE `bachelor` AS b, `waitlist` AS wl +SET + b.`transferred`=wl.`transferred`, + b.`on_waitlist`=1 +WHERE + wl.`waitlist_id` = b.`bachelor_id` AND + wl.`fahrt_id` = b.`fahrt_id`; + +-- remove deprecated waitlist table +DROP TABLE IF EXISTS `waitlist`; \ No newline at end of file -- GitLab