From 66c60d5d76cd80ada078ecaa94ba7a827690d8a6 Mon Sep 17 00:00:00 2001 From: mutec Date: Thu, 3 Aug 2017 23:00:07 +0200 Subject: [PATCH] SQL upgrade routine --- install.sql | 58 ++++++++++++++++----------------------------------- update.sql | 6 ------ update126.sql | 6 ++++++ 3 files changed, 24 insertions(+), 46 deletions(-) delete mode 100644 update.sql create mode 100644 update126.sql diff --git a/install.sql b/install.sql index 3e93c1c..bcbea73 100644 --- a/install.sql +++ b/install.sql @@ -9,8 +9,8 @@ CREATE TABLE wcf1_todo ( username VARCHAR(255) NOT NULL DEFAULT '', time INT(10) NOT NULL DEFAULT 0, endTime INT(10) NOT NULL DEFAULT 0, - private INT(1) NOT NULL DEFAULT 0, - comments INT(1) NOT NULL DEFAULT 1, + private TINYINT(1) NOT NULL DEFAULT 0, -- update + comments INT(1) NOT NULL DEFAULT 0, -- update important INT(1) NOT NULL DEFAULT 0, categoryID INT(10), updatetimestamp INT(10) NOT NULL DEFAULT 0, @@ -26,12 +26,12 @@ CREATE TABLE wcf1_todo ( cumulativeLikes MEDIUMINT(7) NOT NULL DEFAULT 0, attachments MEDIUMINT(7) NOT NULL DEFAULT 0, hasEmbeddedObjects TINYINT(1) NOT NULL DEFAULT 0, - notesHasEmbeddedObjects TINYINT(1) NOT NULL DEFAULT 0, + notesHasEmbeddedObjects TINYINT(1) NOT NULL DEFAULT 0, -- create ipAddress VARCHAR(39) NOT NULL DEFAULT '', -- 170404 hasLabels TINYINT(1) NOT NULL DEFAULT 0, - enableHtml TINYINT(1) NOT NULL DEFAULT 0, + enableHtml TINYINT(1) NOT NULL DEFAULT 0, -- update PRIMARY KEY (todoID) ); @@ -65,44 +65,22 @@ CREATE TABLE wcf1_todo_to_group ( PRIMARY KEY (assignID) ); -INSERT INTO wcf1_todo_status (statusID, subject, showOrder, cssClass, locked) -VALUES (1, 'abgeschlossen/solved', 99, 'green', 1); +INSERT INTO wcf1_todo_status (statusID, subject, showOrder, cssClass, locked) VALUES (1, 'abgeschlossen/solved', 99, 'green', 1); INSERT INTO wcf1_todo_status (statusID, subject, showOrder, cssClass, locked) VALUES (2, 'offen/unsolved', 2, 'red', 0); -INSERT INTO wcf1_todo_status (statusID, subject, showOrder, cssClass, locked) -VALUES (3, 'in Arbeit/in progress', 3, 'yellow', 0); -INSERT INTO wcf1_todo_status (statusID, subject, showOrder, cssClass, locked) -VALUES (4, 'verworfen/canceled', 98, 'gray', 0); -INSERT INTO wcf1_todo_status (statusID, subject, showOrder, cssClass, locked) -VALUES (5, 'in Vorbereitung/in preparation', 1, 'gray', 0); -INSERT INTO wcf1_todo_status (statusID, subject, showOrder, cssClass, locked) -VALUES (6, 'pausiert/paused', 4, 'gray', 0); +INSERT INTO wcf1_todo_status (statusID, subject, showOrder, cssClass, locked) VALUES (3, 'in Arbeit/in progress', 3, 'yellow', 0); +INSERT INTO wcf1_todo_status (statusID, subject, showOrder, cssClass, locked) VALUES (4, 'verworfen/canceled', 98, 'gray', 0); +INSERT INTO wcf1_todo_status (statusID, subject, showOrder, cssClass, locked) VALUES (5, 'in Vorbereitung/in preparation', 1, 'gray', 0); +INSERT INTO wcf1_todo_status (statusID, subject, showOrder, cssClass, locked) VALUES (6, 'pausiert/paused', 4, 'gray', 0); -ALTER TABLE wcf1_user - ADD todos INT(10) NOT NULL DEFAULT 0; +ALTER TABLE wcf1_user ADD todos INT(10) NOT NULL DEFAULT 0; -ALTER TABLE wcf1_todo - ADD FOREIGN KEY (submitter) REFERENCES wcf1_user (userID) - ON DELETE SET NULL; -ALTER TABLE wcf1_todo - ADD FOREIGN KEY (deletedByID) REFERENCES wcf1_user (userID) - ON DELETE SET NULL; -ALTER TABLE wcf1_todo - ADD FOREIGN KEY (statusID) REFERENCES wcf1_todo_status (statusID) - ON DELETE SET NULL; -ALTER TABLE wcf1_todo - ADD FOREIGN KEY (categoryID) REFERENCES wcf1_category (categoryID) - ON DELETE CASCADE; +ALTER TABLE wcf1_todo ADD FOREIGN KEY (submitter) REFERENCES wcf1_user (userID) ON DELETE SET NULL; +ALTER TABLE wcf1_todo ADD FOREIGN KEY (deletedByID) REFERENCES wcf1_user (userID) ON DELETE SET NULL; +ALTER TABLE wcf1_todo ADD FOREIGN KEY (statusID) REFERENCES wcf1_todo_status (statusID) ON DELETE SET NULL; +ALTER TABLE wcf1_todo ADD FOREIGN KEY (categoryID) REFERENCES wcf1_category (categoryID) ON DELETE CASCADE; -ALTER TABLE wcf1_todo_to_user - ADD FOREIGN KEY (userID) REFERENCES wcf1_user (userID) - ON DELETE CASCADE; -ALTER TABLE wcf1_todo_to_user - ADD FOREIGN KEY (todoID) REFERENCES wcf1_todo (todoID) - ON DELETE CASCADE; +ALTER TABLE wcf1_todo_to_user ADD FOREIGN KEY (userID) REFERENCES wcf1_user (userID) ON DELETE CASCADE; +ALTER TABLE wcf1_todo_to_user ADD FOREIGN KEY (todoID) REFERENCES wcf1_todo (todoID) ON DELETE CASCADE; -ALTER TABLE wcf1_todo_to_group - ADD FOREIGN KEY (groupID) REFERENCES wcf1_user_group (groupID) - ON DELETE CASCADE; -ALTER TABLE wcf1_todo_to_group - ADD FOREIGN KEY (todoID) REFERENCES wcf1_todo (todoID) - ON DELETE CASCADE; +ALTER TABLE wcf1_todo_to_group ADD FOREIGN KEY (groupID) REFERENCES wcf1_user_group (groupID) ON DELETE CASCADE; +ALTER TABLE wcf1_todo_to_group ADD FOREIGN KEY (todoID) REFERENCES wcf1_todo (todoID) ON DELETE CASCADE; diff --git a/update.sql b/update.sql deleted file mode 100644 index d507b36..0000000 --- a/update.sql +++ /dev/null @@ -1,6 +0,0 @@ -ALTER TABLE wcf1_todo CHANGE timestamp time INT(10) NOT NULL DEFAULT 0; -ALTER TABLE wcf1_todo ADD COLUMN notesHasEmbeddedObjects TINYINT(1) NOT NULL DEFAULT 0; - --- 170404 (done by 2.0.0 Beta 2) -ALTER TABLE wcf1_todo ADD COLUMN hasLabels TINYINT(1) NOT NULL DEFAULT 0; -ALTER TABLE wcf1_todo ADD COLUMN enableHtml TINYINT(1) NOT NULL DEFAULT 0; diff --git a/update126.sql b/update126.sql new file mode 100644 index 0000000..63ff1ab --- /dev/null +++ b/update126.sql @@ -0,0 +1,6 @@ +-- 1.2.6 (pl 1) +ALTER TABLE wcf1_todo CHANGE timestamp time INT(10) NOT NULL DEFAULT 0; +ALTER TABLE wcf1_todo ADD COLUMN notesHasEmbeddedObjects TINYINT(1) NOT NULL DEFAULT 0; +ALTER TABLE wcf1_todo CHANGE private private TINYINT(1) NOT NULL DEFAULT 0; +ALTER TABLE wcf1_todo CHANGE comments comments INT(10) NOT NULL DEFAULT 0; +ALTER TABLE wcf1_todo CHANGE enableHtml enableHtml TINYINT(1) NOT NULL DEFAULT 0;