MediaWiki 1.31 has some new tables around the comments (and in the future around authors). With $wgCommentTableSchemaMigrationStage the state of the upcoming migration is handled. Stages are MIGRATION_OLD - MIGRATION_WRITE_BOTH - MIGRATION_WRITE_NEW - MIGRATION_NEW
Using a $wgForeignFileRepos with ForeignDBRepo or ForeignDBViaLBRepo connect to an older mediawiki version or connect to a same versioned but with a different migration stage will fail horribly.
Set $wgCommentTableSchemaMigrationStage = MIGRATION_NEW; in your main wiki, but leave the config as is for your db repo. The created sqls will fail, because there are using the new tables which may not exists or are empty on the foreign db repo.
The migration guide should have some hints for this case. This also affected wmf, because commons is a db repo (and testwiki for test2wiki).
The foreign repo must stay on MIGRATION_WRITE_BOTH as long as an older mediawiki is connect to it.
No other mediawiki can reach MIGRATION_NEW in this situation, when the migration script was not running on the foreign repo.