2020-08-13 09:26:06 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
2020-08-13 14:43:46 +00:00
|
|
|
to_header () {
|
2020-08-13 09:26:06 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
to_header "cache"
|
|
|
|
|
|
|
|
cd $PWD;
|