db_pending/import now use transaction to avoid db data inconsistency
This commit is contained in:
@@ -35,14 +35,23 @@ function import() {
|
||||
for entry in "$pendingPath"/*.sql
|
||||
do
|
||||
if [[ -e $entry ]]; then
|
||||
startTransaction="START TRANSACTION;";
|
||||
updHeader="ALTER TABLE db_version CHANGE COLUMN "$latestUpd" "$dateToday"_"$counter" bit;";
|
||||
endTransaction="COMMIT;";
|
||||
|
||||
cnt=$(printf -v counter "%02d" $counter ; echo $counter)
|
||||
newFile="$updPath/"$dateToday"_"$cnt".sql"
|
||||
echo "$updHeader" > "$newFile"
|
||||
|
||||
echo "$startTransaction" > "$newFile"
|
||||
echo "$updHeader" >> "$newFile"
|
||||
echo "--" >> "$newFile"
|
||||
echo "--" >> "$newFile"
|
||||
|
||||
cat $entry >> "$newFile"
|
||||
echo "$endTransaction" >> "$newFile"
|
||||
|
||||
rm $entry
|
||||
|
||||
((counter+=1))
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user