Hi Bozana,
Thanks for your answer.
About the script… may be we don’t need a separate script to check the DB integrity, but we can extend the upgrade.php one to detect usual issues as:
a) partial migration: just checking ojs3 new or temporary tables?
b) set installed to off: so the upgrade script will refuse to run.
c) permissions: check permissions in file’s folders.
I don’t want to give you all more work… indeed I thinks those improvements will save a lot of time for both, the installers and the PKP forum supporters. But it’s just an idea, so if is ok for you, let’s talk about this in the tech meeting.
So let me change this post focus to my specific DB issue.
Today I also arrived to this post and looks very close to my issue. 
The author published some queries to find duplicated rows (I translated them to pure mysql). Here you have my results:
SELECT COUNT(*) FROM review_rounds;
# 1749
SELECT COUNT(DISTINCT `submission_id`) FROM review_rounds;
# 1538
SELECT COUNT(DISTINCT(CONCAT(`submission_id`,"-",IFNULL(`stage_id`, 'NULL'),"-",`round`))) FROM review_rounds;
# 1747
SELECT COUNT(DISTINCT `review_round_id`) FROM review_rounds;
# 1749
So, looks like two rows are wrong. A little bit more mysql magic shows the culpit:
SELECT DISTINCT(CONCAT(`submission_id`," | ",IFNULL(`stage_id`, 'NULL')," | ",`round`)) as DuplicatedRows, COUNT(*) c FROM review_rounds GROUP BY DuplicatedRows HAVING c > 1;
# 1413 | NULL | 1 3
So looks like there are 3 rows in review_rounds with “submission_id = 1413” that are:
submission_id |
round |
review_revision |
status |
review_round_id |
stage_id |
1413 |
1 |
1 |
NULL |
930 |
NULL |
1413 |
1 |
1 |
NULL |
931 |
NULL |
1413 |
1 |
1 |
NULL |
949 |
NULL |
So, compared to a working row that it’s supposed to work fine:
submission_id |
round |
review_revision |
status |
review_round_id |
stage_id |
1436 |
1 |
1 |
NULL |
948 |
NULL |
1436 |
2 |
2 |
NULL |
1098 |
NULL |
1436 |
3 |
4 |
NULL |
1150 |
NULL |
… IMHO, looks like “round” or “review_revision” is wrong because in 1413 is not incremental.
I will modify both to see if the upgrade script is now able to work and I’ll be back.