Skip to content

Commit

Permalink
UPD: Follow up Reports
Browse files Browse the repository at this point in the history
  • Loading branch information
Itskiprotich committed Aug 14, 2024
1 parent 81e74ee commit 3adcb7b
Show file tree
Hide file tree
Showing 11 changed files with 2,076 additions and 1,682 deletions.
28 changes: 28 additions & 0 deletions bake_truncate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

if [ -f .env ]; then
export $(cat .env | xargs)
fi


# Get the list of tables
TABLES=$(mysql -u"$DB_USER" -p"$DB_PASSWORD" -D"$DB_NAME" -Bse "SHOW TABLES")

# Loop through tables and generate TRUNCATE statements
for TABLE in $TABLES; do
echo "TRUNCATE TABLE \`$TABLE\`;" >> truncate_tables.sql
done

# Print message indicating that the SQL file has been generated
echo "SQL script 'truncate_tables.sql' has been generated."

# Optionally, execute the script
mysql -u"$DB_USER" -p"$DB_PASSWORD" -D"$DB_NAME" < truncate_tables.sql

# Step 4: Export the database to a file
echo "Exporting database to '$EXPORT_FILE'..."

mysqldump -u"$DB_USER" -p"$DB_PASSWORD" "$DB_NAME" > "$EXPORT_FILE"

# Print message indicating that the export is complete
echo "Database export completed. The dump file is '$EXPORT_FILE'."
Loading

0 comments on commit 3adcb7b

Please sign in to comment.