fix: sql migration handling in make
This commit is contained in:
		
							parent
							
								
									2d6c0ff4c1
								
							
						
					
					
						commit
						0f1cd9c02c
					
				
					 2 changed files with 15 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -19,6 +19,8 @@ aux_source_directory(endpoints ENDPOINTS_SRC)
 | 
			
		|||
 | 
			
		||||
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_include_directories(core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
 | 
			
		||||
target_include_directories(core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,10 +4,19 @@ cd "$(dirname "$0")";
 | 
			
		|||
 | 
			
		||||
migration_num=0;
 | 
			
		||||
 | 
			
		||||
while [ -f sql/migration_$migration_num.sql ]
 | 
			
		||||
while [ -f ./sql/migration_$migration_num.sql ]
 | 
			
		||||
do
 | 
			
		||||
  xxd -i sql/migration_$migration_num.sql | sed 's/\([0-9a-f]\)$/\0, 0x00/' > include/migrations/$migration_num.sql.h
 | 
			
		||||
  ((migration_num++));
 | 
			
		||||
done;
 | 
			
		||||
    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++))
 | 
			
		||||
            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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue