FYI: when upgrading to version 6 from 5.0.2 I got this error:
CREATE UNIQUE INDEX
ERROR: query failed: CREATE UNIQUE INDEX
Error: Duplicate entry ‘10038’ for key ‘pid’
/path/to/openemr/library/sql_upgrade_fx.php at 1158:sqlStatement
/path/to/openemr/sql_upgrade.php at 314:upgradeFromSqlFile(5_0_2-to-6_0_0_upgrade.sql)
I had to delete the duplicate row with the “portal_pwd_status” field = 0.
then the update worked.