1
0

scrum.sql 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. Navicat MySQL Data Transfer
  3. Source Server : localhost
  4. Source Server Version : 50709
  5. Source Host : localhost:3306
  6. Source Database : scrum
  7. Target Server Type : MYSQL
  8. Target Server Version : 50709
  9. File Encoding : 65001
  10. Date: 2016-03-11 20:19:15
  11. */
  12. SET FOREIGN_KEY_CHECKS=0;
  13. -- ----------------------------
  14. -- Table structure for `log`
  15. -- ----------------------------
  16. DROP TABLE IF EXISTS `log`;
  17. CREATE TABLE `log` (
  18. `id` int(12) NOT NULL AUTO_INCREMENT COMMENT '日志ID',
  19. `task_id` int(8) NOT NULL COMMENT '任务ID',
  20. `task_name` varchar(100) NOT NULL COMMENT '任务名称',
  21. `info` varchar(500) DEFAULT NULL COMMENT '日志内容',
  22. `time` datetime NOT NULL COMMENT '变化时间',
  23. `author` int(8) NOT NULL COMMENT '修改人',
  24. PRIMARY KEY (`id`)
  25. ) ENGINE=MyISAM AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;
  26. -- ----------------------------
  27. -- Records of log
  28. -- ----------------------------
  29. -- ----------------------------
  30. -- Table structure for `member`
  31. -- ----------------------------
  32. DROP TABLE IF EXISTS `member`;
  33. CREATE TABLE `member` (
  34. `id` int(8) NOT NULL AUTO_INCREMENT COMMENT '人员ID',
  35. `name` varchar(10) NOT NULL COMMENT '人员名称',
  36. `remark` varchar(200) NOT NULL COMMENT '人员备注',
  37. `mail` varchar(20) NOT NULL COMMENT '人员邮箱',
  38. `status` tinyint(2) NOT NULL COMMENT '人员状态',
  39. PRIMARY KEY (`id`)
  40. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  41. -- ----------------------------
  42. -- Records of member
  43. -- ----------------------------
  44. -- ----------------------------
  45. -- Table structure for `program`
  46. -- ----------------------------
  47. DROP TABLE IF EXISTS `program`;
  48. CREATE TABLE `program` (
  49. `id` int(8) NOT NULL AUTO_INCREMENT COMMENT '项目ID',
  50. `name` varchar(100) NOT NULL COMMENT '项目名称',
  51. `status` tinyint(2) NOT NULL COMMENT '项目状态',
  52. `member_id` int(8) NOT NULL COMMENT '创建者ID',
  53. PRIMARY KEY (`id`)
  54. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  55. -- ----------------------------
  56. -- Records of program
  57. -- ----------------------------
  58. -- ----------------------------
  59. -- Table structure for `task`
  60. -- ----------------------------
  61. DROP TABLE IF EXISTS `task`;
  62. CREATE TABLE `task` (
  63. `id` int(8) NOT NULL AUTO_INCREMENT COMMENT '任务ID',
  64. `name` varchar(100) NOT NULL COMMENT '任务名称',
  65. `deadline` datetime NOT NULL COMMENT '任务deadline',
  66. `remark` varchar(200) DEFAULT NULL COMMENT '任务说明',
  67. `status` tinyint(2) NOT NULL COMMENT '任务状态',
  68. `member_id` int(8) NOT NULL COMMENT '归属人员',
  69. `program_id` int(8) NOT NULL COMMENT '归属项目',
  70. `author_id` int(8) NOT NULL COMMENT '任务作者/修改者',
  71. PRIMARY KEY (`id`),
  72. KEY `member_id` (`member_id`)
  73. ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
  74. -- ----------------------------
  75. -- Records of task
  76. -- ----------------------------
  77. INSERT INTO `task` VALUES ('1', '名字', '2016-03-16 00:00:13', '备注', '2', '5', '1', '5');
  78. DROP TRIGGER IF EXISTS `loging`;
  79. DELIMITER ;;
  80. CREATE TRIGGER `loging` AFTER UPDATE ON `task` FOR EACH ROW BEGIN
  81. IF NEW.name != OLD.name
  82. THEN
  83. INSERT INTO log(
  84. task_id,
  85. task_name,
  86. info,
  87. time,
  88. author)
  89. values(
  90. NEW.id,
  91. NEW.name,
  92. concat('任务名称变更:' , OLD.name , '→' , NEW.name),
  93. NOW(),
  94. NEW.author_id);
  95. END IF;
  96. IF NEW.deadline != OLD.deadline
  97. THEN
  98. INSERT INTO log(
  99. task_id,
  100. task_name,
  101. info,
  102. time,
  103. author)
  104. values(
  105. NEW.id,
  106. NEW.name,
  107. concat('任务时间变更:' , OLD.deadline , '→' , NEW.deadline),
  108. NOW(),
  109. NEW.author_id);
  110. END IF;
  111. IF NEW.status != OLD.status
  112. THEN
  113. INSERT INTO log(
  114. task_id,
  115. task_name,
  116. info,
  117. time,
  118. author)
  119. values(
  120. NEW.id,
  121. NEW.name,
  122. concat('任务状态变更:' , OLD.status , '→' , NEW.status),
  123. NOW(),
  124. NEW.author_id);
  125. END IF;
  126. IF NEW.member_id != OLD.member_id
  127. THEN
  128. INSERT INTO log(
  129. task_id,
  130. task_name,
  131. info,
  132. time,
  133. author)
  134. values(
  135. NEW.id,
  136. NEW.name,
  137. concat('任务成员变更:' , OLD.member_id , '→' , NEW.member_id),
  138. NOW(),
  139. NEW.author_id);
  140. END IF;
  141. END
  142. ;;
  143. DELIMITER ;