我正在将 bugzilla 安装迁移到 redmine。
在 bugzilla 中,总是针对导致问题出现的软件版本记录错误。
由于 redmine 支持路线图,我想做一些迁移的事情。我想做的第一部分是将所有当前版本设置移至新的自定义“源版本”字段。
我尝试创建一个名为“源版本”的新自定义字段并手动更改一些错误报告以使用该字段。一些有限的测试表明,为该字段指定的每个值都会在custom_values
表中获得一个新条目。下面显示了三个错误,其中两个具有相同的自定义版本值 1.2060:
--------------
SELECT * FROM custom_values WHERE custom_field_id=4
--------------
+------+-----------------+---------------+-----------------+--------+
| id | customized_type | customized_id | custom_field_id | value |
+------+-----------------+---------------+-----------------+--------+
| 4821 | Issue | 765 | 4 | 1.1098 |
| 4822 | Issue | 802 | 4 | 1.2060 |
| 4823 | Issue | 801 | 4 | 1.2060 |
+------+-----------------+---------------+-----------------+--------+
... custom_field_id 与我添加的新“源版本”字段相关。
因此,我认为要填充表格,我需要为需要从当前版本复制的每个问题创建一个新条目。
如果有帮助,版本表具有以下结构:
--------------
SHOW COLUMNS FROM versions
--------------
+-----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| project_id | int(11) | NO | MUL | 0 | |
| name | varchar(255) | NO | | | |
| description | varchar(255) | YES | | | |
| effective_date | date | YES | | NULL | |
| created_on | datetime | YES | | NULL | |
| updated_on | datetime | YES | | NULL | |
| wiki_page_title | varchar(255) | YES | | NULL | |
| status | varchar(255) | YES | | open | |
| sharing | varchar(255) | NO | MUL | none | |
+-----------------+--------------+------+-----+---------+----------------+
...并且问题表具有以下结构:
--------------
SHOW COLUMNS FROM issues
--------------
+------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| tracker_id | int(11) | NO | MUL | 0 | |
| project_id | int(11) | NO | MUL | 0 | |
| 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 | 0 | |
| assigned_to_id | int(11) | YES | MUL | NULL | |
| priority_id | int(11) | NO | MUL | 0 | |
| fixed_version_id | int(11) | YES | MUL | NULL | |
| author_id | int(11) | NO | MUL | 0 | |
| 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 | |
+------------------+--------------+------+-----+---------+----------------+
问题是,我需要执行什么神奇的 SQL 查询才能将版本复制到新字段并进行清理?我从来都不是 SQL 高手,因此我将不胜感激地收到任何帮助!
编辑- 我尝试了以下方法:
INSERT INTO custom_values
(Issue, issues.id, 4, versions.name)
SELECT * FROM issues INNER JOIN versions ON issues.fixed_version_id=versions.id;
...但它给了我一个错误:
--------------
INSERT INTO custom_values (Issue, issues.id, 4, versions.name) SELECT * FROM issues INNER JOIN versions ON issues.fixed_version_id=versions.id
--------------
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '4, versions.name) SELECT * FROM issues INNER JOIN versions ON issues.fixed_version_id=ve' at line 1