diff --git a/plugins/services/scripts/sql-import.sh b/plugins/services/scripts/sql-import.sh index 688f4a1..cd5d521 100755 --- a/plugins/services/scripts/sql-import.sh +++ b/plugins/services/scripts/sql-import.sh @@ -108,21 +108,13 @@ if [ "$WIPE" == "true" ]; then lando_green "\t\tCreating database ...\n\n" psql postgresql://$USER@$HOST:$PORT/postgres -c "create database $DATABASE" else - # Build the SQL prefix + # Drop and recreate database SQLSTART="mysql -h $HOST -P $PORT -u $USER ${LANDO_EXTRA_DB_IMPORT_ARGS} $DATABASE" + lando_yellow "\t\tDropping database ...\n\n" + $SQLSTART -e "DROP DATABASE IF EXISTS ${DATABASE}" - # Gather and destroy tables - TABLES=$($SQLSTART -e 'SHOW TABLES' | awk '{ print $1}' | grep -v '^Tables' || true) - - # PURGE IT ALL! Drop views and tables as needed - for t in $TABLES; do - echo "Dropping $t from $DATABASE database..." - $SQLSTART <<-EOF - SET FOREIGN_KEY_CHECKS=0; - DROP VIEW IF EXISTS \`$t\`; - DROP TABLE IF EXISTS \`$t\`; -EOF - done + lando_green "\t\tCreating database ...\n\n" + $SQLSTART -e "CREATE DATABASE ${DATABASE}" fi fi