Created
February 20, 2019 05:38
-
-
Save herewithme/b996306d3c0f48b210d7f9d0415caed7 to your computer and use it in GitHub Desktop.
Convert all WordPress tables to UTF8MB4 with WP-CLI
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
#!/usr/bin/env bash | |
# Author Amaury Balmer - BEAPI.fr | |
# See: https://wordpress.stackexchange.com/questions/195046/relaunch-4-2-utf8mb4-databse-upgrade/244992#244992 | |
# Purpose - Convert all tables to UTF8MB4 with WP-CLI | |
# Create array of all tables | |
WPTABLES=($(wp db tables --all-tables)) | |
# loop through array and alter tables | |
for WPTABLE in ${WPTABLES[@]} | |
do | |
echo "Converting ${WPTABLE} to UTF8MB4" | |
wp eval "echo maybe_convert_table_to_utf8mb4( ${WPTABLE} );" --allow-root | |
echo "Converted ${WPTABLE} to UTF8MB4" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment