You are using Blank node in an upsert query. Blank node means “create a new node” and every time you hit mutate, it will create a new node. And link with the one you are targeting.
Can you explain what you are trying to do? Feels like you wanna upsert the Student entity, but why the uid(student_uid) <Student> <_:my.org/Student/009aec0b-0068-16bb-e914-379de14d4e9a> . ?
I don’t recommend this approach. If you are relying in the XID predicate. You should never try to upsert that value.
Look, computers don’t lie. I see your query, and I see it is valid. There’s no other indication that would lead to duplication. Dgraph itself has a ton of self testing steps before shipping any feature. And it is not possible to have duplicate if your query is valid. Which means, you haven’t dropped the data correctly.
And why this UUID 009aec0b-0068-16bb-e914-379de14d4e9 is a student in the previous results and now it is a Patient?
In order to delete something you have to have a perfect aligned Schema and also the correct <dgraph.type> value. If something is wrong in the middle, it won’t delete the data.
So, please, instead of trying Drop or something. Delete all data from Dgraph manually. Deleting the whole files in the p, zw, w directories. With this you gonna start from scratch.