Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DevMode generates invalid schema: Invalid schema change (UPLOAD): destructive schema change #7253

Closed
sipersso opened this issue May 12, 2021 · 10 comments
Assignees

Comments

@sipersso
Copy link

sipersso commented May 12, 2021

Goals

Create a synced schema based on a current local realm schema. The schema contains relationships

Expected Results

When running MongoDb Realm in devmode, the schema should be generated correctly.

Actual Results

Sync fails since it says that it is an invalid schema change.

"Sync: Connection[2]: Session[2]: Received: ERROR "Invalid schema change (UPLOAD): destructive schema change: cannot change field "deletedPropertyName" in table "AnObject" from "string" to a relationship" (error_code=225, try_again=0)"

It looks like all relationships in the generated schema is of type "string" instead of relationship and this will cause sync to fail even though I am running the app in dev mode with the goal of generating a schema

Steps for others to Reproduce

1: Create an realm schema containing a relationship
2: Run MongoDb Realm in devmode

Version of Realm and Tooling

Realm framework version: 10.7.5

@sipersso sipersso changed the title Migration from local to synced realm: Invalid schema change (UPLOAD): destructive schema change DevMode generates invalid schema: Invalid schema change (UPLOAD): destructive schema change May 12, 2021
@sipersso
Copy link
Author

sipersso commented May 12, 2021

Invalid issue. I am closing this. The issue is that the "relationship" in the local database becomes a "string" in the generated schema.

EDIT: Turned out this is an issue after all. Updating the description

@sipersso
Copy link
Author

Looks like all relationships in my old schema gets converted to strings in MongoDb Realm. Why is this? According to the docs here https://docs.mongodb.com/realm/sdk/react-native/fundamentals/relationships-and-embedded-objects/ it should be possible to use relationships in MongoDb Realm. The way it works now is unintuitive. Do I need to change the schema manually?

@sipersso sipersso reopened this May 12, 2021
@sipersso
Copy link
Author

sipersso commented May 14, 2021

I think I figured out what is happening here. All "relationships" in embedded objects are automatically changed from a relationship to a string in the Atlas schema when using devmode. This makes sync fail with "Invalid schema change (UPLOAD): destructive schema change". I assume this is a bug? That the relationship that exists in the models should generate a relationship in Atlas as well?

Models I used are the same as the ones I posed in the sample for #7145 and #7248

@sipersso
Copy link
Author

More weirdness. The schema in atlas actually contains all the relationships, but the generated swift classes have converted all relationships in EmbeddedObject classes to plain strings. Not sure what is going on here.

@dianaafanador3
Copy link
Contributor

Hi @sipersso Can you please share your Atlas schema definition, so I can help you with this issue?

@sipersso
Copy link
Author

@dianaafanador3 I am not able to share it here, but I have uploaded it to the support portal (ticket 00771573) and asked them to forward it to you and added contact details if you need any more input.

@dianaafanador3
Copy link
Contributor

Hello @sipersso , I got everything I needed for testing it out, I'll let you know if I'm able to solve this as soon as possible.

@sipersso
Copy link
Author

Hmm... I actually managed to remove the property that caused the invalid schema. It was not necessary to have this in the sync schema and now the sync has actually started working. I am still not sure why this has started working, but it does.

@leemaguire
Copy link
Contributor

Hi @sipersso given your last comment, are you ok to now close this issue?

@sipersso
Copy link
Author

Yes, I have verified that the sync work after turning dev mode off. Closing the issue.

@sync-by-unito sync-by-unito bot changed the title DevMode generates invalid schema: Invalid schema change (UPLOAD): destructive schema change DevMode generates invalid schema: Invalid schema change (UPLOAD): destructive schema change Feb 16, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants