Adjust schema generation to handle foreign keys properly and in sequence.