Advertisement
rudolfbyker

koha_fix_db_row_formats.sh

Aug 16th, 2023
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #!/usr/bin/env sh
  2. # Automatically fix row formats for all tables in a Koha database
  3. # See:
  4. # - https://wiki.koha-community.org/wiki/Database_row_format
  5. # - https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28267
  6. # - https://mariadb.com/kb/en/troubleshooting-row-size-too-large-errors-with-innodb/
  7.  
  8. set -eu
  9.  
  10. INSTANCE="$1"
  11. DB_NAME="koha_$INSTANCE"
  12.  
  13. echo "Fixing row formats for koha instance $INSTANCE in database $DB_NAME ..."
  14.  
  15. TABLES_QUERY="SELECT table_name FROM information_schema.tables WHERE engine = 'InnoDB' AND row_format IN('Redundant', 'Compact') AND table_schema = '$DB_NAME';"
  16. TABLES="$(mysql --batch --skip-column-names --execute="$TABLES_QUERY")"
  17.  
  18. for TABLE in $TABLES
  19. do
  20. echo "Converting $TABLE to DYNAMIC row format ..."
  21. mysql --execute="ALTER TABLE $DB_NAME.$TABLE ROW_FORMAT=DYNAMIC;"
  22. done
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement