vsemionov / boomerang

An experimental web application

Home Page:https://boomerang-core.herokuapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

api_notebook.user_id field is shorter than the referenced field

vsemionov opened this issue · comments

auth_user.username is varchar(150)
api_notebook.user_id is varchar(30)

bin/populate.sh worked in the past with uuid usernames, but now it fails because uuid length is 36 and doesn't fit in user_id

I think the reason for this behavior is the undocumented swappable property of the User model. It is designed to be replaceable by custom models. However, the configured model must have its data in the initial migration of the app that defines the model. The migrations code seems to generate references to the initial migration of swappable models. I am using the default User model, and its initial migration sets the username to 30 chars. Hence my username FKs are 30 chars long. I am able to work around this with a RunSQL migration to alter the FK data type to varchar(15), but I am in doubt if it's the right thing to do.

It is left to explain how the populate script worked before. It is possible that it worked at a time when user child objects referred to users by id instead of username and joins were performed to handle user child requests.

Leaving it as it is for now. Added commit 789d73c with a note about a known bug, a fix for the populator and a potential migration as a workaround that can be applied later.