如何将版本从 bugzilla 迁移到 redmine 中的新自定义'source version'字段(我需要什么 SQL 语法)?



我正在将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

您的查询

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
(customized_type, customized_id, custom_field_id, value)
SELECT 'Issue', issues.id, 4, versions.name
FROM issues INNER JOIN versions ON issues.fixed_version_id=versions.id;

以便成为有效的SQL。

但我无论如何都会备份数据库…:-)

相关内容

  • 没有找到相关文章