Bipin Raut
Bipin Raut

Reputation: 106

rest_framework authtoken migration error

Unable to complete migration for rest_framework.authtoken

Running migrations for authtoken:
- Migrating forwards to 0001_initial.
authtoken:0001_initial
FATAL ERROR - The following SQL query failed: ALTER TABLE "authtoken_token" ADD CONSTRAINT "user_id_refs_id_14b35167" FOREIGN KEY ("user_id") REFERENCES "users_user" ("id") DEFERRABLE INITIALLY DEFERRED; Error in migration: authtoken:0001_initial
DatabaseError: relation "users_user" does not exist

Using version djangorestframework-2.3.8

Upvotes: 3

Views: 1178

Answers (2)

Mars
Mars

Reputation: 534

Because of the custom user table name the migration isn't happening. Go to the initial migration and specify your user table using db_table in the migration where the code is trying to access your custom table. That should work.

Upvotes: 2

Armance
Armance

Reputation: 5390

are you using a custom user model?

if this was the case the migration code for the app implementing the user model should look like:

class Migration(SchemaMigration):
    needed_by = (
        ('oauthtoken', '0001_initial'),
    )

Upvotes: 0

Related Questions