Pr/325

Tests are WIP. Not yet ready to merge.
I should mentioned I didn't have time (and won't for a month, holidays) to port the functionality over to postgres & sqlite. For now, this is a mysql only feature.

Closes #325