Merge everything into generate.sql and tie up some loose ends