diff --git a/logauth.sql b/logauth.sql index 4d09902..d78106c 100644 --- a/logauth.sql +++ b/logauth.sql @@ -3,7 +3,7 @@ -- http://www.phpmyadmin.net -- -- Host: localhost --- Generation Time: Sep 23, 2017 at 07:46 PM +-- Generation Time: Sep 24, 2017 at 07:44 PM -- Server version: 5.7.19-0ubuntu0.16.04.1 -- PHP Version: 7.0.22-0ubuntu0.16.04.1 @@ -28,11 +28,12 @@ USE `logauth`; -- Table structure for table `action` -- +DROP TABLE IF EXISTS `action`; CREATE TABLE `action` ( `id_action` int(11) NOT NULL, `name` varchar(30) COLLATE utf8_unicode_ci NOT NULL, `timeout` int(11) NOT NULL, - `previous` varchar(20) COLLATE utf8_unicode_ci NOT NULL COMMENT 'started | signaled | locked', + `required` varchar(20) COLLATE utf8_unicode_ci NOT NULL COMMENT 'started | signaled | locked', `action` varchar(20) COLLATE utf8_unicode_ci NOT NULL COMMENT 'start | signal | lock' ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -40,10 +41,10 @@ CREATE TABLE `action` ( -- Dumping data for table `action` -- -INSERT INTO `action` (`id_action`, `name`, `timeout`, `previous`, `action`) VALUES +INSERT INTO `action` (`id_action`, `name`, `timeout`, `required`, `action`) VALUES (1, 'Start', 0, '0X0', '1XX'), -(2, 'Signal', 1, 'XX0', '11X'), -(3, 'Lock', 2, 'XX0', '001'), +(2, 'Signal', 3, 'XX0', '11X'), +(3, 'Lock', 5, 'XX0', '001'), (4, 'Unlock', 0, 'XX1', '000'), (5, 'Stop', 0, '1X0', '0XX'), (6, 'Unsignal', 0, 'X10', 'X00'); @@ -54,6 +55,7 @@ INSERT INTO `action` (`id_action`, `name`, `timeout`, `previous`, `action`) VALU -- Table structure for table `action_merge` -- +DROP TABLE IF EXISTS `action_merge`; CREATE TABLE `action_merge` ( `id_action_merge` int(11) NOT NULL, `id_target` int(11) NOT NULL, @@ -97,6 +99,7 @@ INSERT INTO `action_merge` (`id_action_merge`, `id_target`, `id_source`, `id_act -- Table structure for table `admin` -- +DROP TABLE IF EXISTS `admin`; CREATE TABLE `admin` ( `id_admin` int(11) NOT NULL, `id_warehouse` int(11) NOT NULL, @@ -120,21 +123,44 @@ INSERT INTO `admin` (`id_admin`, `id_warehouse`, `username`, `mail`, `password`, -- Table structure for table `chip` -- +DROP TABLE IF EXISTS `chip`; CREATE TABLE `chip` ( `id_chip` int(11) NOT NULL, - `id_module` int(11) DEFAULT NULL, + `id_module` int(11) DEFAULT NULL COMMENT 'in global_state', `name` varchar(20) COLLATE utf8_unicode_ci NOT NULL, `position` int(11) NOT NULL, - `type` varchar(10) COLLATE utf8_unicode_ci NOT NULL + `type` varchar(10) COLLATE utf8_unicode_ci NOT NULL, + `pins` text COLLATE utf8_unicode_ci NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data for table `chip` -- -INSERT INTO `chip` (`id_chip`, `id_module`, `name`, `position`, `type`) VALUES -(1, 1, 'led1', 0, 'SERIAL'), -(2, 1, 'relay1', 1, 'SERIAL'); +INSERT INTO `chip` (`id_chip`, `id_module`, `name`, `position`, `type`, `pins`) VALUES +(1, 1, 'led1', 0, 'digital', '4,17,27'), +(2, 1, 'relay1', 1, 'digital', '21'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `etree` +-- + +DROP TABLE IF EXISTS `etree`; +CREATE TABLE `etree` ( + `id_etree` int(11) NOT NULL, + `id_module` int(11) NOT NULL, + `daemon` varchar(30) COLLATE latin1_bin NOT NULL, + `launcher` varchar(50) COLLATE latin1_bin DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin; + +-- +-- Dumping data for table `etree` +-- + +INSERT INTO `etree` (`id_etree`, `id_module`, `daemon`, `launcher`) VALUES +(1, 1, 'mfrc522', NULL); -- -------------------------------------------------------- @@ -142,6 +168,7 @@ INSERT INTO `chip` (`id_chip`, `id_module`, `name`, `position`, `type`) VALUES -- Table structure for table `global_state` -- +DROP TABLE IF EXISTS `global_state`; CREATE TABLE `global_state` ( `id_global_state` int(11) NOT NULL, `global_state` varchar(20) COLLATE utf8_unicode_ci NOT NULL COMMENT 'started | signaled | locked', @@ -164,6 +191,7 @@ INSERT INTO `global_state` (`id_global_state`, `global_state`, `chips`) VALUES -- Table structure for table `history` -- +DROP TABLE IF EXISTS `history`; CREATE TABLE `history` ( `id_history` int(11) NOT NULL, `timestamp` int(11) NOT NULL, @@ -202,6 +230,7 @@ INSERT INTO `history` (`id_history`, `timestamp`, `id_user`, `id_machine`, `id_a -- Table structure for table `log` -- +DROP TABLE IF EXISTS `log`; CREATE TABLE `log` ( `id_log` int(11) NOT NULL, `id_feature` int(11) NOT NULL, @@ -216,6 +245,7 @@ CREATE TABLE `log` ( -- Table structure for table `machine` -- +DROP TABLE IF EXISTS `machine`; CREATE TABLE `machine` ( `id_machine` int(11) NOT NULL, `id_warehouse` int(11) NOT NULL, @@ -355,6 +385,7 @@ INSERT INTO `machine` (`id_machine`, `id_warehouse`, `name`, `token`, `unlock_co -- Table structure for table `machine_cluster` -- +DROP TABLE IF EXISTS `machine_cluster`; CREATE TABLE `machine_cluster` ( `id_machine_cluster` int(11) NOT NULL, `id_warehouse` int(11) NOT NULL, @@ -378,6 +409,7 @@ INSERT INTO `machine_cluster` (`id_machine_cluster`, `id_warehouse`, `name`) VAL -- Table structure for table `machine_cluster_merge` -- +DROP TABLE IF EXISTS `machine_cluster_merge`; CREATE TABLE `machine_cluster_merge` ( `id_machine_cluster_merge` int(11) NOT NULL, `id_machine_cluster` int(11) NOT NULL, @@ -392,7 +424,15 @@ INSERT INTO `machine_cluster_merge` (`id_machine_cluster_merge`, `id_machine_clu (3, 1, 58), (4, 2, 75), (5, 3, 6), -(6, 2, 58); +(6, 2, 58), +(9, 4, 122), +(10, 4, 123), +(11, 4, 124), +(12, 4, 125), +(13, 5, 126), +(14, 5, 127), +(15, 5, 128), +(16, 5, 129); -- -------------------------------------------------------- @@ -400,6 +440,7 @@ INSERT INTO `machine_cluster_merge` (`id_machine_cluster_merge`, `id_machine_clu -- Table structure for table `module` -- +DROP TABLE IF EXISTS `module`; CREATE TABLE `module` ( `id_module` int(11) NOT NULL, `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL @@ -410,9 +451,9 @@ CREATE TABLE `module` ( -- INSERT INTO `module` (`id_module`, `name`) VALUES -(1, 'motheure'), -(2, 'portail'), -(3, 'upload'); +(1, 'rfid'), +(2, 'motheure'), +(3, 'portail'); -- -------------------------------------------------------- @@ -420,6 +461,7 @@ INSERT INTO `module` (`id_module`, `name`) VALUES -- Table structure for table `module_availability` -- +DROP TABLE IF EXISTS `module_availability`; CREATE TABLE `module_availability` ( `id_warehouse` int(11) NOT NULL, `id_module` int(11) NOT NULL @@ -441,6 +483,7 @@ INSERT INTO `module_availability` (`id_warehouse`, `id_module`) VALUES -- Table structure for table `module_merge` -- +DROP TABLE IF EXISTS `module_merge`; CREATE TABLE `module_merge` ( `id_module_merge` int(11) NOT NULL, `id_machine_cluster` int(11) NOT NULL, @@ -448,28 +491,13 @@ CREATE TABLE `module_merge` ( `id_warehouse` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; --- -------------------------------------------------------- - -- --- Table structure for table `pin_merge` +-- Dumping data for table `module_merge` -- -CREATE TABLE `pin_merge` ( - `id_pin_merge` int(11) NOT NULL, - `id_chip` int(11) NOT NULL, - `pin` int(11) NOT NULL, - `type` varchar(20) COLLATE utf8_unicode_ci NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - --- --- Dumping data for table `pin_merge` --- - -INSERT INTO `pin_merge` (`id_pin_merge`, `id_chip`, `pin`, `type`) VALUES -(1, 1, 4, 'SERIAL'), -(2, 1, 17, 'SERIAL'), -(3, 1, 27, 'SERIAL'), -(4, 2, 21, 'SERIAL'); +INSERT INTO `module_merge` (`id_module_merge`, `id_machine_cluster`, `id_module`, `id_warehouse`) VALUES +(1, 4, 1, 8), +(2, 5, 1, 8); -- -------------------------------------------------------- @@ -477,32 +505,25 @@ INSERT INTO `pin_merge` (`id_pin_merge`, `id_chip`, `pin`, `type`) VALUES -- Table structure for table `state` -- +DROP TABLE IF EXISTS `state`; CREATE TABLE `state` ( `id_state` int(11) NOT NULL, - `id_pin_merge` int(11) NOT NULL, + `id_chip` int(11) NOT NULL, `state` varchar(1) COLLATE utf8_unicode_ci NOT NULL, - `value` smallint(4) NOT NULL + `value` text COLLATE utf8_unicode_ci NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data for table `state` -- -INSERT INTO `state` (`id_state`, `id_pin_merge`, `state`, `value`) VALUES -(1, 1, '0', 1), -(2, 2, '0', 1), -(3, 3, '0', 1), -(4, 1, 'G', 1), -(5, 2, 'G', 0), -(6, 3, 'G', 1), -(7, 1, 'B', 1), -(8, 2, 'B', 1), -(9, 3, 'B', 0), -(10, 1, 'R', 0), -(11, 2, 'R', 1), -(12, 3, 'R', 1), -(13, 4, '0', 0), -(14, 4, '1', 1); +INSERT INTO `state` (`id_state`, `id_chip`, `state`, `value`) VALUES +(15, 1, '0', '1,1,1'), +(16, 1, 'R', '0,1,1'), +(17, 1, 'G', '1,0,1'), +(18, 1, 'B', '1,1,0'), +(19, 2, '0', '0'), +(20, 2, '1', '1'); -- -------------------------------------------------------- @@ -510,6 +531,7 @@ INSERT INTO `state` (`id_state`, `id_pin_merge`, `state`, `value`) VALUES -- Table structure for table `user` -- +DROP TABLE IF EXISTS `user`; CREATE TABLE `user` ( `id_user` int(11) NOT NULL, `id_warehouse` int(11) NOT NULL, @@ -623,6 +645,7 @@ INSERT INTO `user` (`id_user`, `id_warehouse`, `code`, `username`, `firstname`, -- Table structure for table `user_cluster` -- +DROP TABLE IF EXISTS `user_cluster`; CREATE TABLE `user_cluster` ( `id_user_cluster` int(11) NOT NULL, `id_warehouse` int(11) NOT NULL, @@ -646,6 +669,7 @@ INSERT INTO `user_cluster` (`id_user_cluster`, `id_warehouse`, `name`) VALUES -- Table structure for table `user_cluster_merge` -- +DROP TABLE IF EXISTS `user_cluster_merge`; CREATE TABLE `user_cluster_merge` ( `id_user_cluster_merge` int(11) NOT NULL, `id_user_cluster` int(11) NOT NULL, @@ -677,6 +701,7 @@ INSERT INTO `user_cluster_merge` (`id_user_cluster_merge`, `id_user_cluster`, `i -- Table structure for table `warehouse` -- +DROP TABLE IF EXISTS `warehouse`; CREATE TABLE `warehouse` ( `id_warehouse` int(11) NOT NULL, `name` varchar(30) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, @@ -726,6 +751,13 @@ ALTER TABLE `chip` ADD PRIMARY KEY (`id_chip`), ADD KEY `id_module` (`id_module`); +-- +-- Indexes for table `etree` +-- +ALTER TABLE `etree` + ADD PRIMARY KEY (`id_etree`), + ADD KEY `id_module` (`id_module`); + -- -- Indexes for table `global_state` -- @@ -794,19 +826,12 @@ ALTER TABLE `module_merge` ADD KEY `id_machine` (`id_module`), ADD KEY `id_warehouse` (`id_warehouse`); --- --- Indexes for table `pin_merge` --- -ALTER TABLE `pin_merge` - ADD PRIMARY KEY (`id_pin_merge`), - ADD KEY `id_chip` (`id_chip`); - -- -- Indexes for table `state` -- ALTER TABLE `state` ADD PRIMARY KEY (`id_state`), - ADD KEY `id_pin_merge` (`id_pin_merge`); + ADD KEY `id_pin_merge` (`id_chip`); -- -- Indexes for table `user` @@ -861,6 +886,11 @@ ALTER TABLE `admin` ALTER TABLE `chip` MODIFY `id_chip` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- +-- AUTO_INCREMENT for table `etree` +-- +ALTER TABLE `etree` + MODIFY `id_etree` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; +-- -- AUTO_INCREMENT for table `global_state` -- ALTER TABLE `global_state` @@ -889,7 +919,7 @@ ALTER TABLE `machine_cluster` -- AUTO_INCREMENT for table `machine_cluster_merge` -- ALTER TABLE `machine_cluster_merge` - MODIFY `id_machine_cluster_merge` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; + MODIFY `id_machine_cluster_merge` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17; -- -- AUTO_INCREMENT for table `module` -- @@ -899,17 +929,12 @@ ALTER TABLE `module` -- AUTO_INCREMENT for table `module_merge` -- ALTER TABLE `module_merge` - MODIFY `id_module_merge` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=59; --- --- AUTO_INCREMENT for table `pin_merge` --- -ALTER TABLE `pin_merge` - MODIFY `id_pin_merge` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; + MODIFY `id_module_merge` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `state` -- ALTER TABLE `state` - MODIFY `id_state` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15; + MODIFY `id_state` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21; -- -- AUTO_INCREMENT for table `user` -- @@ -924,7 +949,7 @@ ALTER TABLE `user_cluster` -- AUTO_INCREMENT for table `user_cluster_merge` -- ALTER TABLE `user_cluster_merge` - MODIFY `id_user_cluster_merge` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=89; + MODIFY `id_user_cluster_merge` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=88; -- -- AUTO_INCREMENT for table `warehouse` -- @@ -954,6 +979,12 @@ ALTER TABLE `admin` ALTER TABLE `chip` ADD CONSTRAINT `chip_id_module` FOREIGN KEY (`id_module`) REFERENCES `module` (`id_module`) ON DELETE CASCADE ON UPDATE CASCADE; +-- +-- Constraints for table `etree` +-- +ALTER TABLE `etree` + ADD CONSTRAINT `fk_etree_id_module` FOREIGN KEY (`id_module`) REFERENCES `module` (`id_module`) ON DELETE CASCADE ON UPDATE CASCADE; + -- -- Constraints for table `history` -- @@ -1003,17 +1034,11 @@ ALTER TABLE `module_merge` ADD CONSTRAINT `fk_module_merge_id_module` FOREIGN KEY (`id_module`) REFERENCES `module` (`id_module`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `fk_module_merge_id_warehouse` FOREIGN KEY (`id_warehouse`) REFERENCES `warehouse` (`id_warehouse`) ON DELETE CASCADE ON UPDATE CASCADE; --- --- Constraints for table `pin_merge` --- -ALTER TABLE `pin_merge` - ADD CONSTRAINT `pin_id_chip` FOREIGN KEY (`id_chip`) REFERENCES `chip` (`id_chip`) ON DELETE CASCADE ON UPDATE CASCADE; - -- -- Constraints for table `state` -- ALTER TABLE `state` - ADD CONSTRAINT `state_id_pin_merge` FOREIGN KEY (`id_pin_merge`) REFERENCES `pin_merge` (`id_pin_merge`); + ADD CONSTRAINT `fk_state_id_chip` FOREIGN KEY (`id_chip`) REFERENCES `chip` (`id_chip`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Constraints for table `user`