controller-legacy/compile_sql.sh
Tobias Reisinger 9602e6e937 remove: lmdb
add: sqlite
add: new commands
2020-08-24 16:00:08 +02:00

33 lines
769 B
Bash
Executable file

#!/usr/bin/env sh
to_header () {
if [ -f ./include/sql/$1.h ]
then
if [ -z $(find ./sql/$1.sql -newer ./include/sql/$1.h -print) ]
then
return
fi
fi
echo "Compiling $1"
xxd -i sql/$1.sql | sed 's/\([0-9a-f]\)$/\0, 0x00/' > ./include/sql/$1.h
}
cd "$(dirname "$0")";
migration_num=0;
while [ -f ./sql/migration_$migration_num.sql ]
do
if [ -f ./include/migrations/$migration_num.sql.h ]
then
if [ -z $(find ./sql/migration_$migration_num.sql -newer ./include/sql/migration_$migration_num.h -print) ]
then
migration_num=$((migration_num+1))
continue
fi
fi
to_header "migration_$migration_num"
migration_num=$((migration_num+1))
done
cd $PWD;