Created
September 22, 2025 12:34
-
-
Save gsomoza/04b1bbae66ae3d49dd539506fc651bd5 to your computer and use it in GitHub Desktop.
Fix mariadb row format for all nextcloud tables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # fix-rowformat.sh — set ROW_FORMAT=DYNAMIC for all oc_ tables | |
| # | |
| DB="nextcloud" | |
| USER="nextcloud" | |
| PASS="" | |
| HOST="localhost" | |
| echo "Checking tables in database '$DB'…" | |
| TABLES=$(mariadb -N -B -u${USER} ${PASS:+-p${PASS}} -h${HOST} -e " | |
| SELECT TABLE_NAME | |
| FROM information_schema.tables | |
| WHERE TABLE_SCHEMA='${DB}' | |
| AND TABLE_NAME LIKE 'oc\_%' | |
| AND ENGINE='InnoDB' | |
| AND UPPER(COALESCE(ROW_FORMAT, '')) NOT IN ('DYNAMIC'); | |
| ") | |
| if [ -z "$TABLES" ]; then | |
| echo "✅ All oc_ tables are already DYNAMIC. Nothing to do." | |
| exit 0 | |
| fi | |
| echo "The following tables need conversion:" | |
| echo "--------------------------------------" | |
| echo "$TABLES" | |
| echo "--------------------------------------" | |
| read -p "Proceed with ALTER TABLE to set ROW_FORMAT=DYNAMIC? (y/N) " confirm | |
| [ "$confirm" != "y" ] && { echo "Aborted."; exit 1; } | |
| for tbl in $TABLES; do | |
| echo "Running ALTER TABLE on $tbl …" | |
| mariadb -u${USER} ${PASS:+-p${PASS}} -h${HOST} $DB \ | |
| -e "ALTER TABLE \`${tbl}\` ROW_FORMAT=DYNAMIC, ALGORITHM=INPLACE, LOCK=NONE;" | |
| if [ $? -ne 0 ]; then | |
| echo "❌ ALTER TABLE failed for $tbl." | |
| else | |
| echo "✅ ALTER TABLE succeeded for $tbl." | |
| fi | |
| done | |
| echo "All done. Re-run the script to verify that everything is now DYNAMIC." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment