Вашето запитване
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.
Но все пак бих архивирал базата данни... :-)