Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 757
Bipin Raut Avatar asked Jul 01 '26 00:07

Bipin Raut


1 Answers

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.

like image 146
Mars Avatar answered Jul 02 '26 14:07

Mars