-
Notifications
You must be signed in to change notification settings - Fork 13
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
refactor: extract base model from member service #532
base: master
Are you sure you want to change the base?
Conversation
We might need to some som manual migration trickery like in this stackoverflow thread (expect we want to do the opposite) |
Code changes look good assuming that the new extra fields are meaningless but this likely needs database migrations? @tswfi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Good idea.
yup, this will probably require a manual migration file to be written. Django is usually pretty good at generating the migrations automatically but that seems to not be the case here.. Also we might want consider using a global base model that always adds things like The base model should also be marked as Abstract https://docs.djangoproject.com/en/5.1/topics/db/models/#abstract-base-classes as it should probably never be used directly. |
I converted this to draft so it is not merged before at least the migration is ok |
@tswfi's suggestion about making the class abstract solved the migration problem! I ended up removing the service_id field since it is probably superfluous given that there already is an ID field under the hood (in the base model, I reckon). Having a special unique identifier on top of that feels too use case specific to include in the base model. |
Here I am trying to extract the most general fields of a service, stripping away anything that is lab-specific or assumes a certain kind of way of doing things.
see #531 for the reasoning behind this.
I have come across a problem with this approach:
It seems we can't retroactively tell Django that a model wants to become a child of another model due to a (presumably) required foreign to the other model.