[Koha-bugs] [Bug 18050] Missing constraint foreign key on table aqbudget

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Sun Apr 19 03:42:37 CEST 2020


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18050

--- Comment #1 from Katrin Fischer <katrin.fischer at bsz-bw.de> ---
(In reply to Baptiste from comment #0)
> There is not foreign key constraint on the column budget_parent_id in the
> table aqbudget.
> It is so possible to delete a budget without deleting the associated fund.

2835 DROP TABLE IF EXISTS `aqbudgets`;
2836 CREATE TABLE `aqbudgets` ( -- information related to Funds
2837   `budget_id` int(11) NOT NULL auto_increment, -- primary key and unique
number assigned to each fund by Koha
2838   `budget_parent_id` int(11) default NULL, -- if this fund is a child of
another this will include the parent id (aqbudgets.budget_id)
...
2850   `budget_owner_id` int(11) default NULL, -- borrowernumber of the person
who owns this fund (borrowers.borrowernumber)
2851   `budget_permission` int(1) default '0', -- level of permission for this
fund (used only by the owner, only by the library, or anyone)
2852   PRIMARY KEY  (`budget_id`),
2853   KEY `budget_parent_id` (`budget_parent_id`),
2854   KEY `budget_code` (`budget_code`),
2855   KEY `budget_branchcode` (`budget_branchcode`),
2856   KEY `budget_period_id` (`budget_period_id`),
2857   KEY `budget_owner_id` (`budget_owner_id`)
2858 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

budget_parent_id could have a constraint on aqbudgetperiods.budget_period_id

budget_owner_id should probably be an FK on borrowers.borrowernumber

Both should be still allowed to be empty (NULL), as they don't need to always
be set.

Then we got:

budget_id = fund ID
budget_parent_id = used for child/sub funds to link them to the parent. 
I am not sure if you can have a FK constraint on another column in the same
table?

I can add the changes to the kohastructure and via updatedatabase, but not sure
what 'false' date we might expect to clean up here.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list