Property of Realm Schema cannot be removed from the Backend UI ("cannot define relationship for field which does not exist in schema")

Hey everyone,

On our test environment, I noticed an inconsistency between the schema of an object on the Backend (seen in the App Services’ Schema UI) and in our Client app (iOS). On the backend, it’s an array of String, while on the client side, it’s an array of another object.
Weirdly enough, this hasn’t caused any Sync issue (?!).

Realizing I don’t need this property, I decided to simply remove it from the schema on the client side.
I turned on development mode, and ran the client app to update the schema.
Went back to the Schema (viewed from the App Services’ Schema UI), but nothing has changed.

Now, I decided to remove it manually from the Schema UI, but the following error pops up when I try to save:

Error is the following: “cannot define relationship for field which does not exist in schema”

Cryptic! Is this a bug, or am I missing something?

Thanks!

Hi @Baptiste_Malaguti,

Thanks for posting! A few things here:

I turned on development mode, and ran the client app to update the schema

Your local schema can actually be a subset of your server-side schema. So, removing the table from your local data model would not trigger the table to be removed from your server-side schema. Similarly when removing fields from a schema in your local data model. Development mode changes are additive-only

Error is the following: “cannot define relationship for field which does not exist in schema”

This likely means that you still have a relationship that references the property you’re trying to remove. From the schemas tab, there’s should be a toggle labeled “Expand relationships”, if you turn that on you’ll be able to see the relationships defined on your table, and remove the ones that you no longer need. See https://www.mongodb.com/docs/atlas/app-services/schemas/relationships for additional details.

It’s also worth noting that removing a property on a synced table is a destructive schema change, so you will be prompted to terminate + re-enable sync when trying to save this schema change. See https://www.mongodb.com/docs/atlas/app-services/sync/data-model/update-schema/#std-label-destructive-changes-synced-schema for additional details.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.