Project

General

Profile

Actions

Patch #6035

closed

Migration from redmine_subtasks to core subtasking feature

Added by Federico Ramallo over 13 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Documentation
Target version:
-
Start date:
2010-08-05
Due date:
% Done:

0%

Estimated time:

Description

If you use redmine_subtask plugin and are migrating from 0.9.4 to 1.0.0RC the plugin is not working anymore since the same feature is built in the core.

I added this patch to fix the migration and keep the parent relations


Files

subtasking.patch (1.54 KB) subtasking.patch Federico Ramallo, 2010-08-05 04:51
subtasking_1.patch (1.56 KB) subtasking_1.patch Ådne Hovda, 2010-08-10 10:52
subtasking_2.patch (1.66 KB) subtasking_2.patch Yoichi Izumi, 2010-10-09 06:39

Related issues

Has duplicate Redmine - Defect #7078: Migration from redmine_subtasks pluginClosed2010-12-08

Actions
Actions #1

Updated by Felix Schäfer over 13 years ago

Thanks for the contribution, though sending it to the author of the plugin would have been better :-)

Eric, Holger: Maybe we could include that into the upgrade docs as an untested and unsupported patch/workaround?

Actions #2

Updated by Eric Davis over 13 years ago

  • Category set to Documentation

Felix Schäfer wrote:

Eric, Holger: Maybe we could include that into the upgrade docs as an untested and unsupported patch/workaround?

Probably a good idea since the core's subtasks don't include an upgrade path from the plugin.

Actions #3

Updated by Ådne Hovda over 13 years ago

If you have several levels of subtasks the current patch may fail. Ordering the issues by parent_id solved it for me. Updated patch attached.

Actions #4

Updated by Rahul Vaidya over 13 years ago

I have several levels of subtasks, but subtasking_1.patch failed while the original subtasking.patch worked successfully.

Thanks for the patches!

SQLite3::SQLException: near ",": syntax error: UPDATE "issues" SET root_id = , lft = 1056, rgt = 1057 WHERE (id = 181)

when trying to run the "issue.update_attribute(:parent_issue_id, issue.parent_id)" line.

Actions #5

Updated by Yoichi Izumi over 13 years ago

Delightful, but both patches failed.
It seems that a more complex condition is needed in my case.

subtasking.patch (no order specified):

Mysql::Error: 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 ' lft = 162, rgt = 163 WHERE (id = 67)' at line 1: UPDATE `issues` SET root_id = , lft = 162, rgt = 163 WHERE (id = 67)

id parent_id
67 68
68 66
69 68

(id=66 has no parent)

subtasking_1.patch (:order => "parent_id"):

...near ' lft = 290, rgt = 291 WHERE (id = 4)' at line 1: UPDATE `issues` SET root_id = , lft = 290, rgt = 291 WHERE (id = 4)

id parent_id
4 2
2 3

(id=3 has no parent)

Actions #6

Updated by Federico Ramallo over 13 years ago

looks like you have to clean your issues table.
Seems you have a record with id null.
Is that possible?

Of course you should test this in a sandbox environment.

Actions #7

Updated by Yoichi Izumi over 13 years ago

Thanks Federico, but it is not my point.
(There's no record with id null)

When updating root_id of id=4,

  • record with id=4 has parent_id=2 and root_id nil
  • record with id=2 not updated yet (so, its root_id column is nil)

In issues.update_nested_set_attributes...

  def update_nested_set_attributes
    if root_id.nil?
      # issue was just created
      self.root_id = (@parent_issue.nil? ? id : @parent_issue.root_id)
      set_default_left_and_right
      Issue.update_all("root_id = #{root_id}, lft = #{lft}, rgt = #{rgt}", ["id = ?", id])
      ...

root_id set to nil (@parent_issue.root_id).
Then error occurs.

I'm at a loss what to do though I want to update the migration script.

Actions #8

Updated by Yoichi Izumi over 13 years ago

Solved above problem. Ordering issues by hierarchy from root to leaf.
(ref. http://www.ibase.ru/devinfo/DBMSTrees/sqltrees.html)
Updated patch attached.

< +      Issue.find(:all,:conditions=>"parent_id IS NOT NULL",:order => "parent_id").each do |issue|
---
> +      Issue.find_by_sql("SELECT t1.* FROM issues t1 LEFT JOIN issues t2 ON t1.lft BETWEEN t2.lft AND t2.rgt WHERE t1.parent_id is not null GROUP BY t1.id ORDER BY count(t2.id)").each do |issue|
Actions #9

Updated by Anton Nepomnyaschih over 13 years ago

We used http://www.redmine.org/attachments/2490/redmine_subissues.zip and try to apply subtasking_2.patch. But we don't have "lft" and "rgt" columns in "issues" table. So, the migration doesn't work :(

Can anybody tell me what to do?.. Can I just add the columns manually and set lft = 1 rgt = 2?

Actions #10

Updated by Jean-Baptiste Barth almost 11 years ago

  • Status changed from New to Closed

I close this issue since there was no activity for the last 2 years. I think anybody who needed to upgrade from 0.9.x has finished now. There was a lot of help tickets on the forum at the time, so people in need of this information will just find these threads or this issue easily. Thanks.

Actions

Also available in: Atom PDF