--
-- Host: localhost    Database: manuclemmanu
-- ------------------------------------------------------


--
-- Table structure for table `category`
--

CREATE TABLE `category` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(50) NOT NULL,
  `position` int(11) NOT NULL,
  `shop_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `shop_id` (`shop_id`),
  CONSTRAINT `category_ibfk_1` FOREIGN KEY (`shop_id`) REFERENCES `shop` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `category`
--


--
-- Table structure for table `country`
--

CREATE TABLE `country` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Countries',
  `value` varchar(50) NOT NULL COMMENT 'Country',
  `countrycode` varchar(50) NOT NULL COMMENT 'Code',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `country`
--

INSERT INTO `country` VALUES (1,'France','FR'),(2,'Belgique','BE'),(3,'GD Luxembourg','LU');

--
-- Table structure for table `opening_hours`
--

CREATE TABLE `opening_hours` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Horaires',
  `day` varchar(50) NOT NULL COMMENT 'Jour',
  `am_from` time NOT NULL COMMENT 'Matin depuis',
  `am_to` time NOT NULL COMMENT 'Matin jusque',
  `pm_from` time NOT NULL COMMENT 'Après midi depuis',
  `pm_to` time NOT NULL COMMENT 'Après midi jusque',
  `shop_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `opening_hours`
--


--
-- Table structure for table `product`
--

CREATE TABLE `product` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `description` text NOT NULL,
  `title` int(50) NOT NULL,
  `price` decimal(6,2) NOT NULL,
  `category_id` int(11) NOT NULL,
  `position` int(11) NOT NULL,
  `sell_as_unique` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `category_id` (`category_id`),
  CONSTRAINT `product_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `category` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `product`
--


--
-- Table structure for table `role`
--

CREATE TABLE `role` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `value` varchar(50) NOT NULL COMMENT 'Rôle',
  PRIMARY KEY (`id`),
  UNIQUE KEY `role_value` (`value`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `role`
--

INSERT INTO `role` VALUES (1,'admin'),(2,'user');

--
-- Table structure for table `session`
--

CREATE TABLE `session` (
  `id` varchar(255) NOT NULL,
  `last_access` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `session_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `session`
--

INSERT INTO `session` VALUES ('05567255e17cca5992a689599c194ae1',1635671612,1),('152c15aa521f53ef59e474c673f3048f',1635628098,1),('25ff4ca29272fd2fe9e1ee28c04281a2',1635322910,1),('bb3eac46efcb348f09a6d194f3277e4e',1635286753,1),('ccf2907d71cebf1344f27e5de1463700',1635496764,1);

--
-- Table structure for table `shop`
--

CREATE TABLE `shop` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Etablissements',
  `shop_code` varchar(20) NOT NULL COMMENT 'Identifiant établissement (siret,...)',
  `shop_name` varchar(50) NOT NULL COMMENT 'Nom',
  `shop_speciality` varchar(50) DEFAULT NULL COMMENT 'Spécialité',
  `street` varchar(100) NOT NULL COMMENT 'Rue & num',
  `city` varchar(100) NOT NULL COMMENT 'Ville',
  `zip` int(11) NOT NULL COMMENT 'Code Postal',
  `country_id` int(11) NOT NULL COMMENT 'Pays',
  `latitude` decimal(8,6) NOT NULL COMMENT 'Latitude|native',
  `telephone` varchar(10) NOT NULL COMMENT 'Téléphone',
  `deliverylink` varchar(100) DEFAULT NULL COMMENT 'Site de livraison',
  `shop_date` datetime NOT NULL COMMENT 'Creation date|native',
  `shop_is_valid` tinyint(1) NOT NULL COMMENT 'is_valid|native',
  `friendlyurl` varchar(100) NOT NULL COMMENT 'FriendlyURL|native',
  `longitude` decimal(9,6) NOT NULL COMMENT 'longitude|native',
  `user_id` int(11) NOT NULL,
  `stripe_account` varchar(80) DEFAULT NULL,
  `stripe_creation_date` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `user_id` (`user_id`),
  KEY `country_id` (`country_id`),
  KEY `user_id_2` (`user_id`),
  CONSTRAINT `shop_ibfk_2` FOREIGN KEY (`country_id`) REFERENCES `country` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `shop_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `shop`
--


--
-- Table structure for table `user`
--

CREATE TABLE `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Utilisateurs',
  `username` varchar(50) NOT NULL COMMENT 'Utilisateur',
  `email` varchar(50) NOT NULL COMMENT 'email',
  `password` varchar(80) NOT NULL COMMENT 'Mot de passe',
  `code` varchar(80) NOT NULL COMMENT 'Code',
  `is_valid` tinyint(1) NOT NULL COMMENT 'Est valide',
  `creation_date` date NOT NULL COMMENT 'Création',
  `last_access` date NOT NULL COMMENT 'Dernier accès',
  `role_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `role_id` (`role_id`),
  CONSTRAINT `user_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

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

INSERT INTO `user` VALUES (1,'manuclem','manu.clement.fr@gmail.com','$2y$12$lIDXtCPG1gT39tA9kvL36uSt2JSI6dyM43iq6GAsb34ONKUxuE.JK','74rvMxQ',1,'2020-09-01','2021-09-01',1),(2,'charles','charles@gmail.com','$2y$12$lIDXtCPG1gT39tA9kvL36uSt2JSI6dyM43iq6GAsb34ONKUxuE.JK','74rvexQ',1,'2020-09-01','2021-09-01',2);


