etrepat / baum

Baum is an implementation of the Nested Set pattern for Laravel's Eloquent ORM.
http://etrepat.com/baum
MIT License
2.24k stars 459 forks source link

I messed up the left and right columns data accidentally #273

Open charanjeet5ingh opened 7 years ago

charanjeet5ingh commented 7 years ago

I messed up the left and right columns data accidentally and i have no database backup with me can i get it back or not?

nhuebnereagle commented 7 years ago

Try this: YourModel::rebuild()

As long as your children are associated by parent_id to their parent, this will rebuild your lft/rgt.

If you manually adjusted your lft/rgt using some kind of Sort Re-order, you'll be stuck re-ordering after you rebuild.

Just throw the YourModel::rebuild() in your controller and let it hit once, it will rebuild your lft/rgt

nhuebnereagle commented 7 years ago

Don't forget to take YourModel::rebuild() out of the controller after it's rebuilt. I've used this when manually adding test records to the database, it works good.

rayer91 commented 5 years ago

Thanks, you save my day. That command fixed lots of bug in my project :) :+1:

Try this: YourModel::rebuild()

As long as your children are associated by parent_id to their parent, this will rebuild your lft/rgt.

If you manually adjusted your lft/rgt using some kind of Sort Re-order, you'll be stuck re-ordering after you rebuild.

Just throw the YourModel::rebuild() in your controller and let it hit once, it will rebuild your lft/rgt