34 lines
769 B
Bash
34 lines
769 B
Bash
|
#!/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;
|