redo models/migrations, improve robustness

- make couchforms tests pass
- add a lot of Doc.get_db().* functionality
- fix _attachment json
- scrap _sql_rev on doc and save that in the _rev position