laravel-nestedset
laravel-nestedset copied to clipboard
[Question] Can I simply just manually edit parent_id and then fixTree()?
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()?
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.