-
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?
Conversation
Helpful if the user has an old instance of wordpress that they aren't interested in.
a6cd9ff
to
ad4c687
Compare
fuck lint |
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.
Looks good to me, however the warning at the top of this file
Lines 20 to 22 in ad4c687
echo -e "A user with an existing website or database will have their files | |
backed up, but their database password will change and the WordPress | |
install may migrate and reuse existing tables.\n" |
seems like it's wrong now (it'll ask to delete existing tables and not let you continue instead now), but I couldn't comment on that line itself since it's not in the diff.
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 comment
The 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.
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" |
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.
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" |
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.
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 comment
The 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.
Helpful if the user has an old instance of wordpress that they aren't
interested in.