Realm-CLI trying to update schema even though no changes to it?

Hello all,

I have been playing with the realm-cli to export app and copy them to different environments etc.

One thing I find confusing is the following:

  • create a realm app in “development” mode so that a client can define the schema etc
  • use realm-cli pull --remote=“your app” to export that app to your local machine
  • now use realm-cli push --remote=“custr-sw1-mhylq”

Now given that I just exported the app, applied no changes whatsoever to it and then re-import the exact same status again, I would assume the CLI to come back to me saying “no changes detected - I got nothing to do”

It however always seems to detect that there is a schema on the server - and instead of leaving it alone it always seems to want to remove all schema objects and recreate them like so:

— data_sources/mongodb-atlas/your app/User/schema.json
+++ data_sources/mongodb-atlas/your app/User/schema.json

Naturally if you confirm the changes shown above with “Yes” realm-cli comes back with:

“push failed: destructive change not allowed: mongodb sync schema will be deleted”

so once your app is created, you can’t manage it with the realm-cli. It kind of makes it impossible to add additional objects such as functions or triggers on your local machine and push the changes - as the cli always fails because it thinks a schema (that was not touched) needs updating too.

Does anyone have any ideas what is going on?

Stay safe and cheers,
Steve

Hi Steve,

Since the app is in development mode, it’s possible that between your Pull and Push commands a client has made changes to the cloud schema which is making it conflict with the local copy of your app. When trying these steps in my project I did not get a destructive change warning.

How much time elapses between downloading a copy of the app and attempting a push? Please try taking a second export when this error occurs and compare the schema configuration between the first export and the second.

Regards
Manny

Hi Manny,

thank you for your response!

Well it is absolutely bizarre … I literally downloaded with the cli and tried to upload a few seconds later and it always complained about schema differences. I downloaded into a different folder before pushing and compared the two - both local folders were identical! I just cant get it to work. Maybe it is something wrong with my M0 cluster.

I then went on to try the same on my M10 and I couldnt get it to work either. The only thing that works for me is upload the project onto githu and then deploy changes (such as adding functions). In this case, the changes correctly get deployed without trying to update the data model …

It remains a mystery to me … I will use github deployment now as opposed to the CLI :frowning: …maybe my CLI installation is buggered up, but I am on the latest version. So - no idea!

Thank you for getting back to me!
Stephan

1 Like