Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide migrating document class on DocumentManager too #420

Open
dbu opened this issue Feb 14, 2014 · 4 comments
Open

provide migrating document class on DocumentManager too #420

dbu opened this issue Feb 14, 2014 · 4 comments
Labels

Comments

@dbu
Copy link
Member

dbu commented Feb 14, 2014

there is now a command to migrate a document from one class to an other, but this would be useful functionality through code as well.

https://github.com/doctrine/phpcr-odm/blob/master/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/DocumentMigrateClassCommand.php

@dantleech
Copy link
Contributor

I think also a more generic $dm->replace($fooDocument, $barDocument) feature. This is valid behavior in PHPCR I think (when nodeType constraints are satisfied), so by extension I think maybe we should support it in ODM,

@dbu
Copy link
Member Author

dbu commented Feb 14, 2014

i agree. we had endless discussions in #262 about automatically merging / replacing documents.

for an explicit replace operation, there are already many options: either replace just the document itself but keep children of the old document, or only keep the new children (so if the new has no children, remove all old children), or merge children and take the new or the old child in case of a conflict (and then how to merge the children of children?).

when we flush a whole model tree, this is not explicit, and even more tricky. maybe we should say that then a replace can't happen, that it always has to be explicit...

@dantleech
Copy link
Contributor

Hmm. I think if you are going to remove the node and its children, then you may as well do $dm->remove($oldDoc); $dm->persist($newDoc). On the otherhand there is no clean way to replace / migrate a document at a specified path.

@dbu
Copy link
Member Author

dbu commented Jul 11, 2014

the problem with remove & persist new is that all children of the old document are removed as well. when this is intended, it can make sense to do this (though you noticed that it does not work in the same flush i think)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants