About error #1 - Source and destination environments must have the same schema:
Running the push command will send the layout changes from your source environment (local development environment) to the destination environment.
To do this, it is required that both source and destination have the same (forestadmin) schema.
To be sure the same schemas are on source and destination, it’s needed to have both git branches entirely synchronized (git pull/push).
Sometimes it is not the case because someone else added commits to the destination.
As I can see, all of your 5 environments have different hashes, meaning they all have different schemas.
Comparing branches in both directions showed no difference.
Checking Environment tab in Forest Admin Project Settings I see as well that Liana Version is different for Development and QA. Already tried to restart QA server few times but no changes. That is a known issue for us, and we almost always had to execute schema:apply to force .forestadmin-schema.json file to be updated. But in this specific case, schema:apply is also failing and we are not able to apply changes.
Here is the list of your environment with their last synchro dates.
Hope it will help you to find what synchronization is missing.
dev “irfan” => last synchro yesterday at 18h (today synchros changed nothing)
dev “joche” (outdated agent version) => last synchro 20th May at 14h (later synchros changed nothing)
Prod => last synchro 16 May at 11h
QA => last synchro 06 May at 13h
Could you please verify what is the latest sync time for forestadmin-schema.json file for QA environment?
Now, when I check Environment tab in Forest Admin Project Settings I see the same Liana versions for my Development and QA, but still forest push shows error message. forestadmin-schema.json file on QA environment should be the same as one on my Development environment.
Failed to push branch: Source and destination environments must have the same schema. Please check your environments code is synchronized.
A little trick to know what fields are different is to do a JSON diff between your generated schema from your 2 environments. You can use this tool: http://jsondiff.com/.
Do you have any diff with this tool ?
Although two environments have same code deployed, for some reason this field is missing on the QA environment. Is there a possibility that server modifies this .json file and remove it for some reason?
I have compared your dev (updated 27/05/2022 10:33:34) and the QA (updated 24/05/2022 15:22:38) schema file and they are always different because on your QA env you don’t have isPrimaryKey attribute.
Please go to same git branch of your QA and restart your server to regenerate your schema on your development environment.
The thread contains a lot of messages, so I’ll sum it up just to be sure I fully understand the issue.
You frequently encounter the × Failed to push branch: Source and destination environments must have the same schema. Please check your environments code is synchronized.
Running forest schema:apply triggers another error: Cannot properly read the “.forestadmin-schema.json” file: “orm_version” is required.
Running forest schema:apply is not recommanded in the development workflow context, and should only be used in a few use-case.
As stated from @Alban_Bertolini, the last .forestadmin-schema.json received on our end on the QA environment is from the 05/24 and is different from your development environment, which either means that:
The .forestadmin-schema.json on the QA server did not change since the 05/24?
Even if the file changed, your server was not restarted?
On our end, we do not have any log for your QA (nor Production) environment indicating a failure on saving this schema.
In order to solve this, could you confirm that:
Both your QA and Production have the NODE_ENV=production variable set (Especially useful as this prevent the server to re-generate the .forestadmin-schema.json and force the server to use the one versioned in the repository)
That all your dev either don’t have NODE_ENV=production set, or that the NODE_ENV variable is equal to anything else than production
The last resort manupilation to fix this kind of issue would be:
On your development environment, drop .forestadmin-schema.json, and restart your server
A new one should be generated. Handle your versionning as you usually do
Once done, deploy the new code on your QA server
In development, run forest schema:apply, and force-apply this schema on your QA
At that point, both schema should be the same and push should work as excepted.
Once everything is correct, forest deploy to should be available and work as expected.
× Failed to push branch: Source and destination environments must have the same schema. Please check your environments code is synchronized.
is related to the schema already available in forest. If this error is raised but both of your schema are the same locally, this could indicate another issue (Failure to send the schema, falsy network settings, etc), and these kind of issues should be visible in your backend logs.