generate_sql taking an array of indexes to create is slightly less understandable than it prob could be? Perhaps if you did something like moving the loop to out here on the array of indices to create it would be clearer? That way someone could probably guess at how it worked from here rather than needing to read schemaIndices as well.

Perhaps we will want to consider a refactor of 'capture' in the future as well as the whole thing feels pretty messy but just thought I'd send the feedback regardless.