Can not deploy, code stuck at draft. Code deployed from CLI can not show on UI

When I deploy from CLI, the code on UI does not change. (don’t know if my latest code deployed successfully). When I changes code (on local machine) and deploy via CLI, it show all previous deploy as draft and ask me if I want to discard.
I tried to export code from UI and from CLI pull (I also tried export from old CLI version). Code between UI and CLI are different???
I can’t deploy the new code now, what should I do now?

Hi Tai,

What realm-cli version are you using?
Please run realm-cli -v in terminal to get this.

If you export the app using the UI it should show you the modern app config structure. If you’re using an old CLI version then it’s possible the export is being given in the legacy app structure.

Which structure is your local directory consistent with?

What is the exact realm-cli command you’re using to push changes?

Do you see any errors in your Deployment > History?

Regards
Manny

1 Like

Hi @Mansoor_Omar, thank you for your reply.
I tried both old and new realm versions, code in functions in CLI versions are the same and different from UI version.
The commands I used:
Old: realm-cli export ...
New: realm-cli pull

Because of the limited number of items in deployment history, I can not show you the result when I deployed successfully from CLI. I have a problem with Realm Sync since last night in deployment (I sent a support ticket)

I think exporting code and deployment fail must be 2 different issues?

Hi Tai,

The error given is related to the Realm Sync metadata stored in the __realm_sync database.

If this is not a production app, then please try terminating Sync and waiting 10 minutes before re-enabling it. This should clear out the __realm_sync database.

If the issue still persists or if Sync is not currently enabled, then please try manually clearing out the metadata using MongoShell with the command below. You’ll need to specify the given app id in appIdValue - you can get the app id value from the URL given after the /apps path… realm.mongodb.com/groups/${group_id}/apps/${app_id}

use __realm_sync
let appIdValue = ObjectId("")

db.history.deleteMany({appId: appIdValue})
db.client_history.deleteMany({appId: appIdValue})
db.client_meta.deleteMany({"appId": appIdValue})
db.client_reciprocal_history.deleteMany({"appId": appIdValue})
db.clientfiles.deleteMany({"appId": appIdValue})
db.clientfiles_counter.deleteMany({"_id": appIdValue})
db.initial_sync_progress.deleteMany({"appId": appIdValue})
db.reciprocal_history.deleteMany({"appId": appIdValue})
db.schema_change_history.deleteMany({"_id": appIdValue})
db.session_tracker.deleteMany({"appId": appIdValue})
db.open_transactions_batches.deleteMany({"appId": appIdValue})
db.versions.deleteMany({"appId": appIdValue})
db.unsynced_documents.deleteMany({"appId": appIdValue})
db.compaction_meta.deleteMany({"appId": appIdValue})

Regards
Manny

1 Like

Thank you @Mansoor_Omar, I will try your script.