Skip to content

Issue 8124 8126 fix 7660 7682 2 6266 after review#8154

Open
melton-jason wants to merge 117 commits into
v7_12_0_7_basefrom
issue-8124-8126-fix-7660-7682-2-after-review-2
Open

Issue 8124 8126 fix 7660 7682 2 6266 after review#8154
melton-jason wants to merge 117 commits into
v7_12_0_7_basefrom
issue-8124-8126-fix-7660-7682-2-after-review-2

Conversation

@melton-jason

@melton-jason melton-jason commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Taken from #8142 (comment) by @CarolineDenis:

Fixes #8124
Fixes #8126
Fixes #8101
Fixes #8065

Checklist

  • Self-review the PR after opening it to make sure the changes look good and
    self-explanatory (or properly documented)
  • Add relevant issue to release milestone
  • Add pr to documentation list
  • Add automated tests
  • Add a reverse migration if a migration is present in the PR
  • Add migration function to
    def fix_schema_config(stdout: WriteToStdOut | None = None):

Testing instructions

Summary by CodeRabbit

  • Bug Fixes

    • Corrected schema configuration references in data migrations
    • Fixed discipline and tree definition linking issues
    • Improved admin and permission initialization logic
    • Enhanced query logging controls based on debug settings
  • Refactor

    • Streamlined migration utilities for improved efficiency
    • Simplified multi-database routing during migrations
    • Optimized permission seeding with per-user checks
    • Restructured role assignment logic using set-based operations
  • Chores

    • Removed legacy debugging code and unused migration helpers
    • Updated function signatures to remove unnecessary parameters

Fix: compare full rule definitions before deleting anything in uniqueness

(cherry picked from commit c61a530)
(cherry picked from commit b1f0346)
(cherry picked from commit d4c0231)
(cherry picked from commit bab5083)
(cherry picked from commit 11b6608)
(cherry picked from commit af4c963)
(cherry picked from commit 57bca64)
(cherry picked from commit e07aaeb)
(cherry picked from commit b183031)
(cherry picked from commit 2e9e4ad)
(cherry picked from commit 2254fc4)
(cherry picked from commit d8bd82d)
CarolineDenis and others added 29 commits June 17, 2026 10:56
Compartmentalize migration code

@grantfitzsimmons grantfitzsimmons left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Dev Attention Needed

3 participants