1

我需要你的善意支持。

我的 redmine 中有一个大项目,里面有很多子项目。超过 300 个问题已从该项目错误地转移到另一个子项目。而且我没有机会直接从redmine用手将它救出来。但是我有一个数据库转储,它在这次事故之前已经完成。所以,我的问题是 - 我可以将来自正确数据库的表“问题”与损坏的数据库进行比较并将问题移回吗?或者可能有任何工具或方法可以将问题移回正确的项目?Redmine 版本是 2.0.4。数据库:PostgreSQL。

先感谢您。

4

1 回答 1

0

方案一: 您可以尝试分析表格issues并找出所有错误移动的问题。您知道新的 project_id,并且您知道更改的大致时间戳。并编写 sql 查询(或使用 rails 控制台)来撤消操作。例如(代码未测试!)

new_project_id = Project.find(ID).id # note that ID is project identificator not id of record!
timestamp = DateTime.parse('2013-10-30 12:20:45')
issues = Issue.where(project_id: new_project_id).where('updated_at > ? AND updated_at < ?', timestamp - 1.minute, timestamp + 1.minute)
# check that all selected issues must be updated!!!
issues.update_all(project_id: old_project_id) # note that old_project_id is correct id (integer value) of record in DB

计划 b: 您可以在正确的数据库中找到所有具有 project_id 的 issue_id。然后应用 SQL 查询更新项目 ID 以纠正where id IN (issue_ids) 损坏数据库上所有问题的值

# load correct DATABASE and start rails console
project = Project.find(OLD_ID) # note that OLD_ID is project identificator not id of record!
issue_ids = project.issue_ids
# save somewhere issue_ids
# load corrupted database and start rails console
issue_ids = [saved_array_of_ids_from_previous_step]
Issue.where(id: issue_ids).update_all(project_id: correct_project_id) # note that correct_project_id is correct id (integer value) of record in DB
于 2013-10-30T14:56:49.847 回答