My friend, Ms. Jameela P, encountered an issue while upgrading Koha from v17.05 to v24.05. The upgrade failed due to the missing display_order column in the marc_subfield_structure table. After investigating, I identified this as the root cause of the error.
Issue
C4::Biblio::GetMarcSubfieldStructure(): DBI Exception: DBD::mysql::db selectall_arrayref failed: Unknown column 'display_order' in 'order clause' at /usr/share/koha/lib/C4/Biblio.pm line 1228
Something went wrong rebuilding biblio indexes for library
C4::Biblio::GetMarcSubfieldStructure(): DBI Exception: DBD::mysql::db selectall_arrayref failed: Unknown column 'display_order' in 'order clause' at /usr/share/koha/lib/C4/Biblio.pm line 1228
Something went wrong rebuilding authority indexes for library
This issue arises due to a missing display_order column in the marc_subfield_structure table. This can happen after a Koha upgrade if the database schema hasn’t been updated properly.
Steps to Fix the Issue
First, switch to the root user and access MySQL:
sudo su
mysql -uroot -prootpassword
Use the Koha database:
USE koha_library;
1. Check if the Column Exists
Run the following SQL query to verify the existence of the display_order column:
DESCRIBE marc_subfield_structure;
If the column is missing, proceed to the next steps.
2. Run Koha Database Schema Updates
Execute the schema upgrade command:
sudo koha-upgrade-schema library
Replace your_instance_name with your actual Koha instance name.
3. Manually Add the Column (If Needed)
If the schema upgrade does not resolve the issue, manually add the missing column using:
ALTER TABLE marc_subfield_structure ADD COLUMN display_order INT DEFAULT 0;
Then restart Koha:
sudo systemctl restart koha-common
4. Rebuild Zebra or Elasticsearch Index
Depending on your setup, run:
For Zebra:
sudo koha-rebuild-zebra -f library
For Elasticsearch:
sudo koha-elasticsearch --rebuild library
5. Check Logs for Further Errors
If issues persist, check the logs for additional details:
sudo journalctl -u koha-common --no-pager | tail -n 50
This issue can disrupt indexing and MARC subfield retrieval in Koha, but following these steps should help you resolve it quickly. If you have encountered similar errors or have alternative solutions, feel free to share your insights!