fix: sql migration handling in make

This commit is contained in:
Tobias Reisinger 2020-06-13 19:20:07 +02:00
parent 2d6c0ff4c1
commit 0f1cd9c02c
2 changed files with 15 additions and 4 deletions

View file

@ -19,6 +19,8 @@ aux_source_directory(endpoints ENDPOINTS_SRC)
configure_file("core.ini" "core.ini" COPYONLY) configure_file("core.ini" "core.ini" COPYONLY)
add_dependencies(core migrations)
target_sources(core PRIVATE ${VENDOR_SRC} ${SRC_DIR} ${HANDLERS_SRC} ${HELPERS_SRC} ${MODELS_SRC} ${ENDPOINTS_SRC}) target_sources(core PRIVATE ${VENDOR_SRC} ${SRC_DIR} ${HANDLERS_SRC} ${HELPERS_SRC} ${MODELS_SRC} ${ENDPOINTS_SRC})
target_include_directories(core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) target_include_directories(core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor) target_include_directories(core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor)

View file

@ -4,10 +4,19 @@ cd "$(dirname "$0")";
migration_num=0; migration_num=0;
while [ -f sql/migration_$migration_num.sql ] while [ -f ./sql/migration_$migration_num.sql ]
do do
xxd -i sql/migration_$migration_num.sql | sed 's/\([0-9a-f]\)$/\0, 0x00/' > include/migrations/$migration_num.sql.h if [ -f ./include/migrations/$migration_num.sql.h ]
((migration_num++)); then
done; if [ -z $(find ./sql/migration_$migration_num.sql -newer ./include/migrations/$migration_num.sql.h -print) ]
then
((migration_num++))
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++))
done
cd $PWD; cd $PWD;