core-legacy/compile_migrations.sh

22 lines
616 B
Bash
Executable file

#!/usr/bin/env sh
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/migrations/$migration_num.sql.h -print) ]
then
migration_num=$((migration_num+1))
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
migration_num=$((migration_num+1))
done
cd $PWD;