Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kkuehlz
Copy link
Member

@kkuehlz kkuehlz commented Aug 28, 2019

Helpful if the user has an old instance of wordpress that they aren't
interested in.

@kkuehlz kkuehlz requested a review from cg505 August 28, 2019 23:16
Helpful if the user has an old instance of wordpress that they aren't
interested in.
@kkuehlz kkuehlz force-pushed the easywp_clear_tables branch from a6cd9ff to ad4c687 Compare August 28, 2019 23:21
@kkuehlz
Copy link
Member Author

kkuehlz commented Aug 28, 2019

fuck lint

Copy link
Member

@jvperrin jvperrin left a 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

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."
Copy link
Member

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"
Copy link
Member

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.

Copy link
Member

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"
Copy link
Member

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"
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants