24 lines
No EOL
583 B
Bash
Executable file
24 lines
No EOL
583 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
sqlite_return=$(sqlite3 core.sqlite "SELECT version_num FROM meta LIMIT 1;" 2>/dev/null);
|
|
|
|
if ! [[ $sqlite_return =~ ^-?[0-9]+$ ]]
|
|
then
|
|
echo "No version number found. Initiating database."
|
|
sqlite_return=0;
|
|
fi;
|
|
|
|
version_num=$sqlite_return;
|
|
|
|
while [ -f sql/migration_$version_num.sql ]
|
|
do
|
|
sqlite3 core.sqlite < sql/migration_$version_num.sql;
|
|
((version_num++));
|
|
done;
|
|
|
|
if [ $sqlite_return -eq 0 ]
|
|
then
|
|
sqlite3 core.sqlite "INSERT INTO meta (version_num) VALUES ($version_num); ";
|
|
else
|
|
sqlite3 core.sqlite "UPDATE meta SET version_num=$version_num;";
|
|
fi |