#!/bin/bash

# Database name
if [[ $1 != "" ]]; then
  tpl=$1
else
  tpl="music_academy"
fi

# Clean the database
mysql <<EOF
  USE $tpl;
  TRUNCATE tl_cron;
  TRUNCATE tl_log;
  TRUNCATE tl_session;
  TRUNCATE tl_undo;
  UPDATE tl_member SET session='', language='en';
  UPDATE tl_user SET session='', language='en';
EOF

# Create the SQL dump
mysqldump \
  --compact \
  --no-create-info \
  --hex-blob \
  --complete-insert \
  --skip-opt \
  $tpl > templates/$tpl.sql
