Upgrading from 1.9.x to 2.0 under PostgreSQL, I get:
ERROR: duplicate key value violates unique constraint "mdl_confplug_plunam_uix"
UPDATE mdl_config_plugins SET plugin = $1,name = $2,value = $3 WHERE id=$4
[array ( 'plugin' => 'assignment_online', 'name' => 'version', 'value' => '2005042900', 0 => '23', )]
line 365 of /lib/dml/moodle_database.php: dml_write_exception thrown
line 223 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
line 883 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
line 937 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->update_record_raw()
line 2224 of /lib/db/upgrade.php: call to pgsql_native_moodle_database->update_record()
line 987 of /lib/upgradelib.php: call to xmldb_main_upgrade()
line 237 of /admin/index.php: call to upgrade_core()
It seems that the (assignment_online, version) tuple already exists and something previous in the upgrade is inserting it, so the 2009061703 block in main upgrade fails.
Solution: check for existing tuple before inserting AND delete the original ones