# This is a simple example, so in practice you’d need to handle duplicates carefully
content = assoc_map.flat_map do |from_table, to_tables|
  to_tables.map { |to_table| %(add_foreign_key "#{from_table}", "#{to_table[:table_name]}", column: "#{to_table[:column_name]}") }
end.join("\n")