After updating Omeka S to its latest version, I tried to update the CustomVocab module.
The following error appears:
------
Doctrine\DBAL\Exception\NonUniqueFieldNameException
An exception occurred while executing ‘ALTER TABLE custom_vocab ADD uris LONGTEXT DEFAULT NULL’: SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name ‘uris’
-----
Do you have any idea how to solve this problem? Thank you in advance.
That error means the module is attempting to add the uris column to the custom_vocab table, but the column already exists. The URI custom vocab type was introduced back in v1.4.0 and the ALTER TABLE statement should have only been run once during upgrade, but it appears to have been run more than once.
Did you have any issues with upgrading the module prior to this error? What version of CustomVocab are updating from?
Thank you for your answer. The error showed the first time I tried to update CustomVocab to its 2.0.2 version from 1.3.1 running on Omeka S 3. I tried other ones (2.0.1 and 1.7.1) without any success.
It appears that a partial upgrade happened during your initial upgrade from 1.3.1, but something interrupted it. Any further attempts to upgrade would have the same error.
I see two ways out of this. If you can reconstruct your custom vocabularies, just uninstall and reinstall the module, then add the vocabs back in. That’s the safest method; but if you can’t do that, you could modify the code to skip that ALTER statement.
Open CustomVocab/Module.php for editing and, in Module::upgrade(), change the following line:
$conn->exec('ALTER TABLE custom_vocab ADD uris LONGTEXT DEFAULT NULL');
To this:
// $conn->exec('ALTER TABLE custom_vocab ADD uris LONGTEXT DEFAULT NULL');
This should either just work, or expose why the initial upgrade didn’t work.
Thank you, that worked perfectly!