我怎样才能从迁移Bugzilla的版本到一个新的自定义的“源代码版本”字段的管理平台(什么SQL语法

2019-09-19 14:17发布

我在过迁移Bugzilla的安装管理平台的过程。

在Bugzilla的错误总是记录对造成被提出的问题的软件版本。

由于管理平台支持路线图,我想要做的几件事情要迁移。 我想要做的第一部分是超过移动所有当前版本的设置到一个新的自定义的“源代码版本”字段。

我试图使被称为“源版本”的新的自定义字段并手动更改了几个bug报告使用该领域。 一些有限的测试表明,该字段指定的每个值获得的一个新的条目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

Answer 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。

但我会备份数据库反正... :-)



文章来源: How can I migrate versions from bugzilla into a new custom 'source version' field in redmine (what SQL syntax do I need)?