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数据操作语句=>常 ...
随机推荐
- response contentType
response.setContentType(MIME)的作用是使客户端浏览器,区分不同种类的数据,并根据不同的MIME调用浏览器内不同的程序嵌入模块来处理相应的数据. 例如web浏览器就是通过MI ...
- Codeforces 2014-2015 ACM-ICPC, NEERC, Southern Subregional Contest L. Useful Roads
L. Useful Roads time limit per test:4 seconds memory limit per test:512 megabytes input:standard inp ...
- 51Nod 1001 数组中和等于K的数对 And 1015 水仙花数
1001 数组中和等于K的数对 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 给出一个整数K和一个无序数组A,A的元素为N个互不相同的整数,找出数组A中所有和等于K ...
- sql partition by
--不分班按学生成绩排名 select *,ROW_NUMBER() over(order by Score desc) as Sequence from Student id Gr ...
- Maven 集成Tomcat7插件自动部署
1.配置tomcat-users.xml文件 在tomcat安装目录下找到tomcat-users.xml文件.该文件路径为[tomcat安装根目录]/conf/ 修改文件内容,增加下列内容:(一般配 ...
- android程序入口
android程序的真正入口是Application类的onCreate方法
- [Machine Learning with Python] Data Preparation through Transformation Pipeline
In the former article "Data Preparation by Pandas and Scikit-Learn", we discussed about a ...
- servlet与线程与jdbc connection的关系
servlet与线程与jdbc connection的关系 都是一一绑定的关系, servlet接受那么多此请求. 一个请求,对应一个线程,对应一个DB POOL的connection. 因为conn ...
- 【spring boot logback】日志logback格式解析
日志logback格式解析 logback官网 格式解析 https://logback.qos.ch/manual/layouts.html#ClassicPatternLayout 官网格式解析有 ...
- The web application [/struts2_0100] created a ThreadLocal with key of type
引用: 严重: The web application [/struts2_0100] created a ThreadLocal with key of type [com.opensymphony ...