laravel-nestedset icon indicating copy to clipboard operation
laravel-nestedset copied to clipboard

[Question] Can I simply just manually edit parent_id and then fixTree()?

Open ryanmortier opened this issue 6 years ago • 1 comments

I have a table that isn't managed through the webapp but rather a nightly import from CSV. Therefore I wouldn't be using the append or prepend methods, etc. Aside from performance, do you see anything wrong with simply wiping the parent_id of all nodes with something like DB::table('categories')->update(['parent_id' => null]); and then importing the CSV which would manually update the parent_id and then after everything is imported running Category::fixTree()?

ryanmortier avatar Feb 06 '19 20:02 ryanmortier

I know this question is quite old, just for reference though:

I have been doing this in my application and if performance is not an issue I don't see anything wrong with this approach. Just to be safe you could also null the "_lft" and "_rgt" fields before fixing the tree.

taalas avatar Aug 17 '20 12:08 taalas