sqlmig: corriger la lecture des paramètres

This commit is contained in:
Jephté Clain 2019-05-09 12:48:17 +04:00
parent d197fc0420
commit 0891e89278
1 changed files with 53 additions and 38 deletions

53
sqlmig
View File

@ -1191,10 +1191,7 @@ grant all privileges on $dbname.* to '$dbname';"
default-character-set=utf8 default-character-set=utf8
[sqlmig] [sqlmig]
#suffix= #suffix="
#csv2sql=0
csv_null=
#load-data=default"
fi fi
if [ ! -f "$dbdir/my-${dbname}.cnf" ]; then if [ ! -f "$dbdir/my-${dbname}.cnf" ]; then
@ -1203,7 +1200,12 @@ csv_null=
# Paramètres de connexion pour $dbname # Paramètres de connexion pour $dbname
[client] [client]
#user= #user=
#password=" #password=
[sqlmig]
#csv2sql=0
csv_null=
#load-data=default"
fi fi
elif [ "$type" == oracle ]; then elif [ "$type" == oracle ]; then
@ -1482,13 +1484,12 @@ for dbdir in "${dbdirs[@]}"; do
ensure_dbtype "$dbdir" "$type" ensure_dbtype "$dbdir" "$type"
ensure_dbmode "$dbtype" "$mode" ensure_dbmode "$dbtype" "$mode"
############################################################################
if [ "$dbtype" == mysql ]; then if [ "$dbtype" == mysql ]; then
setx defaults=mysql_get_defaults "$dbdir" # construire les paramètres pour mysql
set_csv2sql=1 mysql_set_adminargs "$dbdir"
set_csv_null=1 mysql_set_userargs "$dbdir" "$dbname"
mysql__mconf_get "$defaults" mysql_set_mysqlargs
fix_csv2sql
fix_csv_null
if is_yes "$csv2sql" && [ -n "$data_csv" ]; then if is_yes "$csv2sql" && [ -n "$data_csv" ]; then
# Conversion csv --> sql # Conversion csv --> sql
@ -1514,7 +1515,6 @@ for dbdir in "${dbdirs[@]}"; do
done done
eend; eclearp eend; eclearp
fi fi
fi
# lister les mises à jour disponibles # lister les mises à jour disponibles
drops=() drops=()
@ -1538,13 +1538,6 @@ for dbdir in "${dbdirs[@]}"; do
fi fi
done done
############################################################################
if [ "$dbtype" == mysql ]; then
# construire les paramètres pour mysql
mysql_set_adminargs "$dbdir"
mysql_set_userargs "$dbdir" "$dbname"
mysql_set_mysqlargs
if [ -n "$suffix" ]; then if [ -n "$suffix" ]; then
estepi "Suffixe: $dbname --> $dbname$suffix" estepi "Suffixe: $dbname --> $dbname$suffix"
dbname="$dbname$suffix" dbname="$dbname$suffix"
@ -1616,6 +1609,28 @@ for dbdir in "${dbdirs[@]}"; do
oracle_source_userconf "$dbdir" "$dbname" oracle_source_userconf "$dbdir" "$dbname"
oracle_ensure_opdir oracle_ensure_opdir
# lister les mises à jour disponibles
drops=()
creates=()
updates=()
have_csv=
array_lsfiles files "$dbdir" "*.sql" "*.csv"
for file in "${files[@]}"; do
if [[ "$file" == *.sql ]]; then
if have_tag drop "$file"; then
array_add drops "$file"
elif have_tag create "$file"; then
array_add creates "$file"
else
array_add updates "$file"
fi
elif [ ! -f "${file%.csv}.sql" ]; then
# n'ajouter le CSV que si le fichier SQL correspondant n'existe pas
array_add updates "$file"
have_csv=1
fi
done
if [ -n "$suffix" ]; then if [ -n "$suffix" ]; then
estepi "Suffixe: $dbname --> $dbname$suffix" estepi "Suffixe: $dbname --> $dbname$suffix"
dbname="$dbname$suffix" dbname="$dbname$suffix"