3

I'm trying to perform a database migration to create the necessary tables for API Key authentication via tastypie and south. This requires that I run python manage.py migrate tastypie. The output is:

Running migrations for tastypie:
Migrating forwards to 0002_add_apikey_index. 
tastypie:0001_initial
FATAL ERROR - The following SQL query failed: 
ALTER TABLE "tastypie_apikey"
ADD CONSTRAINT "user_id_refs_id_ac46cea0"
FOREIGN KEY ("user_id") REFERENCES "nox_customuser" ("id") DEFERRABLE INITIALLY DEFERRED;
The error was: relation "nox_customuser" does not exist

I've implemented a custom user model, CustomUser(AbstractBaseUser), which has worked just fine to this point. In its meta class, I've set db_table = "custom_user".

The problem seems to be that South is not recognizing my name for the table, and is using the default naming scheme instead. If I were to change the relation in the failing query from "nox_customuser" to "custom_user", everything should work as expected.

How can I make that fix using South?

Chris Travers
  • 25,424
  • 6
  • 65
  • 182
dcapotation
  • 133
  • 6
  • I still believe this is a South bug, but there is a workaround. Inside the `forwards` function of the migration script, I put: `orm[AUTH_USER_MODEL]._meta.db_table= "custom_user"` – dcapotation Jul 21 '13 at 22:13

0 Answers0