-- phpMyAdmin SQL Dump
-- version 4.5.4.1deb2ubuntu2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- 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

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `logauth`
--
CREATE DATABASE IF NOT EXISTS `logauth` DEFAULT CHARACTER SET latin1 COLLATE latin1_bin;
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,
  `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;

--
-- Dumping data for table `action`
--

INSERT INTO `action` (`id_action`, `name`, `timeout`, `required`, `action`) VALUES
(1, 'Start', 0, '0X0', '1XX'),
(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');

-- --------------------------------------------------------

--
-- 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,
  `id_source` int(11) NOT NULL,
  `id_action` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `action_merge`
--

INSERT INTO `action_merge` (`id_action_merge`, `id_target`, `id_source`, `id_action`) VALUES
(4, 1, 2, 5),
(6, 1, 2, 2),
(7, 1, 2, 3),
(8, 1, 2, 1),
(11, 1, 4, 4),
(14, 2, 2, 1),
(15, 2, 2, 2),
(16, 2, 4, 4),
(17, 2, 2, 3),
(18, 2, 2, 5),
(23, 4, 6, 4),
(26, 5, 6, 4),
(27, 4, 7, 1),
(28, 4, 7, 2),
(29, 4, 7, 3),
(30, 4, 7, 5),
(31, 5, 5, 1),
(32, 5, 5, 2),
(33, 5, 5, 3),
(34, 5, 5, 5),
(38, 5, 6, 5),
(39, 4, 6, 6),
(40, 5, 6, 6),
(41, 5, 6, 1);

-- --------------------------------------------------------

--
-- 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,
  `username` varchar(30) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
  `mail` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `password` varchar(128) COLLATE utf8_unicode_ci NOT NULL,
  `token` varchar(128) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `admin`
--

INSERT INTO `admin` (`id_admin`, `id_warehouse`, `username`, `mail`, `password`, `token`) VALUES
(1, 7, 'adrien.marques', 'adminmail@gmail.com', 'eb35bccc794d3151b050285c3f6f6d084faadcc7345302b639fbb036cf623b7befcbf7ea08579c612f6201b22cdbc98d6d5d39354b3d31f51ba0426a5299371d', '434f3494ca228538463320eccf93ba67ca29e734073fbf7a9178ba7494b0e26365bb5ae2ead89428f515cdcb9ac75f0ec2200033c3911f4a49f133dfb6dd4aca'),
(2, 8, 'alexandre.marques', 'admin2mail@gmail.com', 'b70896036f6d717f938ca09f531364c17910fc6a2011166e2c2bac6f505bda52e8d8993fefb7a6fdf13b1fd5368280f064ff87e01ae74aadf7e14f582dede676', '287361328d110cbc2e78464563e005dc82a6a0d501b84cba6770dd3d173b65eef0b226fcb8326cc14fb4ee9dec5df6622a11fd8e6e8a6e518a7eca055e67e8c5');

-- --------------------------------------------------------

--
-- 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 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,
  `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`, `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);

-- --------------------------------------------------------

--
-- 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',
  `chips` varchar(30) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `global_state`
--

INSERT INTO `global_state` (`id_global_state`, `global_state`, `chips`) VALUES
(1, '0X0', '00x'),
(2, '100', 'G1x'),
(3, '110', 'B1x'),
(4, 'XX1', 'R0x');

-- --------------------------------------------------------

--
-- Table structure for table `history`
--

DROP TABLE IF EXISTS `history`;
CREATE TABLE `history` (
  `id_history` int(11) NOT NULL,
  `timestamp` int(11) NOT NULL,
  `id_user` int(11) NOT NULL,
  `id_machine` int(11) NOT NULL,
  `id_action` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `history`
--

INSERT INTO `history` (`id_history`, `timestamp`, `id_user`, `id_machine`, `id_action`) VALUES
(139, 1491819479, 215, 127, 5),
(140, 1491819482, 215, 127, 1),
(141, 1491819484, 215, 127, 5),
(142, 1491819486, 215, 127, 1),
(143, 1491819487, 215, 127, 2),
(144, 1491819488, 215, 127, 3),
(145, 1491819497, 210, 127, 4),
(146, 1491819499, 210, 127, 1),
(147, 1491819501, 215, 127, 5),
(148, 1491819502, 215, 127, 2),
(149, 1491819506, 210, 127, 5),
(150, 1491819508, 215, 127, 1),
(151, 1491819511, 215, 127, 5),
(152, 1491819522, 215, 127, 1),
(153, 1491819522, 215, 127, 2),
(154, 1491819523, 215, 127, 3),
(155, 1491819526, 210, 127, 4),
(156, 1491819527, 215, 127, 1);

-- --------------------------------------------------------

--
-- 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,
  `id_machine` int(11) NOT NULL,
  `timestamp` int(11) NOT NULL,
  `value` text COLLATE latin1_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;

-- --------------------------------------------------------

--
-- 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,
  `name` varchar(30) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
  `token` varchar(128) DEFAULT NULL,
  `unlock_code` varchar(128) DEFAULT NULL,
  `ap` varchar(30) DEFAULT NULL,
  `ip` varchar(16) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `machine`
--

INSERT INTO `machine` (`id_machine`, `id_warehouse`, `name`, `token`, `unlock_code`, `ap`, `ip`) VALUES
(5, 7, 'HKSWS', NULL, NULL, NULL, NULL),
(6, 7, 'ASIFK', NULL, NULL, NULL, NULL),
(8, 7, 'KDVSJ', NULL, NULL, NULL, NULL),
(9, 7, 'VCEWY', NULL, NULL, NULL, NULL),
(10, 7, 'UKWVN', NULL, NULL, NULL, NULL),
(11, 7, 'FFJDJ', NULL, NULL, NULL, NULL),
(12, 7, 'NHCWO', NULL, NULL, NULL, NULL),
(13, 7, 'IBRFK', NULL, NULL, NULL, NULL),
(14, 7, 'FGLXK', NULL, NULL, NULL, NULL),
(15, 7, 'BUZRV', NULL, NULL, NULL, NULL),
(16, 7, 'WKNTM', NULL, NULL, NULL, NULL),
(17, 7, 'SPQOQ', NULL, NULL, NULL, NULL),
(18, 7, 'SSRWE', NULL, NULL, NULL, NULL),
(19, 7, 'TIBAH', NULL, NULL, NULL, NULL),
(20, 7, 'EKOFT', NULL, NULL, NULL, NULL),
(21, 7, 'GJTJW', NULL, NULL, NULL, NULL),
(22, 7, 'XIPNP', NULL, NULL, NULL, NULL),
(23, 7, 'FDFXQ', NULL, NULL, NULL, NULL),
(24, 7, 'HSCUZ', NULL, NULL, NULL, NULL),
(25, 7, 'BYKBF', NULL, NULL, NULL, NULL),
(26, 7, 'GNOKK', NULL, NULL, NULL, NULL),
(27, 7, 'WLSUB', NULL, NULL, NULL, NULL),
(28, 7, 'DMTTJ', NULL, NULL, NULL, NULL),
(29, 7, 'OCFWD', NULL, NULL, NULL, NULL),
(32, 7, 'OULIX', NULL, NULL, NULL, NULL),
(33, 7, 'XCDYM', NULL, NULL, NULL, NULL),
(34, 7, 'LREGF', NULL, NULL, NULL, NULL),
(35, 7, 'DDLSP', NULL, NULL, NULL, NULL),
(36, 7, 'DTGHG', NULL, NULL, NULL, NULL),
(37, 7, 'BZWUE', NULL, NULL, NULL, NULL),
(38, 7, 'LGDDS', NULL, NULL, NULL, NULL),
(39, 7, 'ERXMY', NULL, NULL, NULL, NULL),
(40, 7, 'VJGER', NULL, NULL, NULL, NULL),
(41, 7, 'LOXIE', NULL, NULL, NULL, NULL),
(42, 7, 'IHARA', NULL, NULL, NULL, NULL),
(43, 7, 'ZIQJQ', NULL, NULL, NULL, NULL),
(44, 7, 'ZKUEW', NULL, NULL, NULL, NULL),
(45, 7, 'BLDTO', NULL, NULL, NULL, NULL),
(46, 7, 'OZRQF', NULL, NULL, NULL, NULL),
(47, 7, 'NWPBM', NULL, NULL, NULL, NULL),
(48, 7, 'OZDYC', NULL, NULL, NULL, NULL),
(49, 7, 'ETUZU', NULL, NULL, NULL, NULL),
(50, 7, 'CNQAB', NULL, NULL, NULL, NULL),
(51, 7, 'OPIIW', NULL, NULL, NULL, NULL),
(53, 7, 'NMHYG', NULL, NULL, NULL, NULL),
(54, 7, 'ASKZD', NULL, NULL, NULL, NULL),
(55, 7, 'QMIJT', NULL, NULL, NULL, NULL),
(56, 7, 'BBDZL', NULL, NULL, NULL, NULL),
(57, 7, 'WKKYH', NULL, NULL, NULL, NULL),
(58, 7, 'AFHJH', '9c1b8b74a81b6f192c7ebe5df319d060a13acab5079fa8e1ee6e95544bdd6a89b81522127c29ce75eeb71d5d82161b0fc818ff11f4d749cc76062221e8e1dcf9', NULL, NULL, NULL),
(59, 7, 'CASXB', NULL, NULL, NULL, NULL),
(60, 7, 'LOXOZ', NULL, NULL, NULL, NULL),
(61, 7, 'ZTUNO', NULL, NULL, NULL, NULL),
(62, 7, 'QGQNK', NULL, NULL, NULL, NULL),
(63, 7, 'SVIBS', NULL, NULL, NULL, NULL),
(64, 7, 'RSVXL', NULL, NULL, NULL, NULL),
(65, 7, 'EMESC', NULL, NULL, NULL, NULL),
(66, 7, 'BBXON', NULL, NULL, NULL, NULL),
(67, 7, 'NGLBK', NULL, NULL, NULL, NULL),
(68, 7, 'MZHBC', NULL, NULL, NULL, NULL),
(69, 7, 'OYEPB', NULL, NULL, NULL, NULL),
(70, 7, 'RQFNK', NULL, NULL, NULL, NULL),
(71, 7, 'MRUUS', NULL, NULL, NULL, NULL),
(72, 7, 'DJDVW', NULL, NULL, NULL, NULL),
(73, 7, 'SOJEJ', NULL, NULL, NULL, NULL),
(74, 7, 'YYSRC', NULL, NULL, NULL, NULL),
(75, 7, 'AJNMI', NULL, NULL, NULL, NULL),
(76, 7, 'IVUSU', NULL, NULL, NULL, NULL),
(77, 7, 'VYPUB', NULL, NULL, NULL, NULL),
(78, 7, 'SJYUN', NULL, NULL, NULL, NULL),
(79, 7, 'QRGTG', NULL, NULL, NULL, NULL),
(80, 7, 'LXIFX', NULL, NULL, NULL, NULL),
(81, 7, 'YXWTP', NULL, NULL, NULL, NULL),
(82, 7, 'SMEFT', NULL, NULL, NULL, NULL),
(83, 7, 'HUTUW', NULL, NULL, NULL, NULL),
(84, 7, 'DYCLY', NULL, NULL, NULL, NULL),
(85, 7, 'VBJWP', NULL, NULL, NULL, NULL),
(86, 7, 'CZRPO', NULL, NULL, NULL, NULL),
(87, 7, 'JCNSP', NULL, NULL, NULL, NULL),
(88, 7, 'EOKCA', NULL, NULL, NULL, NULL),
(89, 7, 'PZEAK', NULL, NULL, NULL, NULL),
(90, 7, 'ERIMX', NULL, NULL, NULL, NULL),
(91, 7, 'NGVPC', NULL, NULL, NULL, NULL),
(92, 7, 'MVONW', NULL, NULL, NULL, NULL),
(93, 7, 'ZUHOD', NULL, NULL, NULL, NULL),
(94, 7, 'YIATG', NULL, NULL, NULL, NULL),
(95, 7, 'WFQGC', NULL, NULL, NULL, NULL),
(96, 7, 'NKZQL', NULL, NULL, NULL, NULL),
(97, 7, 'EMIWA', NULL, NULL, NULL, NULL),
(98, 7, 'WOYWY', NULL, NULL, NULL, NULL),
(99, 7, 'ZBLQG', NULL, NULL, NULL, NULL),
(100, 7, 'STQYS', NULL, NULL, NULL, NULL),
(101, 7, 'a', NULL, NULL, NULL, NULL),
(102, 7, 'machine1', NULL, NULL, NULL, NULL),
(103, 7, 'machine2', NULL, NULL, NULL, NULL),
(104, 7, 'machine3', NULL, NULL, NULL, NULL),
(105, 7, 'machine4', NULL, NULL, NULL, NULL),
(106, 7, 'machine5', NULL, NULL, NULL, NULL),
(107, 7, 'machine6', NULL, NULL, NULL, NULL),
(108, 7, 'machine7', NULL, NULL, NULL, NULL),
(109, 7, 'machine8', NULL, NULL, NULL, NULL),
(110, 7, 'machine9', NULL, NULL, NULL, NULL),
(111, 7, 'machine10', NULL, NULL, NULL, NULL),
(112, 7, 'machine11', NULL, NULL, NULL, NULL),
(113, 7, 'machine12', NULL, NULL, NULL, NULL),
(114, 7, 'b', NULL, NULL, NULL, NULL),
(115, 7, 'sd', NULL, NULL, NULL, NULL),
(116, 7, 'machine13', NULL, NULL, NULL, NULL),
(121, 7, 'dsad', NULL, NULL, NULL, NULL),
(122, 8, 'surgel1', NULL, NULL, NULL, NULL),
(123, 8, 'surgel2', NULL, NULL, NULL, NULL),
(124, 8, 'surgel3', NULL, NULL, NULL, NULL),
(125, 8, 'surgel4', NULL, NULL, NULL, NULL),
(126, 8, 'lait1', NULL, '159050986ee4fdeb3ead38f83b12511ca2223c4bc1939ee47edd1549393b1b5cf829803a392b1ce3ef03f45c705a90a0c5b07f4a435ade50586d2b2c8e29d490', NULL, NULL),
(127, 8, 'lait2', '2daca1d493c3cb95d067827483b64bc3f5c20c168401c4d3f2096b3b458c3a84c18fb3008fd6f9fc434e554f930d5bf7a043aee1b58c7661c74bccfd384fa4e0', '0d7e99166c23eb7e56dfe331f7e92535c9b1f4bc9103ed2b2f9d72c55dfa3d1601e60ded996bc2c0e7a152286f1b49f0644534154910eb3d7efb5d8588b73369', NULL, NULL),
(128, 8, 'lait3', NULL, NULL, NULL, NULL),
(129, 8, 'lait4', NULL, NULL, NULL, NULL);

-- --------------------------------------------------------

--
-- 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,
  `name` varchar(30) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `machine_cluster`
--

INSERT INTO `machine_cluster` (`id_machine_cluster`, `id_warehouse`, `name`) VALUES
(1, 7, 'surgelÃ©s'),
(2, 7, 'laitiers'),
(3, 7, 'fruits.legumes'),
(4, 8, 'Machines SurgelÃ©s'),
(5, 8, 'Machines Laitiers');

-- --------------------------------------------------------

--
-- 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,
  `id_machine` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `machine_cluster_merge`
--

INSERT INTO `machine_cluster_merge` (`id_machine_cluster_merge`, `id_machine_cluster`, `id_machine`) VALUES
(3, 1, 58),
(4, 2, 75),
(5, 3, 6),
(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);

-- --------------------------------------------------------

--
-- 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
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `module`
--

INSERT INTO `module` (`id_module`, `name`) VALUES
(1, 'rfid'),
(2, 'motheure'),
(3, 'portail');

-- --------------------------------------------------------

--
-- 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
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `module_availability`
--

INSERT INTO `module_availability` (`id_warehouse`, `id_module`) VALUES
(7, 1),
(8, 1),
(7, 2),
(8, 2);

-- --------------------------------------------------------

--
-- 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,
  `id_module` int(11) NOT NULL,
  `id_warehouse` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `module_merge`
--

INSERT INTO `module_merge` (`id_module_merge`, `id_machine_cluster`, `id_module`, `id_warehouse`) VALUES
(1, 4, 1, 8),
(2, 5, 1, 8);

-- --------------------------------------------------------

--
-- Table structure for table `state`
--

DROP TABLE IF EXISTS `state`;
CREATE TABLE `state` (
  `id_state` int(11) NOT NULL,
  `id_chip` int(11) NOT NULL,
  `state` varchar(1) COLLATE utf8_unicode_ci 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_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');

-- --------------------------------------------------------

--
-- 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,
  `code` varchar(20) NOT NULL,
  `username` varchar(30) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
  `firstname` varchar(30) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
  `lastname` varchar(30) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
  `mail` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `user`
--

INSERT INTO `user` (`id_user`, `id_warehouse`, `code`, `username`, `firstname`, `lastname`, `mail`) VALUES
(1, 7, '92-55-B9-B4', 'jufrenc', 'Juliana', 'French', 'julianafrench@core.com'),
(2, 7, '10-FE-BD-61', 'cuchurc', 'Curry', 'Church', 'currychurch@corecom.com'),
(3, 7, 'E0-11-41-DB', 'gediaz', 'Geneva', 'Diaz', 'genevadiaz@corecom.com'),
(7, 7, 'DB-A3-8A-D7', 'rogomez', 'bli', 'Gomez', 'rodriquezgomez@corecom.com'),
(8, 7, 'AF-BB-68-6B', 'beholde', 'Bender', 'Holder', 'benderholder@corecom.com'),
(9, 7, '39-DF-20-69', 'bemurra', 'Beck', 'Murray', 'beckmurray@corecom.com'),
(11, 7, '75-E1-A6-9E', 'phpears', 'Phoebe', 'Pearson', 'phoebepearson@corecom.com'),
(13, 7, 'E1-C8-AB-8C', 'shmcgow', 'Shepherd', 'Mcgowan', 'shepherdmcgowan@corecom.com'),
(14, 7, '7C-94-C4-9A', 'sawolfe', 'Sandoval', 'Wolfe', 'sandovalwolfe@corecom.com'),
(15, 7, '36-3C-BB-F4', 'jualvar', 'Julie', 'Alvarado', 'juliealvarado@corecom.com'),
(16, 7, 'E7-52-B2-35', 'erhayes', 'Erin', 'Hayes', 'erinhayes@corecom.com'),
(18, 7, '89-64-A2-C2', 'jamcgee', 'Janine', 'Mcgee', 'janinemcgee@corecom.com'),
(19, 7, 'AB-E2-19-73', 'jawilco', 'Janell', 'Wilcox', 'janellwilcox@corecom.com'),
(20, 7, '88-13-39-95', 'guhale', 'Gutierrez', 'Hale', 'gutierrezhale@corecom.com'),
(21, 7, '6A-8B-F5-05', 'loclark', 'Lowery', 'Clarke', 'loweryclarke@corecom.com'),
(23, 7, 'C2-97-8A-D1', 'docohen', 'Dorsey', 'Cohen', 'dorseycohen@corecom.com'),
(24, 7, 'D1-CD-18-D5', 'moallen', 'Mosley', 'Allen', 'mosleyallen@corecom.com'),
(25, 7, 'BF-18-2B-5A', 'gehenry', 'Georgia', 'Henry', 'georgiahenry@corecom.com'),
(26, 7, '3A-B9-55-4C', 'rodaugh', 'Rosetta', 'Daugherty', 'rosettadaugherty@corecom.com'),
(27, 7, '6C-90-5E-0A', 'adsmall', 'Adrian', 'Small', 'adriansmall@corecom.com'),
(28, 7, '3B-FE-71-B1', 'belong', 'Benton', 'Long', 'bentonlong@corecom.com'),
(29, 7, '94-B6-5A-D4', 'atriddl', 'Atkins', 'Riddle', 'atkinsriddle@corecom.com'),
(31, 7, '7D-2B-DB-BD', 'buluna', 'Bush', 'Luna', 'bushluna@corecom.com'),
(32, 7, 'D8-A3-FB-FC', 'frodom', 'Fran', 'Odom', 'franodom@corecom.com'),
(33, 7, 'D8-3D-79-D5', 'stvaugh', 'Stevens', 'Vaughan', 'stevensvaughan@corecom.com'),
(34, 7, 'CE-08-DB-1D', 'krgilli', 'Kristi', 'Gilliam', 'kristigilliam@corecom.com'),
(35, 7, 'F1-3C-AA-0D', 'trwolf', 'Trudy', 'Wolf', 'trudywolf@corecom.com'),
(36, 7, '86-EE-8D-B3', 'peharre', 'Penelope', 'Harrell', 'penelopeharrell@corecom.com'),
(37, 7, '34-1E-E7-CC', 'perober', 'Pena', 'Roberson', 'penaroberson@corecom.com'),
(38, 7, '36-E8-D6-7F', 'makeith', 'Maryann', 'Keith', 'maryannkeith@corecom.com'),
(39, 7, '23-77-0B-03', 'almatth', 'Allie', 'Matthews', 'alliematthews@corecom.com'),
(40, 7, '83-1B-E8-D4', 'gicarpe', 'Giles', 'Carpenter', 'gilescarpenter@corecom.com'),
(41, 7, '59-4F-13-7B', 'nemays', 'Newman', 'Mays', 'newmanmays@corecom.com'),
(43, 7, '5F-CA-AD-DC', 'laguthr', 'Larson', 'Guthrie', 'larsonguthrie@corecom.com'),
(45, 7, 'E9-61-60-8B', 'elgolde', 'Ella', 'Golden', 'ellagolden@corecom.com'),
(46, 7, '3B-27-8E-1F', 'cacasta', 'Cantrell', 'Castaneda', 'cantrellcastaneda@corecom.com'),
(47, 7, '49-DF-A5-C2', 'auwalla', 'Audrey', 'Wallace', 'audreywallace@corecom.com'),
(48, 7, 'B1-87-EA-BF', 'mcsavag', 'Mcmillan', 'Savage', 'mcmillansavage@corecom.com'),
(49, 7, '63-7F-09-29', 'shhicks', 'Shawna', 'Hicks', 'shawnahicks@corecom.com'),
(50, 7, 'C9-48-F7-62', 'lyroth', 'Lynn', 'Roth', 'lynnroth@corecom.com'),
(51, 7, 'DF-CD-42-C9', 'mitran', 'Minerva', 'Tran', 'minervatran@corecom.com'),
(53, 7, 'F5-AA-76-14', 'wrdelga', 'Wright', 'Delgado', 'wrightdelgado@corecom.com'),
(54, 7, 'A5-C8-50-F5', 'mamccon', 'May', 'Mcconnell', 'maymcconnell@corecom.com'),
(55, 7, 'A0-0E-D0-AC', 'heranda', 'Herrera', 'Randall', 'herrerarandall@corecom.com'),
(56, 7, 'FF-1F-FD-20', 'gwyates', 'Gwendolyn', 'Yates', 'gwendolynyates@corecom.com'),
(57, 7, '7D-0D-95-B1', 'rabento', 'Ramos', 'Benton', 'ramosbenton@corecom.com'),
(58, 7, '9D-5A-95-A9', 'grhorne', 'Graves', 'Horne', 'graveshorne@corecom.com'),
(59, 7, 'B9-3C-5A-74', 'malawre', 'Maribel', 'Lawrence', 'maribellawrence@corecom.com'),
(60, 7, 'E0-B9-0F-F5', 'pelinds', 'Peterson', 'Lindsey', 'petersonlindsey@corecom.com'),
(61, 7, 'BD-A1-69-F0', 'lechen', 'Lee', 'Chen', 'leechen@corecom.com'),
(62, 7, '81-8B-3B-DD', 'doramos', 'Doreen', 'Ramos', 'doreenramos@corecom.com'),
(64, 7, '12-74-96-57', 'kamarti', 'Kane', 'Martinez', 'kanemartinez@corecom.com'),
(65, 7, '5E-CA-06-D0', 'elmolin', 'Eleanor', 'Molina', 'eleanormolina@corecom.com'),
(66, 7, '46-D5-1C-58', 'pesimps', 'Pennington', 'Simpson', 'penningtonsimpson@corecom.com'),
(67, 7, '04-D8-00-77', 'tacleme', 'Tami', 'Clements', 'tamiclements@corecom.com'),
(69, 7, '99-82-48-DC', 'chmeado', 'Charlene', 'Meadows', 'charlenemeadows@corecom.com'),
(70, 7, '51-FC-6F-FB', 'loware', 'Lois', 'Ware', 'loisware@corecom.com'),
(71, 7, 'C5-20-CB-4B', 'mcwashi', 'Mcgee', 'Washington', 'mcgeewashington@corecom.com'),
(72, 7, 'BA-25-6F-EA', 'laoneil', 'Langley', 'Oneil', 'langleyoneil@corecom.com'),
(73, 7, 'D6-9E-A2-80', 'frfloyd', 'Frost', 'Floyd', 'frostfloyd@corecom.com'),
(74, 7, '26-C4-EB-5D', 'dipruit', 'Diaz', 'Pruitt', 'diazpruitt@corecom.com'),
(75, 7, '8A-BF-C9-3D', 'butucke', 'Bullock', 'Tucker', 'bullocktucker@corecom.com'),
(76, 7, '17-4B-80-EC', 'fohyde', 'Foster', 'Hyde', 'fosterhyde@corecom.com'),
(77, 7, 'C8-5B-C6-4A', 'halarse', 'Hahn', 'Larsen', 'hahnlarsen@corecom.com'),
(78, 7, 'BD-6F-75-F0', 'pahawki', 'Payne', 'Hawkins', 'paynehawkins@corecom.com'),
(79, 7, 'C4-DB-18-8B', 'lecantr', 'Leach', 'Cantrell', 'leachcantrell@corecom.com'),
(81, 7, '04-08-EB-92', 'mubrook', 'Munoz', 'Brooks', 'munozbrooks@corecom.com'),
(82, 7, 'EB-DB-FD-87', 'sofarle', 'Sofia', 'Farley', 'sofiafarley@corecom.com'),
(83, 7, '83-F4-17-0D', 'trwalls', 'Trina', 'Walls', 'trinawalls@corecom.com'),
(84, 7, 'E7-7D-E0-52', 'prgentr', 'Price', 'Gentry', 'pricegentry@corecom.com'),
(85, 7, '0F-6C-B6-F9', 'adwilli', 'Adriana', 'Williamson', 'adrianawilliamson@corecom.com'),
(86, 7, '2D-C2-9C-32', 'gaarmst', 'Garner', 'Armstrong', 'garnerarmstrong@corecom.com'),
(87, 7, '1C-5E-93-06', 'ratrevi', 'Rachael', 'Trevino', 'rachaeltrevino@corecom.com'),
(88, 7, '6F-49-74-A5', 'sagates', 'Samantha', 'Gates', 'samanthagates@corecom.com'),
(89, 7, '54-65-6C-9F', 'swbarry', 'Sweet', 'Barry', 'sweetbarry@corecom.com'),
(91, 7, 'F1-D0-5D-4E', 'rushann', 'blo', 'Shannon', 'russellshannon@corecom.com'),
(94, 7, '28-86-38-25', 'euantho', 'zlozlazli', 'Anthony', 'eugeniaanthony@corecom.com'),
(95, 7, 'C7-7C-E2-41', 'kirodri', 'bloblabli', 'Rodriguez', 'kingrodriguez@corecom.com'),
(96, 7, '6B-1B-5E-A7', 'momeyer', 'Montoya', 'Meyer', 'montoyameyer@corecom.com'),
(97, 7, '48-03-38-1F', 'lastron', 'Larsen', 'Strong', 'larsenstrong@corecom.com'),
(98, 7, 'E0-4B-04-F6', 'crklein', 'Craft', 'Klein', 'craftklein@corecom.com'),
(99, 7, '2F-7D-0A-51', 'decampo', 'Delgado', 'Campos', 'delgadocampos@corecom.com'),
(100, 7, '91-D4-7E-65', 'mclott', 'Mcmahon', 'Lott', 'mcmahonlott@corecom.com'),
(101, 7, '01-FB-DB-83', 'username', 'firstname', 'lastname', 'mail@mail.com'),
(103, 7, '01-FB-DB-84', 'usernames', 'firstname', 'lastname', 'mail@mail.com'),
(204, 7, 'A1-AD-CA-2D', 'user2x', 'firstname', 'lastnamex', 'mail2x@gmail.com'),
(206, 8, 'FD-60-13-3B', 'Carte1', 'Carte', 'RFID1', 'brussal.alain@lk.fr'),
(208, 8, '33-33-33-35', 'lucas.mascaro', 'Lucas', 'Mascaro', 'mascaro.lucas@yahoo.fr'),
(210, 8, '34-C2-A0-85', 'xdrm-brackets', 'Adrien', 'Ligou-MarquÃ¨s', 'doowap31@gmail.com'),
(214, 7, '66-66-66-66', 'lucas.mascaro', 'Lucas', 'Mascaro', 'mascaro.lucas@yahoo.fr'),
(215, 8, 'F9-7D-5D-9E', 'Pass1', 'Pass', 'RFID', 'pass1@logauth.com');

-- --------------------------------------------------------

--
-- 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,
  `name` varchar(30) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `user_cluster`
--

INSERT INTO `user_cluster` (`id_user_cluster`, `id_warehouse`, `name`) VALUES
(2, 7, 'conducteurs'),
(4, 7, 'maintenance'),
(5, 8, 'Conducteurs Lait'),
(6, 8, 'Maintenance'),
(7, 8, 'Conducteurs SurgelÃ©');

-- --------------------------------------------------------

--
-- 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,
  `id_user` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `user_cluster_merge`
--

INSERT INTO `user_cluster_merge` (`id_user_cluster_merge`, `id_user_cluster`, `id_user`) VALUES
(12, 2, 15),
(23, 4, 7),
(42, 2, 7),
(43, 2, 3),
(51, 4, 9),
(52, 4, 16),
(53, 4, 13),
(54, 2, 1),
(55, 4, 1),
(61, 7, 206),
(65, 7, 208),
(86, 6, 210),
(87, 5, 215);

-- --------------------------------------------------------

--
-- 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,
  `theme` varchar(6) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'f44f06',
  `password` varchar(128) COLLATE utf8_unicode_ci NOT NULL,
  `token` varchar(128) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `warehouse`
--

INSERT INTO `warehouse` (`id_warehouse`, `name`, `theme`, `password`, `token`) VALUES
(7, 'stef-montauban', '3091DB', '53859350c1eb59e301d8fe747f4d1c96d3ec31d95cd1bc72c81d72800edbc6ab45da0d5b6208080fb2e519b1f9848ce0a1289775800912068f32e390f5e1bb6c', '2046c66738b4f1f1e6460537f11970ec5b2cfa65f295b2ca0d2036609dcd3f8ccb6ec271e15440933d3b24ae27eba71423a4545583ab6f3736a5d4f7c8f8c53e'),
(8, 'stef-toulouse', 'DB554E', '273bd225482d20c061620c80e3bb87528d9e178bd572acd47feb58eee7e8a3847cb308b287d9d94c7a292b33d4c766cdb7c95c2828f53b97bbc0f80fa44aeb83', '52131065a906de90e26da0732e58400edd6739cfa03fc658e7593abef4a4504e18e66e1a8fe9da374a8e8f753603463e4777789262b3ee945d4bf72dd8d6399c');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `action`
--
ALTER TABLE `action`
  ADD PRIMARY KEY (`id_action`);

--
-- Indexes for table `action_merge`
--
ALTER TABLE `action_merge`
  ADD PRIMARY KEY (`id_action_merge`),
  ADD KEY `id_action` (`id_action`),
  ADD KEY `id_target` (`id_target`),
  ADD KEY `id_source` (`id_source`);

--
-- Indexes for table `admin`
--
ALTER TABLE `admin`
  ADD PRIMARY KEY (`id_admin`),
  ADD KEY `id_warehouse` (`id_warehouse`);

--
-- Indexes for table `chip`
--
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`
--
ALTER TABLE `global_state`
  ADD PRIMARY KEY (`id_global_state`);

--
-- Indexes for table `history`
--
ALTER TABLE `history`
  ADD PRIMARY KEY (`id_history`),
  ADD KEY `id_user` (`id_user`,`id_machine`,`id_action`),
  ADD KEY `history_id_machine` (`id_machine`),
  ADD KEY `history_id_action` (`id_action`);

--
-- Indexes for table `log`
--
ALTER TABLE `log`
  ADD PRIMARY KEY (`id_log`),
  ADD KEY `id_machine` (`id_machine`),
  ADD KEY `id_feature` (`id_feature`);

--
-- Indexes for table `machine`
--
ALTER TABLE `machine`
  ADD PRIMARY KEY (`id_machine`),
  ADD UNIQUE KEY `token` (`token`),
  ADD KEY `id_warehouse` (`id_warehouse`);

--
-- Indexes for table `machine_cluster`
--
ALTER TABLE `machine_cluster`
  ADD PRIMARY KEY (`id_machine_cluster`),
  ADD KEY `id_warehouse` (`id_warehouse`);

--
-- Indexes for table `machine_cluster_merge`
--
ALTER TABLE `machine_cluster_merge`
  ADD PRIMARY KEY (`id_machine_cluster_merge`),
  ADD KEY `id_machine_cluster` (`id_machine_cluster`),
  ADD KEY `id_machine` (`id_machine`);

--
-- Indexes for table `module`
--
ALTER TABLE `module`
  ADD PRIMARY KEY (`id_module`);

--
-- Indexes for table `module_availability`
--
ALTER TABLE `module_availability`
  ADD KEY `id_module` (`id_module`),
  ADD KEY `id_warehouse` (`id_warehouse`);

--
-- Indexes for table `module_merge`
--
ALTER TABLE `module_merge`
  ADD PRIMARY KEY (`id_module_merge`),
  ADD KEY `id_machine_cluster` (`id_machine_cluster`),
  ADD KEY `id_machine` (`id_module`),
  ADD KEY `id_warehouse` (`id_warehouse`);

--
-- Indexes for table `state`
--
ALTER TABLE `state`
  ADD PRIMARY KEY (`id_state`),
  ADD KEY `id_pin_merge` (`id_chip`);

--
-- Indexes for table `user`
--
ALTER TABLE `user`
  ADD PRIMARY KEY (`id_user`),
  ADD KEY `id_warehouse` (`id_warehouse`);

--
-- Indexes for table `user_cluster`
--
ALTER TABLE `user_cluster`
  ADD PRIMARY KEY (`id_user_cluster`),
  ADD KEY `id_warehouse` (`id_warehouse`);

--
-- Indexes for table `user_cluster_merge`
--
ALTER TABLE `user_cluster_merge`
  ADD PRIMARY KEY (`id_user_cluster_merge`),
  ADD KEY `id_user_cluster` (`id_user_cluster`),
  ADD KEY `id_user` (`id_user`);

--
-- Indexes for table `warehouse`
--
ALTER TABLE `warehouse`
  ADD PRIMARY KEY (`id_warehouse`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `action`
--
ALTER TABLE `action`
  MODIFY `id_action` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `action_merge`
--
ALTER TABLE `action_merge`
  MODIFY `id_action_merge` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=42;
--
-- AUTO_INCREMENT for table `admin`
--
ALTER TABLE `admin`
  MODIFY `id_admin` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `chip`
--
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`
  MODIFY `id_global_state` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `history`
--
ALTER TABLE `history`
  MODIFY `id_history` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=157;
--
-- AUTO_INCREMENT for table `log`
--
ALTER TABLE `log`
  MODIFY `id_log` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `machine`
--
ALTER TABLE `machine`
  MODIFY `id_machine` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=130;
--
-- AUTO_INCREMENT for table `machine_cluster`
--
ALTER TABLE `machine_cluster`
  MODIFY `id_machine_cluster` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- 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=17;
--
-- AUTO_INCREMENT for table `module`
--
ALTER TABLE `module`
  MODIFY `id_module` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `module_merge`
--
ALTER TABLE `module_merge`
  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=21;
--
-- AUTO_INCREMENT for table `user`
--
ALTER TABLE `user`
  MODIFY `id_user` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=216;
--
-- AUTO_INCREMENT for table `user_cluster`
--
ALTER TABLE `user_cluster`
  MODIFY `id_user_cluster` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- 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=88;
--
-- AUTO_INCREMENT for table `warehouse`
--
ALTER TABLE `warehouse`
  MODIFY `id_warehouse` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- Constraints for dumped tables
--

--
-- Constraints for table `action_merge`
--
ALTER TABLE `action_merge`
  ADD CONSTRAINT `action_merge_id_action` FOREIGN KEY (`id_action`) REFERENCES `action` (`id_action`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `action_merge_id_source` FOREIGN KEY (`id_source`) REFERENCES `user_cluster` (`id_user_cluster`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `action_merge_id_target` FOREIGN KEY (`id_target`) REFERENCES `machine_cluster` (`id_machine_cluster`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `admin`
--
ALTER TABLE `admin`
  ADD CONSTRAINT `admin_id_warehouse` FOREIGN KEY (`id_warehouse`) REFERENCES `warehouse` (`id_warehouse`);

--
-- Constraints for table `chip`
--
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`
--
ALTER TABLE `history`
  ADD CONSTRAINT `history_id_action` FOREIGN KEY (`id_action`) REFERENCES `action` (`id_action`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `history_id_machine` FOREIGN KEY (`id_machine`) REFERENCES `machine` (`id_machine`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `history_id_user` FOREIGN KEY (`id_user`) REFERENCES `user` (`id_user`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `log`
--
ALTER TABLE `log`
  ADD CONSTRAINT `log_id_feature` FOREIGN KEY (`id_feature`) REFERENCES `module` (`id_module`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `log_id_machine` FOREIGN KEY (`id_machine`) REFERENCES `machine` (`id_machine`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `machine`
--
ALTER TABLE `machine`
  ADD CONSTRAINT `machine_id_warehouse` FOREIGN KEY (`id_warehouse`) REFERENCES `warehouse` (`id_warehouse`);

--
-- Constraints for table `machine_cluster`
--
ALTER TABLE `machine_cluster`
  ADD CONSTRAINT `machine_cluster_id_warehouse` FOREIGN KEY (`id_warehouse`) REFERENCES `warehouse` (`id_warehouse`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `machine_cluster_merge`
--
ALTER TABLE `machine_cluster_merge`
  ADD CONSTRAINT `fk_machine_cluster_merge_id_machine` FOREIGN KEY (`id_machine`) REFERENCES `machine` (`id_machine`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_machine_cluster_merge_id_machine_cluster` FOREIGN KEY (`id_machine_cluster`) REFERENCES `machine_cluster` (`id_machine_cluster`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `module_availability`
--
ALTER TABLE `module_availability`
  ADD CONSTRAINT `module_merge_id_module` FOREIGN KEY (`id_module`) REFERENCES `module` (`id_module`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `module_merge_id_warehouse` FOREIGN KEY (`id_warehouse`) REFERENCES `warehouse` (`id_warehouse`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `module_merge`
--
ALTER TABLE `module_merge`
  ADD CONSTRAINT `fk_module_merge_id_machine_cluster` FOREIGN KEY (`id_machine_cluster`) REFERENCES `machine_cluster` (`id_machine_cluster`) ON DELETE CASCADE ON UPDATE CASCADE,
  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 `state`
--
ALTER TABLE `state`
  ADD CONSTRAINT `fk_state_id_chip` FOREIGN KEY (`id_chip`) REFERENCES `chip` (`id_chip`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `user`
--
ALTER TABLE `user`
  ADD CONSTRAINT `user_id_warehouse` FOREIGN KEY (`id_warehouse`) REFERENCES `warehouse` (`id_warehouse`);

--
-- Constraints for table `user_cluster`
--
ALTER TABLE `user_cluster`
  ADD CONSTRAINT `user_cluster_id_warehouse` FOREIGN KEY (`id_warehouse`) REFERENCES `warehouse` (`id_warehouse`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `user_cluster_merge`
--
ALTER TABLE `user_cluster_merge`
  ADD CONSTRAINT `user_cluster_merge_id_user` FOREIGN KEY (`id_user`) REFERENCES `user` (`id_user`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `user_cluster_merge_id_user_cluster` FOREIGN KEY (`id_user_cluster`) REFERENCES `user_cluster` (`id_user_cluster`) ON DELETE CASCADE ON UPDATE CASCADE;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;