hey prismoids, a migration question: the `@rename`...
# orm-help
p
hey prismoids, a migration question: the
@rename
directive doesn’t appear to work as I assume it does, perhaps one of you could quickly point me right. I have a data model
Copy code
type Organization {
...
  defaultPlanner: OrgUser! @relation(name: "DefaultPlanner") @unique
}
which I wish to change to
Copy code
type Organization {
...
  defaultOrgUser: OrgUser! @relation(name: "DefaultOrgUser") @unique
}
however, when I modify it as
Copy code
defaultOrgUser: OrgUser! @relation(name: "DefaultOrgUser") @unique @rename(oldName: "defaultPlanner")
I lose all the data in the field, which seems contrary to how the @rename directive is supposed to work. What am I missing?
j
I encountered the same issue this week. I ended up removing the
@relation
, running deploy, then adding the new relation. Obvious data loss, but that was fine for us
p
@Jared yargh. The data loss isn’t critical because we aren’t in production yet but… super irritating and I was hoping it was just my ignorance.
j
It could be our ignorance. I didn't dig too much into it. Perhaps others here can enlighten us.
h
the docs don't show an example with any other directives on it other than @rename. I might check if the order of the directives has an effect (i dont think it should, but if it does that needs to get documented) Make sure the rename is the only change and then remove the rename and deploy again with the new name. I wish I could be of more help
p
@Hasan I did try reordering the directives to no effect, alas. And in this case, this was the only change to the model. I have two possible causes in mind, multiple directives & the fact that this is a relational field.
j
There we have it. Not possible!
p
thanks @nuno
h
oh man! that is good to know! That limitation shows up for the postgres doc too. maybe you can do this more manually. add a field with the new name, deploy, make the relation, deploy and then manually copy all data over to new field. then delete old field and deploy --force ?