mirror of
https://gh.wpcy.net/https://github.com/CaptainCore/captaincore.git
synced 2026-04-22 20:45:45 +08:00
21 lines
789 B
Bash
Executable file
21 lines
789 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
#
|
|
# Convert MyISAM datbase tables to InnoDB
|
|
#
|
|
# `captaincore ssh <site> --script=db-convert-to-innodb`
|
|
#
|
|
|
|
current_folder=${PWD##*/}
|
|
output=`wp db query "SELECT COUNT(*) FROM information_schema.TABLES WHERE ENGINE = 'MyISAM'" --skip-column-names`
|
|
if [[ "$output" -gt "0" ]]; then
|
|
if [[ "$current_folder" == "public" ]]; then
|
|
# Most likely Kinsta so extract site name from higher up in path
|
|
current_folder=${PWD#/www/*}
|
|
current_folder=${current_folder%/public}
|
|
fi
|
|
echo "$current_folder Found $output MyISAM tables"
|
|
wp db query "SELECT CONCAT('ALTER TABLE ', TABLE_SCHEMA,'.', TABLE_NAME, ' ENGINE=InnoDB;') FROM information_schema.TABLES WHERE ENGINE = 'MyISAM'" --skip-column-names > db_optimize.sql
|
|
wp db query < db_optimize.sql
|
|
rm db_optimize.sql
|
|
fi
|