Fix migration for custom users

This adds custom user model support to the migrations. It's based on the technique used by [django-reversion](https://github.com/etianen/django-reversion/blob/e956571541ced6e53f2404dab5a6404be6ac8b4c/src/reversion/migrations/0001_initial.py#L7)