Fixes sqlite db schema checks.

main
Yasen Pramatarov 2024-06-11 14:27:09 +03:00
parent 73a13bf828
commit 4fc2223d44
1 changed files with 3 additions and 2 deletions

5
jilo
View File

@ -157,7 +157,7 @@ check_requirements
# normalize DB schemas for Sqlite3 and MySQL/MariaDB in order to compare them when needed # normalize DB schemas for Sqlite3 and MySQL/MariaDB in order to compare them when needed
db_normalize_schema() { db_normalize_schema() {
echo "$1" | tr -d '\n' | tr -s ' ' | tr ',' '\n' | sort echo "$1" | tr -d '\n' | tr -s ' ' | tr ',' '\n' | tr -d ';' | sort
} }
# execute a query and return the result # execute a query and return the result
@ -524,7 +524,8 @@ case "$cmd" in
fi fi
# get current and expected db schemas in comparable format # get current and expected db schemas in comparable format
current_db_schema=$(sqlite3 "$DB" .schema) #current_db_schema=$(sqlite3 "$DB" .schema)
current_db_schema=$(sqlite3 "$DB" "SELECT sql FROM sqlite_master WHERE type='table' AND name!='sqlite_sequence';")
current_db_schema_normalized=$(db_normalize_schema "$current_db_schema") current_db_schema_normalized=$(db_normalize_schema "$current_db_schema")
expected_db_schema_normalized=$(db_normalize_schema "$db_create") expected_db_schema_normalized=$(db_normalize_schema "$db_create")