Improve `sg migration`/`migrator` `drift` recommendations
Created by: efritz
Currently the drift command gives you only the diff of what's wrong. It would also be useful to either suggest hints on how to construct/reconstruct the items that are different (with listed caveats). These are sometimes simple:
- a missing index can just run the associated definition (with a caveat that maybe we tried to create it concurrently initially, or that duplicate values may exist if the index was unique and was missing for a period of time)
- a missing view can be recreated just by running the associated definition with newlines replaced from the json output
There are also more complex issues:
- we store column definitions but would have to reconstruct the SQL text to recommend something runnable to the user
- ordering of object creation matters if there are dependencies, so we can't resolve things in a correct order automatically
- modify type is limited and additional values will require a change on all views and tables that depend on that type; not something we'd want to perform non-manually as there's a lot of minutiae on this transform
One interesting blanket solution would be to:
- ensure that each commit has an up-to-date "squashed" version of migrations for each schema (we can add this to schemadoc generation so it doesn't affect developers)
- when we see a diff, we give a sourcegraph.com search link for that particular file/revision to guide the user to an automated source of truth to help them self-serve schema restorations