Patch #6035
Migration from redmine_subtasks to core subtasking feature
| Status: | Closed | Start date: | 2010-08-05 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | - | % Done: | 0% | |
| Category: | Documentation | |||
| Target version: | - |
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
Related issues
History
#1 Updated by Felix Schäfer almost 3 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 almost 3 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 almost 3 years ago
- File subtasking_1.patch
added
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 over 2 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 over 2 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 over 2 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 over 2 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 hasparent_id=2 androot_idnil - record with
id=2 not updated yet (so, itsroot_idcolumn 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.
#8 Updated by Yoichi Izumi over 2 years ago
- File subtasking_2.patch
added
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|
#9 Updated by Anton Nepomnyaschih over 2 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?
#10 Updated by Jean-Baptiste Barth 16 days 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.