Bug 8480 - auth_subfield_structure is not cleared when deleting an authority type
Summary: auth_subfield_structure is not cleared when deleting an authority type
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Staff interface (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Jonathan Druart
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-20 09:33 UTC by Gaetan Boisson
Modified: 2015-12-03 22:11 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 8480: Add constraint on auth_subfield_structure.authtypecode (2.90 KB, patch)
2015-03-31 11:27 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 8480: Add constraint on auth_subfield_structure.authtypecode (3.41 KB, patch)
2015-04-14 06:59 UTC, Frédéric Demians
Details | Diff | Splinter Review
[PASSED QA] Bug 8480: Add constraint on auth_subfield_structure.authtypecode (3.47 KB, patch)
2015-04-21 05:46 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Gaetan Boisson 2012-07-20 09:33:17 UTC
To reproduce :
- in authtypes.pl create a new authority type
- have a look at it's MARC structure and fill it with the default type for instance
- delete it
- in the database the auth_subfield_structure table was not properly cleared : auth_type and auth_tag_structure were properly cleared but all the subfields for the test authority type are still there.
Comment 1 Jonathan Druart 2015-03-31 11:27:39 UTC Comment hidden (obsolete)
Comment 2 Jonathan Druart 2015-03-31 11:28:24 UTC
Note that this is also valid for marc_subfield_structure (I can provide a patch if this patch is accepted).
Comment 3 Frédéric Demians 2015-04-14 06:59:21 UTC Comment hidden (obsolete)
Comment 4 Katrin Fischer 2015-04-21 05:46:27 UTC
Created attachment 38226 [details] [review]
[PASSED QA] Bug 8480: Add constraint on auth_subfield_structure.authtypecode

In order not to have useless entries in the auth_subfield_structure
table, this patch modifies the DB structure to add a foreign key on the
authtypecode column.
Note that the auth_tag_structure already has this constraint.

Test plan:
0/ Don't apply this patch
1/ Create a now authority type 'RM_ME'
2/ Look at the MARC structure, to create the subfield structure and
populate the auth_subfield_structure table.
3/ Delete the authority type
4/ Using your SQL cli:
 SELECT COUNT(*) FROM auth_subfield_structure WHERE authtypecode='RM_ME';
=> The data are still in this table.
5/ Apply this patch
6/ Execute the updatedb entry
7/ Confirm the entries in the auth_subfield_structure table related to
RM_ME have been deleted
8/ Repeat 1, 2 and 3 and verify the auth_subfield_structure entries have
been correctly removed.

Signed-off-by: Frederic Demians <f.demians@tamil.fr>
- Works exactly as described in the (very good) test plan.
- After authority type deletion, auth_subfield_structure still contains
  entries for deleted authority type. Applying the patch clean the
  previously undeleted records in auth_subfield_strucute. Now deleting a
  authority type cleans propertly all appropriate records in
  auth_subfield_structure.
- Fix a merge conflict

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 5 Tomás Cohen Arazi (tcohen) 2015-05-18 14:26:03 UTC
Patches pushed to master.

Thanks "funny" Jonathan! :-P