scholrly / neo4django

Drop-in Neo4j/Django integration.
GNU General Public License v3.0
357 stars 83 forks source link

Migrate from neo_auth to graph_auth #222

Closed pirhoo closed 10 years ago

pirhoo commented 10 years ago

Hello,

I'm trying to migrate a database that was using the old User model (with _neoauth app label). I took care to update the model definition directly into neo4j by changing the _applabel and name as follows:

capture du 2013-10-23 17 03 37

When I try to get the list with User.objects.all() it works as expected. But when I try to get a single node using get (i.e. User.objects.get(username='pirhoo')) it throws a not found error.

Any idea ?

All the best, Pierre

tonjo commented 10 years ago

When you change a model is a pain. Sometimes adding a single field in the model definition will cause things like yours. Try recreating the model with create, copying fields from the old one. Sometimes I had to destroy and recreate the reference node, starting with a clean db (in early developement stage).

PS: Did you see my pull request #217 that will fix the wrong model? I don't think it's related, anyway, it's an authenticate problem.

pirhoo commented 10 years ago

Thanks for the quick anwser @tonjo ! Your pull request isn't related to my problem but I also noticed that issue :) Otherwise, I'm gonna try what you suggest.

mhluongo commented 10 years ago

@Pirhoo, @tonjo's advice is good. Since indexing is done via the library- not auto-indexes- you have to go through the library to properly migrate. When Neo4j 2.0 is released this will be fixed with schema indexes.

Let us know how it goes! I'd love to share any resulting code in the migrations section of the docs.

pirhoo commented 10 years ago

@mhluongo if the problem may come from the indexes, is there a way to reset a specified index manually?

mhluongo commented 10 years ago

Definitely. Basically, you could either rename the old index or reindex its contents. The library indexes using Groovy- the relevant bits are in library.groovy, around https://github.com/scholrly/neo4django/blob/master/neo4django/gremlin/library.groovy#L186. The easiest way to force a reindex might be something like

for u in User.objects.all():
    u.save()

Renaming the index might also work, but since I can't test right now I think the above attempt would be safest.

pirhoo commented 10 years ago

Now I can get an user and login: thanks to your tips to reindex! I'm going to write a Django Command to force reindex, I will post a gist here if you are interested.

Thanks!

mhluongo commented 10 years ago

Glad we could help.

re: the command - yes please!

Matt Luongo Software Developer about.me/luongo

On Wed, Oct 23, 2013 at 12:27 PM, Pierre Romera notifications@github.comwrote:

Now I can get an user and login: thanks to your tips to reindex! I'm going to write a Django Command to force reindex, I will post a gist here if you are interested.

Thanks!

— Reply to this email directly or view it on GitHubhttps://github.com/scholrly/neo4django/issues/222#issuecomment-26920162 .

pirhoo commented 10 years ago

Hi again! Here is the command: https://gist.github.com/Pirhoo/7122246