-
Notifications
You must be signed in to change notification settings - Fork 40
Add missing autonum and spprincipal tables in django #7621
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
Changes from all commits
8d2693d
a5b81ee
dce2345
80f3fdc
41e149e
18b8e19
9151183
47ecfca
eb5d0cf
bef0c95
342d13e
c951748
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7988,4 +7988,53 @@ class Meta: | |||||
| db_table = 'tectonicunit' | ||||||
| ordering = () | ||||||
|
|
||||||
| save = partialmethod(custom_save) | ||||||
| save = partialmethod(custom_save) | ||||||
|
|
||||||
| class AutonumSchColl(models.Model): | ||||||
| collection = models.ForeignKey("Collection", db_column="CollectionID", on_delete=models.CASCADE) | ||||||
| autonumberingscheme = models.ForeignKey("AutoNumberingScheme", db_column="AutoNumberingSchemeID", on_delete=models.CASCADE) | ||||||
|
|
||||||
| class Meta: | ||||||
| db_table = "autonumsch_coll" | ||||||
| unique_together = (("collection", "autonumberingscheme"),) | ||||||
| indexes = [ | ||||||
| models.Index(fields=["autonumberingscheme"], name="FK46F04F2AFE55DD76"), | ||||||
| models.Index(fields=["collection"], name="FK46F04F2A8C2288BA"), | ||||||
|
Comment on lines
+8001
to
+8002
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Django should actually index ForeignKeys it creates by default, so these explicit indexes shouldn't be needed:
https://docs.djangoproject.com/en/4.2/ref/models/fields/#foreignkey For an example, here's the indexes from the
specify7/specifyweb/backend/permissions/migrations/0002_role_rolepolicy_userrole.py Line 22 in 1e8a448
Could we remove the indexes declared explicitly on Foreign Keys in this PR? |
||||||
| ] | ||||||
|
|
||||||
| class AutonumSchDiv(models.Model): | ||||||
| division = models.ForeignKey("Division", db_column="DivisionID", on_delete=models.CASCADE) | ||||||
| autonumberingscheme = models.ForeignKey("AutoNumberingScheme", db_column="AutoNumberingSchemeID", on_delete=models.CASCADE) | ||||||
|
|
||||||
| class Meta: | ||||||
| db_table = "autonumsch_div" | ||||||
| unique_together = (("division", "autonumberingscheme"),) | ||||||
| indexes = [ | ||||||
| models.Index(fields=["autonumberingscheme"], name="FKA8BE493FE55DD76"), | ||||||
| models.Index(fields=["division"], name="FKA8BE49397C961D8"), | ||||||
| ] | ||||||
|
|
||||||
| class AutonumSchDsp(models.Model): | ||||||
| discipline = models.ForeignKey("Discipline", db_column="DisciplineID", on_delete=models.CASCADE) | ||||||
| autonumberingscheme = models.ForeignKey("AutoNumberingScheme", db_column="AutoNumberingSchemeID", on_delete=models.CASCADE) | ||||||
|
|
||||||
| class Meta: | ||||||
| db_table = "autonumsch_dsp" | ||||||
| unique_together = (("discipline", "autonumberingscheme"),) | ||||||
| indexes = [ | ||||||
| models.Index(fields=["autonumberingscheme"], name="FKA8BE5C3FE55DD76"), | ||||||
| models.Index(fields=["discipline"], name="FKA8BE5C34CE675DE"), | ||||||
| ] | ||||||
|
|
||||||
| class SpecifyuserSpprincipal(models.Model): | ||||||
| specifyuser = models.ForeignKey('SpecifyUser', db_column='SpecifyUserID', on_delete=models.deletion.DO_NOTHING) | ||||||
| spprincipal = models.ForeignKey('SpPrincipal', db_column='SpPrincipalID', on_delete=models.deletion.DO_NOTHING) | ||||||
|
Comment on lines
+8030
to
+8031
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is still the DO_NOTHING |
||||||
|
|
||||||
| class Meta: | ||||||
| db_table = 'specifyuser_spprincipal' | ||||||
| ordering = () | ||||||
| unique_together = (('specifyuser', 'spprincipal'),) | ||||||
| indexes = [ | ||||||
| models.Index(fields=['specifyuser'], name='FK81E18B5E4BDD9E10'), | ||||||
| models.Index(fields=['spprincipal'], name='FK81E18B5E99A7381A'), | ||||||
| ] | ||||||
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.
We did have a convention in the past where we expected to have the Django model class names be in a certain case: where the first letter in the class name is capitalized and all other letters are lowercase.
Here are some related commits I could find:
22d1f06
de2e08c
This specific convention was needed when we were dynamically fetching the model from the models class.
Did we do some work to alleviate the need of the convention?
I did a regular expression search of
getattr\((.*models)within our Python files and it looks like (for non-tree classes) having them named this way might at least break WorkBench/BatchEdit DataSets the tables are in, as well as queries.There may be other places which would break when interacting with these classes.