Warning: You already have nodes for this relation. This change will result in data loss


#1

I have a project on production.
I’m migrating my Docker images versions:

  • Prisma v1.19 to v1.34
  • Postgres v10.5 to v10.3

I already had data in the DB and it persisted during the image change. Everything works fine on the application side.

The problem now is that when I run prisma deploy, I get warnings saying that forcing would result in data loss.
The only thing I changed on the schema is all fields id: ID! @unique to id: ID! @id.

How can I fix this?

Warnings

FooToBar
    ! You already have nodes for this relation. This change will result in data loss.

  Global
    ! You are migrating from the old datamodel syntax to the new one. Make sure that you understand the listed changes because the semantics are different now. Then perform the deployment with the `--force` flag.

#2

I had the same issue, I believe it’s because in 1.34, LINEAR relations are now the default, instead of TABLE relations. So when you update your service, the relationship tables would get deleted and your relations would be lost.

To prevent this, add link: TABLE inside your @relation parameters

More info: https://www.prisma.io/docs/datamodel-and-migrations/datamodel-MYSQL-knul/#relation-table