Make annotation data migration more friendly

This commit makes sure data migration 0019 isn't run if there are not class
instances. This is for instance the case on new installations.
Properly use ORM models in migration 0020

Using the models directly isn't safe, because these models could change in the
future.