scholrly / neo4django

Drop-in Neo4j/Django integration.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Migrate from neo_auth to graph_auth

pirhoo opened this issue · comments

Hello,

I'm trying to migrate a database that was using the old User model (with neo_auth app label). I took care to update the model definition directly into neo4j by changing the app_label 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

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.

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.

@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.

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

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.

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!

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//issues/222#issuecomment-26920162
.