hovel/pybbm — pull request #124 by caioariede (2014-04-01 22:54:59+00:00)
Title: Migrations breaking when using custom user model

I found several problems with the current migrations, when using a custom user model.

**1. They are not fully translated to work with a custom user model** (eg. below)

https://github.com/hovel/pybbm/blob/master/pybb/migrations/0001_initial.py#L111

**2. M2M relations are using incorrect column names** (eg. below)

https://github.com/hovel/pybbm/blob/master/pybb/migrations/0001_initial.py#L113

*Note: this will work when you have a custom user model named "User", but it doesn't work if you're using a different name, say "CustomUser"*

**3. The list of frozen models doesn't contain the custom user model** (eg. below)

https://github.com/hovel/pybbm/blob/master/pybb/migrations/0001_initial.py#L168

**4. Migrations are being skipped on tests**

https://github.com/hovel/pybbm/blob/master/runtests.py#L75

Since `south` isn't on `INSTALLED_APPS`.

The other migrations are affected as well.

Proposed solution
---

* Make things more DRY: use `util.get_user_model_path` on migrations
* Rewrite migrations to make it fully compatible with custom user models
* Use `util.get_user_frozen_models` to get the correct schema for migrations
* If using a custom user model, make `0001_initial` dependent of the migration specified on `PYBB_INITIAL_CUSTOM_USER_MIGRATION`. Just illustrating: `depends_on = ((custom_user_app, PYBB_INITIAL_CUSTOM_USER_MIGRATION),)`
* Make migrations run during tests (add "south" to `INSTALLED_APPS`)