install.template.sql 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  2. SET time_zone = "+00:00";
  3. /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
  4. /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
  5. /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
  6. /*!40101 SET NAMES utf8 */;
  7. --
  8. -- Database: `$DATABASENAME`
  9. --
  10. CREATE DATABASE IF NOT EXISTS `$DATABASENAME` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
  11. USE `$DATABASENAME`;
  12. -- --------------------------------------------------------
  13. --
  14. -- Table structure for table `issues`
  15. --
  16. DROP TABLE IF EXISTS `issues`;
  17. CREATE TABLE IF NOT EXISTS `issues` (
  18. `id` int(100) NOT NULL AUTO_INCREMENT,
  19. `u_id` int(100) NOT NULL,
  20. `s_id` int(100) DEFAULT NULL,
  21. `title` varchar(100) NOT NULL,
  22. `description` text NOT NULL,
  23. PRIMARY KEY (`id`),
  24. KEY `u_id` (`u_id`),
  25. KEY `u_id_2` (`u_id`),
  26. KEY `s_id` (`s_id`)
  27. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
  28. --
  29. -- RELATIONS FOR TABLE `issues`:
  30. -- `s_id`
  31. -- `scrums` -> `id`
  32. -- `u_id`
  33. -- `users` -> `id`
  34. --
  35. -- --------------------------------------------------------
  36. --
  37. -- Table structure for table `messages`
  38. --
  39. DROP TABLE IF EXISTS `messages`;
  40. CREATE TABLE IF NOT EXISTS `messages` (
  41. `id` int(100) NOT NULL AUTO_INCREMENT,
  42. `from_id` int(100) NOT NULL,
  43. `to_id` int(100) DEFAULT NULL,
  44. `s_id` int(100) DEFAULT NULL,
  45. `i_id` int(100) DEFAULT NULL,
  46. `message` text NOT NULL,
  47. PRIMARY KEY (`id`),
  48. KEY `from_id` (`from_id`,`to_id`,`s_id`,`i_id`),
  49. KEY `to_id` (`to_id`),
  50. KEY `s_id` (`s_id`),
  51. KEY `i_id` (`i_id`)
  52. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
  53. --
  54. -- RELATIONS FOR TABLE `messages`:
  55. -- `i_id`
  56. -- `issues` -> `id`
  57. -- `from_id`
  58. -- `users` -> `id`
  59. -- `to_id`
  60. -- `users` -> `id`
  61. -- `s_id`
  62. -- `scrums` -> `id`
  63. --
  64. -- --------------------------------------------------------
  65. --
  66. -- Table structure for table `scrums`
  67. --
  68. DROP TABLE IF EXISTS `scrums`;
  69. CREATE TABLE IF NOT EXISTS `scrums` (
  70. `id` int(100) NOT NULL AUTO_INCREMENT,
  71. `u_id` int(100) NOT NULL,
  72. `title` varchar(100) NOT NULL,
  73. `description` text NOT NULL,
  74. PRIMARY KEY (`id`),
  75. KEY `u_id` (`u_id`)
  76. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
  77. --
  78. -- RELATIONS FOR TABLE `scrums`:
  79. -- `u_id`
  80. -- `users` -> `id`
  81. --
  82. -- --------------------------------------------------------
  83. --
  84. -- Table structure for table `users`
  85. --
  86. DROP TABLE IF EXISTS `users`;
  87. CREATE TABLE IF NOT EXISTS `users` (
  88. `id` int(11) NOT NULL AUTO_INCREMENT,
  89. `name` varchar(50) NOT NULL,
  90. `email` varchar(254) NOT NULL,
  91. `password` varchar(50) NOT NULL,
  92. `hash` varchar(50) NOT NULL,
  93. `salt` varchar(20) NOT NULL,
  94. PRIMARY KEY (`id`),
  95. UNIQUE KEY `name` (`name`)
  96. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
  97. --
  98. -- Constraints for dumped tables
  99. --
  100. --
  101. -- Constraints for table `issues`
  102. --
  103. ALTER TABLE `issues`
  104. ADD CONSTRAINT `issues_ibfk_2` FOREIGN KEY (`s_id`) REFERENCES `scrums` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  105. ADD CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`u_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
  106. --
  107. -- Constraints for table `messages`
  108. --
  109. ALTER TABLE `messages`
  110. ADD CONSTRAINT `messages_ibfk_4` FOREIGN KEY (`i_id`) REFERENCES `issues` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  111. ADD CONSTRAINT `messages_ibfk_1` FOREIGN KEY (`from_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  112. ADD CONSTRAINT `messages_ibfk_2` FOREIGN KEY (`to_id`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE SET NULL,
  113. ADD CONSTRAINT `messages_ibfk_3` FOREIGN KEY (`s_id`) REFERENCES `scrums` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
  114. --
  115. -- Constraints for table `scrums`
  116. --
  117. ALTER TABLE `scrums`
  118. ADD CONSTRAINT `scrums_ibfk_1` FOREIGN KEY (`u_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
  119. /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  120. /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
  121. /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;