Installing updates produces Mismatched entity and/or field definitions, yet only within the live server instance. Local environment works as expected.
It first happened with the update 8001 in both local environment and live server. The issue was with
\Drupal::entityDefinitionUpdateManager()->applyUpdates(); not being applied and got fixed locally with applying the 8002 update.
The different within the database seemed to be that the filed was left as allowing a
NULL value, though it should not have been the case. That did nit sees as such a big deal.
Later updates 8003 and 8004 produced the same results with both fields allowing a
NULL value and the one meant to store the unique code value missing an index.
applyUpdates() did not seem to make much difference. Trying to use
drush entity:updates also had no effect, with the same fields with mismatched definitions being shown every time and not updates happening.
No errors seemed to have been shown, though I did not check the database logs.
The issue only occurs on the live server instance of Drupal 8 and not the local development setup. Server is running Drupal 8.6.13, Apache 2.4.6, CentOS 7.x, PHP 7.1.x, MariaDB 5.5.52.
Taking the database dump from the server and trying to run the updates on local machine with MySQL 5.7.x would still result in the same issues. Although the dumped version already has the first migration results being in the state of limbo (applied and mostly working, yet not in full).
Is that the issue with the code itself and something is missing? If so, then why does that only happen within the production server?
Is there a way to fix it, as none of the suggestions work?
Is there a documentation that would explain the inner workings in detail and allow that to be debugged?
Could that be specifically related to the database version being used?
As a side note. Uninstalling the module and reinstalling seems to fix the issue. Database tables are correct and messages about the issue are gone from the status report page. Current solution was to export the data from the database, remove the entities handled by the module, uninstall and reinstall the module in question, reimport the data on the database level. Though hat was just a quick fix.