From 524e36143986381bf98236d41642838b7c5226b4 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 14 Sep 2015 18:18:52 +0200 Subject: [PATCH] add constraint tblUsers_homefolder after creating tblFolders set homefolder to NULL when creating initial users --- install/create_tables-innodb.sql | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/install/create_tables-innodb.sql b/install/create_tables-innodb.sql index 57d8f248e..26e923ef3 100644 --- a/install/create_tables-innodb.sql +++ b/install/create_tables-innodb.sql @@ -67,8 +67,7 @@ CREATE TABLE `tblUsers` ( `quota` bigint, `homefolder` int(11) default NULL, PRIMARY KEY (`id`), - UNIQUE (`login`), - CONSTRAINT `tblUsers_homefolder` FOREIGN KEY (`homefolder`) REFERENCES `tblFolders` (`id`) + UNIQUE (`login`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -138,6 +137,8 @@ CREATE TABLE `tblFolders` ( CONSTRAINT `tblFolders_owner` FOREIGN KEY (`owner`) REFERENCES `tblUsers` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +ALTER TABLE tblUsers ADD CONSTRAINT `tblUsers_homefolder` FOREIGN KEY (`homefolder`) REFERENCES `tblFolders` (`id`); + -- -------------------------------------------------------- -- @@ -710,8 +711,8 @@ CREATE TABLE `tblVersion` ( -- Initial content for database -- -INSERT INTO tblUsers VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 'Administrator', 'address@server.com', '', '', '', 1, 0, '0000-00-00 00:00:00', 0, 0, 0, 0); -INSERT INTO tblUsers VALUES (2, 'guest', NULL, 'Guest User', NULL, '', '', '', 2, 0, '0000-00-00 00:00:00', 0, 0, 0, 0); +INSERT INTO tblUsers VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 'Administrator', 'address@server.com', '', '', '', 1, 0, '0000-00-00 00:00:00', 0, 0, 0, NULL); +INSERT INTO tblUsers VALUES (2, 'guest', NULL, 'Guest User', NULL, '', '', '', 2, 0, '0000-00-00 00:00:00', 0, 0, 0, NULL); INSERT INTO tblFolders VALUES (1, 'DMS', 0, '', 'DMS root', UNIX_TIMESTAMP(), 1, 0, 2, 0); INSERT INTO tblVersion VALUES (NOW(), 5, 0, 0); INSERT INTO tblCategory VALUES (0, '');