Skip to content

Conversation

@lucaswiman
Copy link

This pull request handles the somewhat special case of using a custom user model with a custom db_table attribute. When migrating a pre-existing database that was using the auth.User model, one guide for doing so recommends creating a custom user table where db_table = 'auth_user' so that few database migrations are required.

This pull request updates the Meta parameters passed for the custom user model to include the db_table from the real settings.AUTH_USER_MODEL model.

Without this change, using a custom db_table attribute leads to errors like the following:

FATAL ERROR - The following SQL query failed: ALTER TABLE "authtoken_token" ADD CONSTRAINT "user_id_refs_id_79b40daa" FOREIGN KEY ("user_id") REFERENCES "custom_user_user" ("id") DEFERRABLE INITIALLY DEFERRED;
The error was: relation "custom_user_user" does not exist

@lovelydinosaur
Copy link
Contributor

Fair enough.

lovelydinosaur added a commit that referenced this pull request Jan 28, 2015
Use the proper db_table argument when constructing meta
@lovelydinosaur lovelydinosaur merged commit 81c2562 into encode:master Jan 28, 2015
@lovelydinosaur lovelydinosaur changed the title Use the proper db_table argument when constructing meta Support custom User.db_table in TokenAuthentication migration. Jan 28, 2015
@lovelydinosaur lovelydinosaur added this to the 3.0.5 Release milestone Jan 28, 2015
@lucaswiman lucaswiman deleted the custom_user_shim_db_table branch January 28, 2015 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants