Ensure all column names are generated before assigning foreign keys.