-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
makeservices: easywp delete tables option #124
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,22 @@ if [[ -z "$sqlpass" ]]; then | |
fi | ||
echo "SQL set up and the password can be found in wp-config.php ..." | ||
|
||
tables=$(mysql --user="$USER" --password="$sqlpass" --execute="show tables" "$USER" | grep -E "^wp_" || echo "") | ||
if ! [[ -z "$tables" ]]; then | ||
echo | ||
echo -e "\033[33mThere appears to be an existing WordPress installation. Would you like to clean the database?\033[00m\n" | ||
read -rp "Do you want to continue? [y/N] " wordpresskiller | ||
wordpresskiller=${wordpresskiller,,} | ||
if ! [[ "$wordpresskiller" =~ ^(yes|y) ]]; then | ||
echo "If you want to run this script and keep the tables intact, rename the existing tables from wp_* to something else." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like it would be useful before asking the user if they want to delete everything than at the stage when they have shied away from it, although it's useful here too I suppose so that they know what to do to continue to the later steps in the script. |
||
exit 0 | ||
fi | ||
|
||
echo "$tables" | tr ' ' '\n' | while read -r table; do | ||
mysql --user="$USER" --password="$sqlpass" --execute="DROP TABLE $table" "$USER" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should use mysqldump to back up the tables before dropping them. |
||
done | ||
fi | ||
|
||
# Install WordPress and create config file | ||
wp core download | ||
wp config create --dbname="$user" --dbuser="$user" --dbpass="$sqlpass" --dbhost=mysql --dbcharset=utf8mb4 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Print out the name of the tables to be deleted in here too? Then at least it might be clear if it's deleting tables that it shouldn't.
I'm unclear if this is too much information for the user, but given this is deleting those tables, it seems reasonable to me to list them first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's pretty reasonable to delete everything that starts with
wp_
without listing them. We don't really want to overload users.