doctrine / DoctrinePHPCRBundle

This bundle integrates Doctrine PHPCR ODM and PHPCR backends into Symfony
http://phpcr.github.com
MIT License
156 stars 66 forks source link

Command to recompute references #388

Closed mamazu closed 11 months ago

mamazu commented 11 months ago

Usecase

If you manage to get the database into a state where the references are not in sync with the reference data, then there is currently no way to easily fix that.

In our case we have merged two phpcr instances and to avoid conflicting Ids we incremented the second system's ids all by 10'000. This however means that all the references into the second structures are broken and need to be recalculated.

Proposed solution

It would be cool if there was a command that would scan the whole database for references and re-compute them.

dbu commented 11 months ago

the strict phpcr way would be to export one repository and import it into the other. but i would not be sure if that process is 100% robust.

either way, the command is an interesting idea. i think this would belong into https://github.com/jackalope/jackalope-doctrine-dbal as that functionality is about the dbal implementation of storage.

i have no capacity to work on that, but if you want to give it a go i would be happy to review a merge request.

mamazu commented 11 months ago

Yeah duh, we should have used the import and export feature. And dealt with the duplicated entries in the two repositories manually. If you want I can have a look at how to implement it, but I think it's not going to be very efficient. I've already implemented a very limited version for our use case.

dbu commented 11 months ago

if it tempts you to look into it, happy to review. but i don't see it as a high priority, we can also leave it be imo :-)

mamazu commented 11 months ago

I have a possibly bad implementation that I could PR. It's taped onto it, because there isn't really a good way to extract the reference updating from the client without creating a BC break.

dbu commented 11 months ago

maybe post it as a gist or blogpost then? if we integrate it into jackalope, it should be a good implementation that we won't regret... which sounds like its not worth the effort. with a gist or blogpost, its at least possible to still find it, but its fine to say its not a clean implementation (and we won't have to maintain it)

mamazu commented 11 months ago

That sounds like a good idea. I will do that.

dbu commented 11 months ago

great. please comment on this issue, would love to read it - and if others ask about it i can then find it again.

mamazu commented 11 months ago

Here you go: https://gist.github.com/mamazu/d09d02ea464eda71ae6b3bb389044abf