Patch #6035

Migration from redmine_subtasks to core subtasking feature

Added by Federico Ramallo about 7 years ago. Updated over 4 years ago.

Status:ClosedStart date:2010-08-05
Priority:NormalDue date:
Assignee:-% Done:


Target version:-


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

subtasking.patch Magnifier (1.54 KB) Federico Ramallo, 2010-08-05 04:51

subtasking_1.patch Magnifier (1.56 KB) Ådne Hovda, 2010-08-10 10:52

subtasking_2.patch Magnifier (1.66 KB) Yoichi Izumi, 2010-10-09 06:39

Related issues

Duplicated by Redmine - Defect #7078: Migration from redmine_subtasks plugin Closed 2010-12-08


#1 Updated by Felix Schäfer about 7 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?

#2 Updated by Eric Davis about 7 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.

#3 Updated by Ådne Hovda about 7 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.

#4 Updated by Rahul Vaidya about 7 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.

#5 Updated by Yoichi Izumi about 7 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)

#6 Updated by Federico Ramallo about 7 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.

#7 Updated by Yoichi Izumi about 7 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)
      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.

#8 Updated by Yoichi Izumi about 7 years ago

Solved above problem. Ordering issues by hierarchy from root to leaf.
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 ORDER BY count(").each do |issue|

#9 Updated by Anton Nepomnyaschih about 7 years ago

We used 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?

#10 Updated by Jean-Baptiste Barth over 4 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.

Also available in: Atom PDF