|

Fix “Incorrect row format” Warning After Upgrading to Nextcloud Hub 10 (31.0.0)

After upgrading to Nextcloud Hub 10 (version 31.0.0), you may encounter the following warning in the Admin > Settings > Overview section:

❗️ Some tables in the database are not using the recommended row format “DYNAMIC”.

This guide helps you fix that efficiently using native MySQL/MariaDB tools, without relying on scripts that may not always work across environments.

Step 1: Define Your Database Name

Start by setting your Nextcloud database name as a variable so you can reuse it in all commands:

DB_NAME="nextcloud"

Replace "nextcloud" with your actual database name if it differs.

Step 2: Check Current Row Format of Tables

Start by checking which tables are not using ROW_FORMAT=DYNAMIC.

mysql -e "
SELECT table_name, row_format
FROM information_schema.tables
WHERE table_schema = '$DB_NAME';
"

You’ll likely see a mix of Dynamic and Compressed formats:

+-----------------------------+------------+
| table_name | row_format |
+-----------------------------+------------+
| oc_systemtag | Compressed |
| oc_twofactor_backupcodes | Compressed |
| oc_preferences_ex | Dynamic |
...

Step 3: Back Up Your Database

Before making any changes, create a full backup of your Nextcloud database.

mysqldump "$DB_NAME" > "${DB_NAME}_backup.sql"

Make sure you test the backup restore process on a staging environment if possible.

Step 4: Generate ALTER TABLE Statements

Now generate a list of ALTER TABLE statements for all tables not already set to DYNAMIC:

mysql -s -e "
SELECT CONCAT(
'ALTER TABLE \`', TABLE_NAME, '\` ROW_FORMAT=DYNAMIC;'
) AS _alter
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = '$DB_NAME'
AND ENGINE='InnoDB'
AND ROW_FORMAT <> 'DYNAMIC';
" > nc_alter_format_row_to_dynamic.sql

Step 5: Run the ALTER Statements

Apply the changes directly to the database:

mysql "$DB_NAME" < nc_alter_format_row_to_dynamic.sql

(Optional: log the output for auditing)

mysql "$DB_NAME" < nc_alter_format_row_to_dynamic.sql | tee alter_output.log

Step 6: Verify Changes

Confirm that all tables now use the correct ROW_FORMAT=DYNAMIC:

mysql -e "
SELECT table_name, row_format
FROM information_schema.tables
WHERE table_schema = '$DB_NAME'
AND row_format <> 'DYNAMIC';
"

If no rows are returned, you’re all set.

Why This Happens

Nextcloud 31+ expects ROW_FORMAT=DYNAMIC for compatibility and performance reasons, especially on InnoDB. If your MySQL/MariaDB server has tables created before that was the default (or uses ROW_FORMAT=Compressed), you’ll get a warning.

Notes

  • This solution only touches the tables within the specified nextcloud schema.
  • Make sure your InnoDB settings support ROW_FORMAT=DYNAMIC. It’s usually safe, but older versions of MariaDB might require innodb_file_format = Barracuda.

Final Thoughts

This method is reliable, reproducible, and doesn’t require third-party scripts or tools. Just SQL and a few shell commands—ideal for sysadmins managing multiple Nextcloud instances.

Automating the Fix with a Bash Script

To streamline this process, especially if you manage multiple Nextcloud instances, I created a reusable bash script that:

  • Prompts for the database name (defaults to nextcloud)
  • Backs up the database
  • Detects which tables are not using ROW_FORMAT=DYNAMIC
  • Generates and runs the required ALTER TABLE statements

Script: fix-nextcloud-row-format.sh

#!/bin/bash

# Fix incorrect row_format warning in Nextcloud Hub 10+
# Author: Pieter (adapted for Unix socket use with DB prompt)
# Version: 1.1

set -e

# --- Ask for DB name with default ---
read -rp "Enter the Nextcloud database name [nextcloud]: " DB_NAME
DB_NAME="${DB_NAME:-nextcloud}"

BACKUP_FILE="${DB_NAME}_backup_$(date +%F_%H-%M-%S).sql"
ALTER_SCRIPT="alter_row_format.sql"

# --- Check for mysql and mysqldump ---
command -v mysql >/dev/null 2>&1 || { echo >&2 "Error: mysql client not found."; exit 1; }
command -v mysqldump >/dev/null 2>&1 || { echo >&2 "Error: mysqldump not found."; exit 1; }

echo "Backing up database '$DB_NAME' to $BACKUP_FILE..."
mysqldump "$DB_NAME" > "$BACKUP_FILE"
echo "Backup completed."

echo "Checking for tables that are not using ROW_FORMAT=DYNAMIC..."
NON_DYNAMIC_TABLES=$(mysql -s -e "
SELECT TABLE_NAME
FROM information_schema.tables
WHERE table_schema = '$DB_NAME'
AND engine = 'InnoDB'
AND row_format <> 'Dynamic';")

if [[ -z "$NON_DYNAMIC_TABLES" ]]; then
    echo "All InnoDB tables are already using ROW_FORMAT=DYNAMIC. No action needed."
    exit 0
fi

echo "Generating ALTER TABLE statements..."
mysql -s -e "
SELECT CONCAT(
  'ALTER TABLE `', TABLE_NAME, '` ROW_FORMAT=DYNAMIC;'
)
FROM information_schema.tables
WHERE table_schema = '$DB_NAME'
AND engine = 'InnoDB'
AND row_format <> 'Dynamic';
" > "$ALTER_SCRIPT"

echo "Generated SQL script: $ALTER_SCRIPT"
echo "Applying row format fixes..."
mysql "$DB_NAME" < "$ALTER_SCRIPT"
echo "All applicable tables have been altered."

echo "Re-checking table formats..."
REMAINING=$(mysql -e "
SELECT table_name, row_format
FROM information_schema.tables
WHERE table_schema = '$DB_NAME'
AND row_format <> 'Dynamic';")

if [[ -z "$REMAINING" ]]; then
    echo "All tables are now using ROW_FORMAT=DYNAMIC!"
else
    echo "Some tables still have non-DYNAMIC format:"
    echo "$REMAINING"
fi

How to Use

  1. Save the script as fix-nextcloud-row-format.sh
  2. Make it executable:chmod +x fix-nextcloud-row-format.sh
  3. Run it as root (or with sudo):sudo ./fix-nextcloud-row-format.sh

This approach works especially well when you’re using MariaDB with Unix socket authentication, as it doesn’t require a username or password when run by root.

Similar Posts