Bug 12601: Add a foreign key for aqorders.budget_id
authorJonathan Druart <jonathan.druart@biblibre.com>
Fri, 18 Jul 2014 10:34:07 +0000 (12:34 +0200)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Thu, 5 Feb 2015 18:16:32 +0000 (15:16 -0300)
commit135f98ee620cff5eb76d7fff64c767b0cb49cef1
treeb86398e270f55060feabc652f7da409dbd645f6b
parent6fd9c909014b488bb383e0488a539512fae39bc2
Bug 12601: Add a foreign key for aqorders.budget_id

When creating an order, the fund value is mandatory but the DB structure
does not show this constraint.

The aqorders.budget_id field should be linked to aqbudgets.budget_id.

The updatedatabase.pl (entry 3.01.00.077) commented this constraint,
certainly for a retro compatibility reason.

Actually I found some cases (in production) where aqorders.budget_id is
set to "0". To add this constraint, we should add a temporary fund to
linked orphan orders.

Test plan:
0/ Verify it is not possible to create an order not linked to a fund via
the Koha interface.
1/ Using your SQL CLI (or equivalent), create or update 1+ orders and set
"0" in the budget_id field.
2/ Execute the updatedabase script.
3/ Verify that your order is linked to a new fund (which is linked to a
new budget).
4/ Verify the constraint has correctly been added (show create table
aqorders).

Signed-off-by: Paola Rossi <paola.rossi@cineca.it>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
installer/data/mysql/kohastructure.sql
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt