Realm app deployment schema issues between env

Hello,

I have three realm synced Apps with the same name, one for “development”, one for “qa” and one for “production”.
“development” is on a shared cluster and has its own database.
“qa” and “production” are on a dedicated cluster and have both their own database.

I use GitHub to deploy “development” to Atlas bi-directionnaly.
I use realm-cli to deploy to “qa” and “production” with a GitHub actions script.

Pardon my words, but honestly this is a pain in the “a…” to maintain.
To have a single source of truth, and because it wouldn’t work otherwise anyway,
I have my schemas only on the “development” folder in my GitHub repository.

When deploying to “qa” or “production” I do the following:

cp data_sources/mongodb-atlas/db-development/<collection_name>/schema.json data_sources/mongodb-atlas/db-qa/<collection_name>/

And this has worked once to deploy to “qa” and “prod”.

But now that I retry deploying to “qa”, it doesn’t work I get the following error:
push failed: error fetching schema provider for schemas: two schemas have the same title “CollectionTitle”

And every time I try re-deploying I get a different “CollectionTitle” in the error.

When I look at my apps in Atlas, for each of the apps, only the corresponding database/schemas are defined. The other ones are greyed out. And schemas are not defined for the other apps.
Has anyone been successful in managing schemas with a single source of truth?

Can anyone make sense of this error ?
Thanks.

Hi,

Sorry to hear you aren’t having a great experience with this. I will try to respond to a few things in parallel:

  1. I would recommend having different clusters for QA and Production. This is great for isolation and will actually improve the performance of some aspects of sync (especially if you are using partition-based sync)
  2. The error you are running into sounds like you are accidentally adding the “dev” schemas to your “qa” app. The issue is likely that you have schemas defined in each environment for the table “CollectionTitle” that map to different namespaces (in dev its “db-development.collection_title”, in qa its “db-qa.collection_title”). When you add the “dev” schema to the “qa” app, it creates a situation where you have two different schemas (namespaces) that have the same “title” field and thus the same Realm table name.

I think this docs page might do a better job explaining this situation: https://www.mongodb.com/docs/atlas/app-services/sync/data-model/data-model-map/#overview

If the issue is still occurring, I would be happy to look into it more if you can send me your GroupId (you can see this in your URL when on atlas/app services). You can reply here (it is safe and only MongoDB employees can look it up), or you can send it privately to me in the forums if that would make you more comfortable.

Best,
Tyler

Thanks for your reply. So the doc you shared clearly states that “You could not have another schema whose title was Dog in the same cluster.”. So I created a new cluster for my “qa” and now everything seems to be working.

I spoke too fast, It was working during a few deploys. And out of nowhere the same error came back, even though my apps databases are on three different clusters.

Hi, what is the error now? One thing that definitely gets rid of the issue is that you no longer need to have the database names have -dev -qa -prod as a suffix. The issue before was the fact that you were most likely uploading your QA schemas to the Prod app (which has duplicate titles), but if you just have the same set of schemas/collections across all apps I suspect you will have a much better time.

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