Resolution: Not a bug
I received the below while upgrading as part of
MDL-40240. My database prefix is outcomes2_
Error writing to database
More information about this error
Debug info: ERROR: duplicate key value violates unique constraint "outcomes2_capa_nam_uix"
DETAIL: Key (name)=(moodle/outcome:mapoutcomes) already exists.
INSERT INTO outcomes2_capabilities (name,captype,contextlevel,component,riskbitmask) VALUES($1,$2,$3,$4,$5)
'name' => 'moodle/outcome:mapoutcomes',
'captype' => 'write',
'contextlevel' => 10,
'component' => 'moodle',
'riskbitmask' => 0,
Error code: dmlwriteexception
line 439 of /lib/dml/moodle_database.php: dml_write_exception thrown
line 239 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
line 848 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
line 900 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->insert_record_raw()
line 2719 of /lib/accesslib.php: call to pgsql_native_moodle_database->insert_record()
line 1551 of /lib/upgradelib.php: call to update_capabilities()
line 341 of /admin/index.php: call to upgrade_core()
Its curious because this is coming out of core code. The capability only appears once in access.php. I'm not sure what the outcomes code could be doing to cause this but if its a core upgrade code issue how has this not come up before now?