Reversible migrations

Fixes #504