|
1 | 1 | #!/bin/bash
|
2 |
| -#echo 'Booting database...' |
3 |
| -## TODO futuramente usar o Flask migrate ou outra alternativa |
4 |
| -# |
5 |
| -#echo 'Creating tables...' |
6 |
| -python3 ./scripts/migrations/mysql/migrate.py ./tests/datasets/database/structure/mysql/create.table.store.products.sql |
7 |
| -# |
8 |
| -#echo 'Inserting data in the table...' |
9 |
| -python3 ./scripts/migrations/mysql/migrate.py ./tests/datasets/database/seeders/mysql/seeder.table.store.products.sql |
| 2 | +# ----------------------------------------------------------------------------- |
| 3 | +# Current file variables |
| 4 | +# ----------------------------------------------------------------------------- |
| 5 | +debug=false |
| 6 | +parent_folder="../" |
| 7 | +current_path=$(pwd)/ |
| 8 | +current_path_basename=$(basename $(pwd)) |
| 9 | +current_file_full_path=$0 |
| 10 | +# echo $current_filepath |
| 11 | +current_file_name=$(basename -- "$0") |
| 12 | +# echo $current_filename |
| 13 | +if [ $current_file_full_path = $current_file_name ] || [ $current_file_full_path = "./$current_file_name" ]; then |
| 14 | + current_file_full_path="./${current_file_full_path}" |
| 15 | + current_file_path="./" |
| 16 | +else |
| 17 | + current_file_path="${current_file_full_path/$current_file_name/''}" |
| 18 | +fi |
| 19 | + |
| 20 | +current_file_path_basename=$(basename -- "$current_file_path") |
| 21 | +#echo "xxxxx current_file_path_basename $current_file_path_basename" |
| 22 | + |
| 23 | +if [ -z "$current_file_path_basename" ] || [ $current_file_path = "./" ]; then |
| 24 | +# echo 'aq' |
| 25 | + current_parent_folder="../" |
| 26 | +else |
| 27 | +# echo 'naq' |
| 28 | + current_file_path_basename=$current_file_path_basename/ |
| 29 | + current_parent_folder="${current_file_path/$current_file_path_basename/''}" |
| 30 | +fi |
| 31 | + |
| 32 | + |
| 33 | +if [ debug ]; then |
| 34 | + echo '----------------------------------------' |
| 35 | + echo "$0 - Script variables" |
| 36 | + echo '----------------------------------------' |
| 37 | + echo "current_path: $current_path" |
| 38 | + echo "current_path_basename: $current_path_basename" |
| 39 | + echo "current_file_full_path: $current_file_full_path" |
| 40 | + echo "current_file_name: $current_file_name" |
| 41 | + echo "current_file_path: $current_file_path" |
| 42 | + echo "current_parent_folder: $current_parent_folder" |
| 43 | + echo '----------------------------------------' |
| 44 | +fi |
| 45 | + |
| 46 | +if test -f ${current_parent_folder}/scripts/migrations/mysql/migrate.py; then |
| 47 | + echo '----------------------------------------' |
| 48 | + echo 'Booting database...' |
| 49 | + echo '----------------------------------------' |
| 50 | + # TODO futuramente usar o Flask migrate ou outra alternativa |
| 51 | + echo 'Creating tables...' |
| 52 | + python3 ${current_parent_folder}/scripts/migrations/mysql/migrate.py ${current_parent_folder}/tests/datasets/database/structure/mysql/create.table.store.products.sql |
| 53 | + |
| 54 | + read -p "Press enter to continue..." |
| 55 | + |
| 56 | + echo 'Inserting data in the table...' |
| 57 | + python3 ${current_parent_folder}/scripts/migrations/mysql/migrate.py ${current_parent_folder}/tests/datasets/database/seeders/mysql/seeder.table.store.products.sql |
| 58 | +fi |
| 59 | + |
| 60 | + |
0 commit comments