Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions plugins/lando-services/scripts/sql-import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,14 @@ if [ "$WIPE" == "true" ]; then
psql postgresql://$USER@$HOST:$PORT/postgres -c "create database $DATABASE"
else
# Build the SQL prefix
SQLSTART="mysql -h $HOST -P $PORT -u $USER ${LANDO_EXTRA_DB_IMPORT_ARGS} $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
SQLSTART="mysql -h $HOST -P $PORT -u $USER ${LANDO_EXTRA_DB_IMPORT_ARGS}"

# Drop and recreate database
lando_yellow "Dropping database ...\n"
$SQLSTART -e "DROP DATABASE IF EXISTS ${DATABASE}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something about this line is failing (see the test results for the PR or try using the db-export example and running the lando db-import test.sql on it).


lando_green "Creating database ...\n"
$SQLSTART -e "CREATE DATABASE ${DATABASE}"
fi
fi

Expand Down