Issue 8124 8126 fix 7660 7682 2 6266 after review#8154
Conversation
(cherry picked from commit ab5b3e3)
(cherry picked from commit 60a6797)
(cherry picked from commit f58c785)
(cherry picked from commit 2c3b7d5)
(cherry picked from commit c452f7d)
Fix: compare full rule definitions before deleting anything in uniqueness (cherry picked from commit c61a530)
(cherry picked from commit ef0eed0)
(cherry picked from commit b1f0346)
(cherry picked from commit 00fe897)
(cherry picked from commit c633180)
(cherry picked from commit d4c0231)
(cherry picked from commit 9953d6a)
(cherry picked from commit 8c9cc13)
(cherry picked from commit 6381382)
(cherry picked from commit bab5083)
(cherry picked from commit 28b9f5b)
(cherry picked from commit 11b6608)
(cherry picked from commit af4c963)
(cherry picked from commit 57bca64)
(cherry picked from commit 00a21ef)
(cherry picked from commit 3da5761)
(cherry picked from commit e07aaeb)
(cherry picked from commit 36b307c)
(cherry picked from commit d97acbd)
(cherry picked from commit d3c6c98)
(cherry picked from commit b183031)
(cherry picked from commit 2e9e4ad)
(cherry picked from commit 2254fc4)
(cherry picked from commit 39b001a)
(cherry picked from commit d8bd82d)
…after-review-2' into issue-8058
Compartmentalize migration code
There was a problem hiding this comment.
This review was kind of a mess so I reformatted using Gemini.
Good news is that it works!
Databases tested:
| Database | Discipline |
|---|---|
aumnh_fish_2026_06_26 |
Ichthyology |
alfmuseum_2026_06_26 |
Multi |
aumnh_herbarium_2026_06_26 |
Botany |
aumnh_inverts_2026_06_26 |
Invertebrate |
bohart_entomology_2026_06_26 |
Entomology |
calvertmarinemuseum_2026_06_26 |
Multi |
Forward Migrations PASS ✅
Every database tested shows "No migrations to apply", the branch's migrations are already present.
Reverse Migrations, Core Apps Pass, Permissions Fail 🔴
| App | Status | Notes |
|---|---|---|
workbench (8 migrations) |
✅ PASS | All reverse cleanly |
setup_tool (1) |
✅ PASS | All reverse cleanly |
businessrules (9) |
✅ PASS | All reverse cleanly |
specify (44) |
✅ PASS | All reverse cleanly (0023→0044) |
patches (8) |
✅ PASS | All reverse cleanly |
notifications (6) |
✅ PASS | All reverse cleanly |
accounts (3) |
✅ PASS | All reverse cleanly |
attachment_gw (1) |
✅ PASS | All reverse cleanly |
permissions (8) |
❌ FAIL | Not reversible — 0008 crashes |
Permission reverse failure is expected and was pre-acknowledged by @melton-jason
Schema Config (splocale*)
From the 0023_update_schema_config_text migration logs, the revert function properly processes Schema Config items per table:
CollectionObjectGroup: 17 items reverted
CollectionObjectGroupJoin: 10 items reverted
AbsoluteAge: 12 items reverted
RelativeAge: 14 items reverted
TectonicUnit: 7 items reverted
TectonicUnitTreeDefItem: 5 items reverted
CollectionObject: 4 items reverted
TectonicUnitTreeDef: 2 items reverted
CollectionObjectType: 4 items reverted
CollectionObjectGroupType: 1 item reverted
AbsoluteAgeCitation: 1 item reverted
RelativeAgeCitation: 1 item reverted
All re-applied cleanly on forward migration with matching item counts.
TectonicUnit Trees ✅
Migration 0009_tectonic_ranks creates:
- 6 ranks per tree (Root, Superstructure, Tectonic Domain, Tectonic Subdomain, Tectonic Unit, Tectonic Subunit)
- Root nodes where missing (with nodenumber=1, isaccepted=1)
- Trees for Disciplines that lack them
Reverse deletes all trees (nodes → ranks → defs → discipline associations). This is a data-loss operation but the trees are reconstructed on re-apply with identical structure (just new primary keys).
Uniqueness Rules ✅
businessrules.0006 and 0007 successfully create rules on apply:
- Storage.uniqueIdentifier → Global scope
- Deaccession.deaccessionNumber → Global
- Disposal.disposalNumber → Global
- ExchangeOut.exchangeOutNumber → Division scope (Global)
- AccessionAuthorization.permit → scoped to accession/repositoryAgreement (per discipline)
- CollectingEventAuthorization.permit → scoped to collectingEvent (per discipline)
- CollectingTripAuthorization.permit → scoped to collectingTrip (per discipline)
Some notes
We might want to put a warning for the 0009 migration since it deletes TectonicUnit trees on reverse? I imagine if you are reversing you know the risks. There are also some model changes in the specify app that we should resolve.
Taken from #8142 (comment) by @CarolineDenis:
Fixes #8124
Fixes #8126
Fixes #8101
Fixes #8065
Checklist
self-explanatory (or properly documented)
specify7/specifyweb/specify/management/commands/run_key_migration_functions.py
Line 50 in ea04665
Testing instructions
Summary by CodeRabbit
Bug Fixes
Refactor
Chores