redmine 自訂欄位mysql表結構

來源:互聯網
上載者:User

標籤:mysql   redmine   

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 limit 10;+----------+-----------------+------------------+--------------+---------------+-----------------------------+| issue_id | custom_field_id | type             | name         | default_value | value                       |+----------+-----------------+------------------+--------------+---------------+-----------------------------+|        2 |               1 | IssueCustomField | 關閉原因 | ...           | ...                         ||      121 |               1 | IssueCustomField | 關閉原因 | ...           | 移動逆襲完成          ||      122 |               1 | IssueCustomField | 關閉原因 | ...           | 暫時不做                ||      123 |               1 | IssueCustomField | 關閉原因 | ...           | 人員離職                ||      124 |               1 | IssueCustomField | 關閉原因 | ...           | 人員離職                ||      125 |               1 | IssueCustomField | 關閉原因 | ...           | 人員離職,論壇改版 ||      126 |               1 | IssueCustomField | 關閉原因 | ...           | 重新規劃                ||      127 |               1 | IssueCustomField | 關閉原因 | ...           | 暫時不涉及             ||      128 |               1 | IssueCustomField | 關閉原因 | ...           | 暫時不涉及             ||      129 |               1 | IssueCustomField | 關閉原因 | ...           | 暫時不涉及             |+----------+-----------------+------------------+--------------+---------------+-----------------------------+

通常這個表都會很大,我的系統裡面有22個自訂欄位,同時有500多個issue,每個issue最多會有22個行表示其自訂欄位的值。因此所有issue的自訂欄位的值的累計行數超過1萬行。

由此可以看出redmine的設計是用記錄行數來表示擴充欄位的值,所以可以不受mysql表欄位的限制。





redmine 自訂欄位mysql表結構

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.