Koha-clms/installer/data/mysql/atomicupdate
Martin Renvoize 32e8a3a2ba
Bug 34000: Add autoMemberNumValue system preference
Introduces a new system preference, autoMemberNumValue, which tracks
the highest auto-generated cardnumber ever issued. It is seeded from
the MAX cardnumber across both borrowers and deletedborrowers so
pre-upgrade deletions do not free numbers for re-issuance.

This preference is managed internally by Koha::Patron::fixup_cardnumber
and has no UI (no YAML entry).

Test plan:
1. Apply the atomicupdate:
   perl installer/data/mysql/updatedatabase.pl
2. Verify the preference exists:
   SELECT * FROM systempreferences WHERE variable = 'autoMemberNumValue';
3. Confirm the seed value matches:
   SELECT GREATEST(
       COALESCE((SELECT MAX(CAST(cardnumber AS SIGNED)) FROM borrowers
                 WHERE cardnumber REGEXP '^-?[0-9]+\$'), 0),
       COALESCE((SELECT MAX(CAST(cardnumber AS SIGNED)) FROM deletedborrowers
                 WHERE cardnumber REGEXP '^-?[0-9]+\$'), 0)
   );
4. Re-run the atomicupdate and confirm the already-exists warning.
5. Drop the syspref, re-apply the atomicupdate, confirm it seeds
   correctly on fresh installs via mandatory/sysprefs.sql.

Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
2026-04-22 20:18:26 +01:00
..
README Bug 39392: Fix typos in atomicupdate README 2025-08-06 17:14:22 +02:00
bug_34000.pl Bug 34000: Add autoMemberNumValue system preference 2026-04-22 20:18:26 +01:00
skeleton.pl Bug 38394: Remove existing try/catch and say_failure from DB revs 2024-11-07 16:29:20 +01:00

README

Please put your database revision files in this folder.
The Release Manager will remove them from here when pushing your patches.

To use the skeleton.pl for your update:

% cp installer/data/mysql/atomicupdate/skeleton.pl
installer/data/mysql/atomicupdate/bug_XXXXX.pl

and put your modifications in where noted.