SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘indexacion-2-blockTitle’ for key ‘plugin_settings_pkey’

Im trying to update from version to, but during the process i have this database error:

Se ha producido un error en la base de datos: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘indexacion-2-blockTitle’ for key ‘plugin_settings_pkey’ (SQL: insert into plugin_settings (context_id, plugin_name, setting_name, setting_type, setting_value) values (2, redes sociales, blockTitle, object, a:1:{s:5:“es_ES”;s:14:“redes sociales”;}), (2, normas para colaboradores, blockTitle, object, a:1:{s:5:“es_ES”;s:25:“normas para colaboradores”;}), (2, open source, blockTitle, object, a:1:{s:5:“es_ES”;s:11:“open source”;}), (2, facebook, blockTitle, object, a:1:{s:5:“es_ES”;s:8:“facebook”;}), (2, basesdedatos, blockTitle, object, a:1:{s:5:“es_ES”;s:12:“basesdedatos”;}), (2, normas, blockTitle, object, a:1:{s:5:“es_ES”;s:6:“normas”;}), (2, indexacion, blockTitle, object, a:1:{s:5:“es_ES”;s:10:“indexacion”;}), (2, indexacion, blockTitle, object, a:1:{s:5:“es_ES”;s:10:“indexacion”;}), (2, idiomas_new, blockTitle, object, a:1:{s:5:“es_ES”;s:11:“idiomas_new”;}))

Do you have any idea of what the problem is ?

Thank’s for you help

1 Like

Hi @iicmuseoIT ,
I was having the same problem as you. I was trying to upgrade from version 3.2.1-4 to 3.3.0-8 but this error was preventing.
I found the solution and came to contribute with you, in case you still need it and it is useful for the next ones that come here looking for the solution, as I did.

CREATE TEMPORARY TABLE IF NOT EXISTS plugin_settings_2_delete AS (
    SELECT s.context_id
    FROM plugin_settings s
        LEFT JOIN rt_contexts j ON (s.context_id = j.context_id)
    WHERE j.context_id IS NULL
DELETE FROM plugin_settings  WHERE context_id IN (SELECT context_id   FROM plugin_settings_2_delete);
DROP TABLE plugin_settings_2_delete;
1 Like