]> git.koha-community.org Git - koha.git/commit
Bug 34064: Add an audit script to compare database with kohastructure.sql
authorDavid Cook <dcook@prosentient.com.au>
Tue, 20 Jun 2023 04:18:09 +0000 (04:18 +0000)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 10 Oct 2023 13:54:03 +0000 (10:54 -0300)
commit5d3bfc5d5b7f61b287391a6871f080ed63ced246
tree8f1529d0afcce47b426aca49196040f3d4887822
parent51e67a264271243dd4762a5050d2ec6d0e5fa3a6
Bug 34064: Add an audit script to compare database with kohastructure.sql

This script can take a connected database handle and compare that database
schema against kohastructure.sql to see what changes the database would
need in order to match kohastructure.sql

NOTE: It uses SQL::Translation::Diff, which is installed with DBIx::Class.

WARNING: The diff doesn't seem to compare comments, so that difference
won't appear in the output. If we wanted, we could easily enhance the
audit_database.pl script to also compare comments.

WARNING: The output is a proposed series of SQL commands. While they
are useful to review, they won't always duplicate the changes done
by updatedatabase.pl, so it's important to carefully analyze the output.
The key purpose of this audit script is to just highlight the differences
between the two.

Test plan:
0. Apply patch
1. vi ./installer/data/mysql/kohastructure.sql
2. Comment out some columns, change NULL status, or whatever you like
3. perl misc/maintenance/audit_database.pl \
    --filename /kohadevbox/koha/installer/data/mysql/kohastructure.sql
4. Note that the output includes SQL commands to change the database
to match the new kohastructure.sql

5a. Try using koha-foreach and note that the database name appears above
the database comparison
5b. koha-foreach "perl misc/maintenance/audit_database.pl \
    --filename /kohadevbox/koha/installer/data/mysql/kohastructure.sql"

Signed-off-by: Emmi Takkinen <emmi.takkinen@koha-suomi.fi>
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
misc/maintenance/audit_database.pl [new file with mode: 0755]