core-legacy/compile_migrations.sh

23 lines
616 B
Bash
Raw Normal View History

#!/usr/bin/env sh
cd "$(dirname "$0")";
migration_num=0;
2020-06-13 17:20:07 +00:00
while [ -f ./sql/migration_$migration_num.sql ]
do
2020-06-13 17:20:07 +00:00
if [ -f ./include/migrations/$migration_num.sql.h ]
then
if [ -z $(find ./sql/migration_$migration_num.sql -newer ./include/migrations/$migration_num.sql.h -print) ]
then
2020-06-29 16:47:42 +00:00
migration_num=$((migration_num+1))
2020-06-13 17:20:07 +00:00
continue
fi
fi
echo "Recompiling migration $migration_num"
xxd -i sql/migration_$migration_num.sql | sed 's/\([0-9a-f]\)$/\0, 0x00/' > ./include/migrations/$migration_num.sql.h
2020-06-29 16:47:42 +00:00
migration_num=$((migration_num+1))
2020-06-13 17:20:07 +00:00
done
cd $PWD;