Skip to content

[harmony] Bug 2052103: Drop FK references around altering attachment id type#157

Open
justdave wants to merge 4 commits into
mainfrom
bug-2052103-harmony
Open

[harmony] Bug 2052103: Drop FK references around altering attachment id type#157
justdave wants to merge 4 commits into
mainfrom
bug-2052103-harmony

Conversation

@justdave

@justdave justdave commented Jul 2, 2026

Copy link
Copy Markdown
Member

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.pm and 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

  1. docker compose up
  2. Used the Files tab in Docker Desktop to drop a mysqldump of a Bugzilla 5.0.4 install into /root on the database image
  3. Used the Exec tab in Docker Desktop to restore that dump into the database
  4. docker compose down
  5. docker compose up and watch the output to confirm that checksetup.pl no longer shows the foreign key error and makes it past where that was previously happening.

@justdave justdave requested review from dylanwh and mrenvoize July 2, 2026 08:30
@justdave

justdave commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

mrenvoize added 2 commits July 3, 2026 12:23
…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.
@mrenvoize mrenvoize force-pushed the bug-2052103-harmony branch from ae3e1a6 to 635788a Compare July 3, 2026 11:23

@mrenvoize mrenvoize left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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)

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants