首页 技术 正文
技术 2022年11月19日
0 收藏 572 点赞 3,613 浏览 3852 个字

redmine能够创建自己定义字段,我经经常使用它来满足不同的管理需求。如今来解读一下。看看这些自己定义字段是怎样存在mysql表中的。

表issues

用来存放issue的标准字段。

mysql> describe issues;
+----------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| tracker_id | int(11) | NO | MUL | NULL | |
| project_id | int(11) | NO | MUL | NULL | |
| subject | varchar(255) | NO | | | |
| description | text | YES | | NULL | |
| due_date | date | YES | | NULL | |
| category_id | int(11) | YES | MUL | NULL | |
| status_id | int(11) | NO | MUL | NULL | |
| assigned_to_id | int(11) | YES | MUL | NULL | |
| priority_id | int(11) | NO | MUL | NULL | |
| fixed_version_id | int(11) | YES | MUL | NULL | |
| author_id | int(11) | NO | MUL | NULL | |
| lock_version | int(11) | NO | | 0 | |
| created_on | datetime | YES | MUL | NULL | |
| updated_on | datetime | YES | | NULL | |
| start_date | date | YES | | NULL | |
| done_ratio | int(11) | NO | | 0 | |
| estimated_hours | float | YES | | NULL | |
| parent_id | int(11) | YES | | NULL | |
| root_id | int(11) | YES | MUL | NULL | |
| lft | int(11) | YES | | NULL | |
| rgt | int(11) | YES | | NULL | |
| is_private | tinyint(1) | NO | | 0 | |
| closed_on | datetime | YES | | NULL | |
| position | int(11) | NO | MUL | NULL | |
| remaining_hours | float | YES | | NULL | |
| release_id | int(11) | YES | MUL | NULL | |
| story_points | float | YES | | NULL | |
| release_relationship | varchar(255) | NO | MUL | auto | |
+----------------------+--------------+------+-----+---------+----------------+

表custom_fields

该表字段都和创建自己定义字段的web页面看到的选择项非常像。

mysql> describe custom_fields;
+-----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| type | varchar(30) | NO | | | |
| name | varchar(30) | NO | | | |
| field_format | varchar(30) | NO | | | |
| possible_values | text | YES | | NULL | |
| regexp | varchar(255) | YES | | | |
| min_length | int(11) | YES | | NULL | |
| max_length | int(11) | YES | | NULL | |
| is_required | tinyint(1) | NO | | 0 | |
| is_for_all | tinyint(1) | NO | | 0 | |
| is_filter | tinyint(1) | NO | | 0 | |
| position | int(11) | YES | | 1 | |
| searchable | tinyint(1) | YES | | 0 | |
| default_value | text | YES | | NULL | |
| editable | tinyint(1) | YES | | 1 | |
| visible | tinyint(1) | NO | | 1 | |
| multiple | tinyint(1) | YES | | 0 | |
| format_store | text | YES | | NULL | |
| description | text | YES | | NULL | |
+-----------------+--------------+------+-----+---------+----------------+

表custom_values

mysql> describe custom_values;
+-----------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| customized_type | varchar(30) | NO | MUL | | |
| customized_id | int(11) | NO | | 0 | |
| custom_field_id | int(11) | NO | MUL | 0 | |
| value | text | YES | | NULL | |
+-----------------+-------------+------+-----+---------+----------------+

该表能够用custom_field_id字段和custom_fields表的id关联。

而customized_id 能够和issues表的id相关联

因此三个表issues, custom_fields和custom_values在一起表达了这么个关系。

一个issue的标准字段来自issues表,扩展字段来自custom_fields表。而custom_values和前custom_fields表关联,一起表示一个issue的某个自己定义字段的值。

而且。当表示issue的自己定义字段时,custom_fields.type的值是 ‘IssueCustomField’ 而custom_values.customized_type的值是’Issue’.

全部issue的自己定义字段值

因此能够先将custom_fields表和custom_values表关联,获得例如以下结果:

mysql> select customized_id as issue_id,custom_field_id,type,name,default_value,value from custom_fields a inner join custom_values b on a.id =b.custom_field_id and a.type = 'IssueCustomField' and b.customized_type='Issue' limit 2;
+----------+-----------------+------------------+--------------+---------------+------------+
| issue_id | custom_field_id | type | name | default_value | value |
+----------+-----------------+------------------+--------------+---------------+------------+
| 1771 | 7 | IssueCustomField | 发现日期 | | 2014-06-01 |
| 1772 | 7 | IssueCustomField | 发现日期 | | 2014-06-15 |
+----------+-----------------+------------------+--------------+---------------+------------+
2 rows in set (0.06 sec)

通常这个表都会非常大。我的系统里面有22个自己定义字段。同一时候有500多个issue,每一个issue最多会有22个行表示其自己定义字段的值。

因此全部issue的自己定义字段的值的累计行数超过1万行。

由此能够看出redmine的设计是用记录行数来表示扩展字段的值。所以能够不受mysql表字段的限制。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,076
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,552
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,400
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,176
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,812
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,894