2023-10-29 03:55:17 -03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
VersionStr='2023-10-29'
|
|
|
|
BASEDIR=$(dirname $(realpath -s $BASH_SOURCE))
|
|
|
|
|
|
|
|
while read LINE; do
|
|
|
|
declare "$LINE" 2>/dev/null
|
|
|
|
done < $BASEDIR/.env
|
|
|
|
|
|
|
|
connect_db(){
|
2023-10-30 03:00:27 -03:00
|
|
|
echo "mariadb -u ${DBUSER} -p${DBPASS} -h ${DBADDR%%:*} ${DBNAME} -P ${DBADDR##*:}"
|
2023-10-29 03:55:17 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
create_tables(){
|
2023-10-30 03:00:27 -03:00
|
|
|
$(connect_db) < ./create_tables.sql
|
2023-10-29 03:55:17 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
populate_tables(){
|
2023-10-30 03:00:27 -03:00
|
|
|
$(connect_db) < ./populate_tables.sql
|
2023-10-29 03:55:17 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
import_records(){
|
2023-10-30 03:00:27 -03:00
|
|
|
$(connect_db) < ./import_records.sql
|
2023-10-29 03:55:17 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
re_create_tables(){
|
2023-10-30 03:00:27 -03:00
|
|
|
$(connect_db) < ./re_create_tables.sql
|
2023-10-29 03:55:17 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
create_f_sp(){
|
2023-10-30 03:00:27 -03:00
|
|
|
$(connect_db) < ./funcs_sp.sql
|
2023-10-29 03:55:17 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
create_triggers(){
|
2023-10-30 03:00:27 -03:00
|
|
|
$(connect_db) < ./triggers.sql
|
2023-10-29 03:55:17 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
deactivate_session(){
|
|
|
|
unset DBNAME DBUSER DBPASS DBADDR PEPPER
|
|
|
|
unset VersionStr BASEDIR
|
|
|
|
unset connect_db create_populate_tables
|
|
|
|
unset populate_tables import_records
|
|
|
|
unset re_create_tables create_f_sp
|
|
|
|
unset create_triggers deactivate_session
|
|
|
|
}
|