summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/install.sql4
-rw-r--r--db/update.d/15_UserAngelTypes.php17
2 files changed, 19 insertions, 2 deletions
diff --git a/db/install.sql b/db/install.sql
index 77c1c559..97103f51 100644
--- a/db/install.sql
+++ b/db/install.sql
@@ -1173,10 +1173,10 @@ CREATE TABLE IF NOT EXISTS `Wecken` (
-- Tabellenstruktur für Tabelle `UserAngelTypes`
--
-CREATE TABLE `engelsystem`.`UserAngelTypes` (
+CREATE TABLE IF NOT EXISTS `UserAngelTypes` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`user_id` INT NOT NULL ,
`angeltype_id` INT NOT NULL ,
`confirm_user_id` INT NULL ,
INDEX ( `user_id` , `angeltype_id` , `confirm_user_id` )
-) ENGINE = MYISAM ;
+) ENGINE = MYISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
diff --git a/db/update.d/15_UserAngelTypes.php b/db/update.d/15_UserAngelTypes.php
new file mode 100644
index 00000000..81a13f4e
--- /dev/null
+++ b/db/update.d/15_UserAngelTypes.php
@@ -0,0 +1,17 @@
+<?php
+if(sql_num_query("SHOW TABLES LIKE 'UserAngelTypes'") === 0) {
+ sql_query("CREATE TABLE `UserAngelTypes` (
+ `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
+ `user_id` INT NOT NULL ,
+ `angeltype_id` INT NOT NULL ,
+ `confirm_user_id` INT NULL ,
+ INDEX ( `user_id` , `angeltype_id` , `confirm_user_id` )
+ )");
+ sql_query("INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`)
+ SELECT `User`.`UID`, `AngelTypes`.`id`
+ FROM `User`
+ INNER JOIN `AngelTypes`
+ ON TRIM(TRAILING 'Angel' FROM `User`.`Art`) = `AngelTypes`.`name`");
+
+ $applied = true;
+}