Sp6 to Sp7 add missing constraints and tables#7643
Conversation
Triggered by 17da256 on branch refs/heads/issue-7551
|
I've added fixes for all of the unit tests that were failing in main. Currently, there are some unit tests failing specifically because of the new tables added from Specify 6 that have multi-field primary keys. This is causing issues with our django, datamodel, and sqlalchemy code. Working through different options for workarounds. |
|
Some of the new tables that need to be added from sp6 have multi-field primary keys, which is causing a lot of issues for our datamodel to sqlalchemy model generation. I create a solution where these will be present in the Django model, but skip the creation for the sqlalchemy model so we can go ahead and finish this issue. We can worry about the sqlalchemy version of the model another time. |
|
Got the many-to-many fields working in the Django model, and got the unit tests working. Ready for review. |
|
Looks good, thanks for removing those unused Specify 6 tables 👍 |
Fixes #7551
Fixes #7617
Fixes #7626
This PR adds Django model definitions, constraints, and migrations for several legacy join tables and related entities that were present in existing Specify databases but missing from freshly initialized Sp7 databases.
These changes are based on a systematic comparison between an existing production database schema and a newly created schema, with the goal of ensuring that new databases accurately reflect the constraints and relationships relied on by legacy data and workflows.
Here is a link to an example of the difference between an Sp6 and Sp7 created database schema dump: https://www.diffchecker.com/qdMfXJCj/
After analyzing many different schema dumps, the schema differences between databases creation in Sp6 and Sp7, the following was found for constant differences:
16 Missing Foreign Key Constraints:
0 missing unique constraints were found, actually Sp7 create database had a few extra unique constrains compared to Sp6 created databases.
32 Missing Primary Key Constraints (Mostly due to unused tables not used in Sp7):
Missing / changed PRIMARY KEYs: 35
The following tables were identified in the schema diff but were not added in this PR because they are legacy, client specific, or no longer used by current Specify workflows:
These tables appear to not be required for new database creation or normal application operation, but let me know if any of these should be added.
Checklist
self-explanatory (or properly documented)
Testing instructions
mariadb-dump -uroot -proot --no-data db_name > dbname_schema.sql