【问题标题】:Move back issues from other projects从其他项目移回问题
【发布时间】:2013-10-30 14:25:24
【问题描述】:

我需要你的支持。

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

提前谢谢你。

【问题讨论】:

    标签: redmine redmine-plugins


    【解决方案1】:

    计划: 您可以尝试分析表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
    

    【讨论】:

    • 非常感谢您的回答!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-12
    • 2018-03-14
    • 1970-01-01
    • 1970-01-01
    • 2019-11-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多