Bug 16170: Pseudo foreign key in Items
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Wed, 23 Mar 2016 15:59:26 +0000 (16:59 +0100)
committerKyle M Hall <kyle@bywatersolutions.com>
Tue, 3 May 2016 15:01:12 +0000 (15:01 +0000)
commit33694a8faac22e760e0559d99a9d013f7c90275b
treee597a7c95f7cecdefd75b255857db675bdc3a076
parent614fe34d863014aef9bb65a23b8c3118759fcced
Bug 16170: Pseudo foreign key in Items

While many of us would like to get rid of biblioitems one day, the current
scheme includes a biblioitemnumber and a biblionumber in Items.
(Which is not so great..)

But also note that biblionumber is NOT defined as a foreign key in Items,
although a belongs_to relation has been added to the DBIx scheme!
This inconsistency should be resolved. The "remove biblioitem table"
operation is a large one, but in the meantime we better make biblionumber
a regular FK not a 'pseudo' one.

Note: If in an (very) exceptional case biblionumbers are found in items,
that do not exist in biblio, this patch prints a warning at upgrade
time and does not add the constraint.

@RM: Please update the DBIx scheme accordingly.

Test plan:
[1] Run the upgrade. Check if the FK constraint has been added.
[2] Remove the FK constraint. Change the biblionumber of one item to an
    unexisting record. Run the upgrade again. Notice the warning.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Tested both cases: constraint added as well as warning printed.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
installer/data/mysql/atomicupdate/16170_dbrev.perl [new file with mode: 0644]
installer/data/mysql/kohastructure.sql