redmine 自己定义字段mysql表结构
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表字段的限制。
redmine 自己定义字段mysql表结构的更多相关文章
- [转载]github在线更改mysql表结构工具gh-ost
GitHub正式宣布以开源的方式发布gh-ost:GitHub的MySQL无触发器在线更改表定义工具! gh-ost是GitHub最近几个月开发出来的,目的是解决一个经常碰到的问题:不断变化的产品需求 ...
- 查看mysql表结构和表创建语句的方法(转)
查看mysql表结构的方法有三种:1.desc tablename;例如:要查看jos_modules表结构的命令:desc jos_modules;查看结果:mysql> desc jos_m ...
- mysql:恢复mysql表结构
mysql,frm格式恢复mysql表结构,以tuser.frm格式为例 新增数据库,如下,创建数据库名为ab 打开数据库,双击打开数据库 点右键新建表结构 新增表,里面只添加一个字段 ...
- MySQL表结构同步工具 mysql-schema-sync
mysql-schema-sync 是一款使用go开发的.跨平台的.绿色无依赖的 MySQL 表结构自动同步工具.用于将线上(其他环境)数据库结构变化同步到测试(本地)环境! 可以解决多人开发,每人都 ...
- SQL SERVER 自动生成 MySQL 表结构及索引 的建表SQL
SQL SERVER的表结构及索引转换为MySQL的表结构及索引,其实在很多第三方工具中有提供,比如navicat.sqlyog等,但是,在处理某些数据类型.默认值及索引转换的时候,总有些 ...
- 【转】查看mysql表结构和表创建语句的方法
转自:http://blog.csdn.net/business122/article/details/7531291 查看mysql表结构的方法有三种: 1.desc tablename; 例如: ...
- Sqoop将MySQL表结构同步到hive(text、orc)
Sqoop将MySQL表结构同步到hive sqoop create-hive-table --connect jdbc:mysql://localhost:3306/sqooptest --user ...
- Mysql表结构定义及相关语法
mysql语法及相关命令1.每个sql命令都需要使用分号来完成2.可以将一个命令写成多行3.可以通过\c来取消本行命令4.可以通过\g.exit.ctrl+c或者quit来退出当前客户端5.可以通过使 ...
- mysql 表结构及基本操作
说明在mysql语句中,sql语句总共分四种 a.DDL数据定义语句=>常用的ddl语句有(CREATE[创建],DROP[删除],ALTER[修改表结构]) b.DML数据操作语句=>常 ...
随机推荐
- kubernetes 之容器监控
[root@manager ~]# git clone https://github.com/kubernetes/heapster.git [root@manager ~]# cd heapster ...
- Codevs 1040 统计单词个数
1040 统计单词个数 2001年NOIP全国联赛提高组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 给出一个长度不超过200的 ...
- flash编程实例源代码下载
原文发布时间为:2008-08-20 -- 来源于本人的百度文章 [由搬家工具导入] http://library.sx.zj.cn/shgp/ActionScript编程实例详解.rar
- mysql启动错误1067的解决
安装后MYSQL5后,发现启动出错,有时启动正常,但加接时马上出错. 出错代码:1067 解决办法如下: 删除%windows%/my.ini 删除其它地方的my.ini 在mysql安装 ...
- Docker(七):仓库
登录 可以通过执行docker login命令来输入用户名和密码,密码和邮箱来完成注册和登录.注册成功之后,本地用户目录的.dockerfig中将保存用户的认证信息. 使用$sudo docker s ...
- 【Android】SQLite基本用法(转)
在Android开发中SQLite起着很重要的作用,网上SQLite的教程有很多很多,不过那些教程大多数都讲得不是很全面.本人总结了一些SQLite的常用的方法,借着论坛的大赛,跟大家分享分享的.一. ...
- LeetCode OJ--Palindrome Number
https://oj.leetcode.com/problems/palindrome-number/ 判断是否为回文数 取每一位存到vector中,再判断 负数不是回文数 class Solutio ...
- 导入Excel表中的数据
第一步:转换导入的文件 private void btnSelectFile_Click(object sender, EventArgs e) { OpenFileDialog ofd = new ...
- 正确地使用GIT FORK
摘自github官方网站,稍后我将抽空翻译. Fork a repo https://help.github.com/articles/fork-a-repo/ Syncing a fork http ...
- NOI模拟题5 Problem A: 开场题
Solution 注意到\(\gcd\)具有结合律: \[ \gcd(a, b, c) = \gcd(a, \gcd(b, c)) \] 因此我们从后往前, 对于每个位置\(L\), 找到每一段不同的 ...