maj.sql 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. DROP TABLE IF EXISTS `type_access`;
  2. DROP TABLE IF EXISTS `access_exception`;
  3. CREATE TABLE `access_exception` (
  4. `id` int NOT NULL,
  5. `id_access` int NOT NULL,
  6. `exception` varchar(150) NOT NULL,
  7. PRIMARY KEY (`id`),
  8. KEY `id_access` (`id_access`)
  9. ) ENGINE=InnoDB;
  10. CREATE TABLE `type_access` (
  11. `id` varchar(7) NOT NULL,
  12. `id_type` int NOT NULL,
  13. `id_access` int NOT NULL,
  14. `id_exception` int DEFAULT NULL,
  15. PRIMARY KEY (`id`),
  16. KEY `idx_access_type` (`id_access`),
  17. KEY `idx_type_access` (`id_type`),
  18. KEY `idx_exception` (`id_exception`)
  19. ) ENGINE=InnoDB;
  20. ALTER TABLE `type_access`
  21. ADD CONSTRAINT `fk_access_type` FOREIGN KEY (`id_access`) REFERENCES `access` (`id`),
  22. ADD CONSTRAINT `fk_exception` FOREIGN KEY (`id_exception`) REFERENCES `access_exception` (`id`),
  23. ADD CONSTRAINT `fk_type_access` FOREIGN KEY (`id_type`) REFERENCES `type_user` (`id`);
  24. ALTER TABLE `access_exception`
  25. ADD CONSTRAINT `id_access` FOREIGN KEY (`id_access`) REFERENCES `access` (`id`);
  26. INSERT INTO `access_exception` (`id`, `id_access`, `exception`) VALUES
  27. (1, 16, 'salaire'),
  28. (2, 17, 'salaire');
  29. INSERT INTO `type_access` (`id`, `id_type`, `id_access`, `id_exception`) VALUES
  30. ('3#10', 3, 10, NULL);
  31. INSERT INTO `type_access` (`id`, `id_type`, `id_access`, `id_exception`) VALUES
  32. ('4#10', 4, 10, NULL),
  33. ('4#11', 4, 11, NULL),
  34. ('4#12', 4, 12, NULL),
  35. ('4#13', 4, 13, NULL),
  36. ('4#14', 4, 14, NULL),
  37. ('4#15', 4, 15, NULL),
  38. ('4#16', 4, 16, 1),
  39. ('4#17', 4, 17, 2),
  40. ('4#4', 4, 4, NULL),
  41. ('4#5', 4, 5, NULL),
  42. ('4#6', 4, 6, NULL),
  43. ('4#7', 4, 7, NULL),
  44. ('4#8', 4, 8, NULL),
  45. ('4#9', 4, 9, NULL);
  46. INSERT INTO `type_access` (`id`, `id_type`, `id_access`, `id_exception`) VALUES
  47. ('5#1', 5, 1, NULL),
  48. ('5#10', 5, 10, NULL),
  49. ('5#11', 5, 11, NULL),
  50. ('5#12', 5, 12, NULL),
  51. ('5#13', 5, 13, NULL),
  52. ('5#14', 5, 14, NULL),
  53. ('5#15', 5, 15, NULL),
  54. ('5#16', 5, 16, NULL),
  55. ('5#17', 5, 17, NULL),
  56. ('5#2', 5, 2, NULL),
  57. ('5#4', 5, 4, NULL),
  58. ('5#5', 5, 5, NULL),
  59. ('5#6', 5, 6, NULL),
  60. ('5#7', 5, 7, NULL),
  61. ('5#8', 5, 8, NULL),
  62. ('5#9', 5, 9, NULL);
  63. INSERT INTO `type_access` (`id`, `id_type`, `id_access`, `id_exception`) VALUES
  64. ('6#10', 6, 10, NULL),
  65. ('6#11', 6, 11, NULL),
  66. ('6#12', 6, 12, NULL),
  67. ('6#14', 6, 14, NULL),
  68. ('6#15', 6, 15, NULL),
  69. ('6#16', 6, 16, 1),
  70. ('6#17', 6, 17, 2),
  71. ('6#4', 6, 4, NULL),
  72. ('6#5', 6, 5, NULL),
  73. ('6#7', 6, 7, NULL),
  74. ('6#8', 6, 8, NULL);
  75. INSERT INTO `type_access` (`id`, `id_type`, `id_access`, `id_exception`) VALUES
  76. ('7#1', 7, 1, NULL),
  77. ('7#16', 7, 16, NULL),
  78. ('7#17', 7, 17, NULL);