[harmony] Bug 2052103: Drop FK references around altering attachment id type#157
Open
justdave wants to merge 4 commits into
Open
[harmony] Bug 2052103: Drop FK references around altering attachment id type#157justdave wants to merge 4 commits into
justdave wants to merge 4 commits into
Conversation
Member
Author
|
The generated POD docs can be viewed at https://bugzilla--157.org.readthedocs.build/projects/harmony/en/157/integrating/api/Bugzilla/DB.html#bz_fk_safe_alter_columns |
…safe_alter_columns POD
The refactor to bz_fk_safe_alter_columns passed only {TYPE => 'INT3'} as the
target definition for the flag*.type_id columns. Because bz_alter_column
replaces the entire column definition with what it is given, this dropped the
NOT NULL constraint that the previous _update_flagtypes_id code preserved (it
mutated only TYPE on the full current definition).
Add NOTNULL => 1 to the three type_id definitions so the constraint is retained,
matching Schema.pm. Also document in the POD that 'definition' must be the
complete desired column definition, and that the alteration check only compares
scalar attributes.
Exercises the new FK-safe column alteration helper against a bare Bugzilla::DB object with bz_column_info/bz_drop_related_fks/bz_alter_column mocked, keeping the test database-independent. Covers: the complete definition (including NOTNULL) being forwarded to bz_alter_column verbatim (the bug 2052103 regression guard), only_if_type gating for both scalar and arrayref forms, idempotency when no change is needed, drop-before-alter ordering, skipping of missing columns and incomplete fix specs, and ordered processing of multiple fixes.
ae3e1a6 to
635788a
Compare
mrenvoize
approved these changes
Jul 3, 2026
mrenvoize
left a comment
Contributor
There was a problem hiding this comment.
Generally looked good; I caught a couple of tiny oversights and I added a unit test for the added bz_fg_safe_alter_columns method (Koha habits requiring unit tests for everything die hard)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Details
Since this is dealt with in multiple places and I didn't want to duplicate code, I created a new helper function for this in
Bugzilla/DB.pmand converted the other location that already did this type of operation to also use that (most of the code in this function was taken from the flag ID migration code, but cleaned up to be a little more flexible).There are a few extensions which will also be getting updated to use this function, but they'll get their own bug reports and PRs.
Additional info
Test Plan
docker compose updocker compose downdocker compose upand watch the output to confirm that checksetup.pl no longer shows the foreign key error and makes it past where that was previously happening.