Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom User.db_table in TokenAuthentication migration. #2479

Merged
merged 1 commit into from Jan 28, 2015
Merged

Support custom User.db_table in TokenAuthentication migration. #2479

merged 1 commit into from Jan 28, 2015

Conversation

lucaswiman
Copy link

@lucaswiman lucaswiman commented Jan 28, 2015

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

@tomchristie
Copy link
Member

tomchristie commented Jan 28, 2015

Fair enough.

tomchristie added a commit that referenced this pull request Jan 28, 2015
Use the proper db_table argument when constructing meta
@tomchristie tomchristie merged commit 81c2562 into encode:master Jan 28, 2015
@tomchristie tomchristie changed the title Use the proper db_table argument when constructing meta Support custom User.db_table in TokenAuthentication migration. Jan 28, 2015
@tomchristie tomchristie added this to the 3.0.5 Release milestone Jan 28, 2015
@lucaswiman lucaswiman deleted the custom_user_shim_db_table branch Jan 28, 2015
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.

None yet

2 participants