misc/maintenance/sync_db_comments.pl
perl sync_db_comments.pl [-h] [-v] [-schema FILE ] [-database DB_NAME] [-table TABLE_NAME] [-commit] [-clear|-reset|-renumber]
Synchronize column comments in database with Koha schema. Allows you to clear comments too. Operates additionally on specific tables only. And provides a dry run mode that prints sql statements. Warning: According to good practice, make a backup of your database before running this script. Some examples: misc/maintenance/sync_db_comments.pl -help Usage statement. misc/maintenance/sync_db_comments.pl -clear -commit -verbose Clear all column comments in database. The verbose flag shows all issued ALTER TABLE statements. misc/maintenance/sync_db_comments.pl -reset -commit -database mydb -table items -schema newstructure.sql Only resets comments in items table. Operates on specific database instead of the one from $KOHA_CONF. Reads the schema from the specified file instead of default one. misc/maintenance/sync_db_comments.pl -renumber Renumbers all comments like Comment_1,2,.. Added for testing purposes. Not meant to run on production. Omitting the commit flag allows you to see what would be done (dry run).
This script may prove helpful to track synchronization issues between Koha schema and actual database structure due to inconsistencies in database revisions. It reduces the noise from missing column comments when running script update_dbix_class_files.pl. The script is just a wrapper around the module Koha::Database::Commenter. A test script is provided in t/db_dependent/Koha/Database/Commenter.t. The flags -clear, -reset and -renumber are mutually exclusive. The renumber option has been helpful in verifying that the alter table operations work on the complete Koha database. It is not recommended to run it in production (obviously).
Marcel de Rooy, Rijksmuseum Amsterdam, The Netherlands