FB 33239 add mutable document revision

See https://gist.github.com/mikerhodes/c022e9e44d83c2e4747e for mini spec (objective-c version)
There's not quite enough similarity to share string literals between them without making the code hard to read. There might be an argument to put all of the SQL queries in one place but if they're used once I don't mind them being next to the code that uses them.