Defect #14335

Issue.rebuild! "lft" and "rgt" are 1 and 2

Added by Morten MacFly over 4 years ago. Updated about 1 month ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Issues
Target version:-
Resolution:Wont fix Affected version:

Description

Discussion here: http://www.redmine.org/boards/2/topics/38378

I would like to see this feature, because otherwise the update from an earlier version of Redmine might be broken.


Related issues

Related to Redmine - Defect #6579: Tree hierachy being currupted on multiple submissions of ... Closed 2010-10-05

History

#1 Updated by Etienne Massip over 4 years ago

  • Status changed from New to Closed
  • Resolution set to Invalid

If I understand well what you need is to run

ruby script/rails runner 'Project.rebuild_tree!' RAILS_ENV=production

Please reopen if I'm mistaken.

#2 Updated by Morten MacFly over 4 years ago

  • Status changed from Closed to Reopened

The suggested solution works indeed for the projects database. However, the same applies to the "issues" database which has these "lft" and "rgt" fields broken, too. So I re-opened the ticket (if you don't mind).

If you have a similar fix for that able that would be PERFECT!

#3 Updated by Etienne Massip over 4 years ago

Try:

Issue.rebuild!

#4 Updated by Morten MacFly over 4 years ago

No, in this case it did not work. All Issues remain allocated with "1" for "lft" and "2" for "rgt".

BTW: I noticed a very bad side-effect. If I remove a project (not archive, but delete) a lot of issues not related to this project get lost. too. Luckily I had a backup, but this might be related to the wrong binary search tree... maybe?!

#5 Updated by Toshi MARUYAMA about 3 years ago

  • Status changed from Reopened to New
  • Resolution deleted (Invalid)

Morten MacFly wrote:

No, in this case it did not work. All Issues remain allocated with "1" for "lft" and "2" for "rgt".

It is awesome_nested_set bug.

#6 Updated by Toshi MARUYAMA about 3 years ago

  • Related to Defect #6579: Tree hierachy being currupted on multiple submissions of an issue added

#7 Updated by Toshi MARUYAMA about 3 years ago

  • Subject changed from Re-generate Binary trteree (lft and rgt) fields to Re-generate Issue Binary trteree (lft and rgt) fields

#8 Updated by Toshi MARUYAMA about 3 years ago

  • Tracker changed from Feature to Defect
  • Subject changed from Re-generate Issue Binary trteree (lft and rgt) fields to Issue.rebuild! set "lft" and "rgt" are 1 and 2

#9 Updated by Toshi MARUYAMA over 2 years ago

  • Subject changed from Issue.rebuild! set "lft" and "rgt" are 1 and 2 to Issue.rebuild! "lft" and "rgt" are 1 and 2

#10 Updated by Toshi MARUYAMA over 2 years ago

  • Status changed from New to Closed
  • Resolution set to Wont fix

We dropped awesome_nested_set gem (#18860) in Redmine 3.0.0.

I have reported this issue.
https://github.com/collectiveidea/awesome_nested_set/issues/299

#6579#note-40

It seems okay to have 1 and 2 if the issue has no hierarchy, what do you expect ?

awesome_nested_set gem rebuild! should be as following.

$ echo 'select lft, rgt from issues;' | sqlite3 db/test.sqlite3
1|2
3|4
5|6
7|8
9|10
11|12
13|14
15|16
17|18
19|20
21|22
23|24
25|26
27|28

"lft" of new created issue with awesome_nested_set 2.1.6 is "Issue.maximum(:rgt) + 1"
source:trunk/test/test_helper.rb@13839#L217

And :scope definition has terrible "moving" bug and Redmine 2.6 workarounds it.
source:tags/2.6.1/app/models/issue.rb#L1331

Redmine 3.0 rebuild_tree! "lft" and "rgt" are 1 and 2.
source:trunk/lib/redmine/nested_set/issue_nested_set.rb@14031#L178
But it has no problem.
Because "lft" of new created issue on Redmine 3.0 is "1".
source:trunk/test/test_helper.rb@13841#L217
And Redmine 3.0 does not have terrible "moving" bug.

Also available in: Atom PDF