View | Details | Raw Unified | Return to bug 21983
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_21983_ill_fk.pl (+40 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "21983",
5
    description => "Deleted biblio handling on ILL",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
10
        unless ( column_exists( 'illrequests', 'deleted_biblio_id' ) ) {
11
            $dbh->do(q{
12
                ALTER TABLE illrequests
13
                    ADD COLUMN `deleted_biblio_id` int(11) DEFAULT NULL COMMENT 'Deleted bib linked to request'
14
                        AFTER `biblio_id`;
15
            });
16
            say $out "Added column 'illrequests.deleted_biblio_id'";
17
        }
18
19
        # Move deleted biblio_id to deleted_biblio_id before setting the FK
20
        $dbh->do(q{
21
            UPDATE    illrequests
22
            LEFT JOIN biblio
23
            ON illrequests.biblio_id=biblio.biblionumber
24
            SET illrequests.biblio_id=NULL,
25
                illrequests.deleted_biblio_id=illrequests.biblio_id
26
            WHERE     biblio.biblionumber IS NULL
27
                  AND illrequests.biblio_id IS NOT NULL
28
        });
29
30
        unless ( foreign_key_exists( 'illrequests', 'illrequests_bibfk' ) ) {
31
            $dbh->do(q{
32
                ALTER TABLE illrequests
33
                    ADD KEY `illrequests_bibfk` (`biblio_id`),
34
                    ADD FOREIGN KEY illrequests_bibfk (`biblio_id`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE;
35
            });
36
37
            say $out "Added foreign key constraint 'illrequests.illrequests_bibfk'";
38
        }
39
    },
40
};
(-)a/installer/data/mysql/db_revs/221200026.pl (+20 lines)
Lines 7-12 return { Link Here
7
        my ($args) = @_;
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
9
10
        unless ( column_exists( 'illrequests', 'deleted_biblio_id' ) ) {
11
            $dbh->do(q{
12
                ALTER TABLE illrequests
13
                    ADD COLUMN `deleted_biblio_id` int(11) DEFAULT NULL COMMENT 'Deleted bib linked to request'
14
                        AFTER `biblio_id`;
15
            });
16
            say $out "Added column 'illrequests.deleted_biblio_id'";
17
        }
18
19
        # Move deleted biblio_id to deleted_biblio_id before setting the FK
20
        $dbh->do(q{
21
            UPDATE    illrequests
22
            LEFT JOIN biblio
23
            ON illrequests.biblio_id=biblio.biblionumber
24
            SET illrequests.biblio_id=NULL,
25
                illrequests.deleted_biblio_id=illrequests.biblio_id
26
            WHERE     biblio.biblionumber IS NULL
27
                  AND illrequests.biblio_id IS NOT NULL
28
        });
29
10
        unless ( foreign_key_exists( 'illrequests', 'illrequests_bibfk' ) ) {
30
        unless ( foreign_key_exists( 'illrequests', 'illrequests_bibfk' ) ) {
11
            $dbh->do(q{
31
            $dbh->do(q{
12
                ALTER TABLE illrequests
32
                ALTER TABLE illrequests
(-)a/installer/data/mysql/kohastructure.sql (-1 / +1 lines)
Lines 3294-3299 CREATE TABLE `illrequests` ( Link Here
3294
  `illrequest_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ILL request number',
3294
  `illrequest_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ILL request number',
3295
  `borrowernumber` int(11) DEFAULT NULL COMMENT 'Patron associated with request',
3295
  `borrowernumber` int(11) DEFAULT NULL COMMENT 'Patron associated with request',
3296
  `biblio_id` int(11) DEFAULT NULL COMMENT 'Potential bib linked to request',
3296
  `biblio_id` int(11) DEFAULT NULL COMMENT 'Potential bib linked to request',
3297
  `deleted_biblio_id` int(11) DEFAULT NULL COMMENT 'Deleted bib linked to request',
3297
  `due_date` datetime DEFAULT NULL COMMENT 'Custom date due specified by backend, leave NULL for default date_due calculation',
3298
  `due_date` datetime DEFAULT NULL COMMENT 'Custom date due specified by backend, leave NULL for default date_due calculation',
3298
  `branchcode` varchar(50) NOT NULL COMMENT 'The branch associated with the request',
3299
  `branchcode` varchar(50) NOT NULL COMMENT 'The branch associated with the request',
3299
  `status` varchar(50) DEFAULT NULL COMMENT 'Current Koha status of request',
3300
  `status` varchar(50) DEFAULT NULL COMMENT 'Current Koha status of request',
3300
- 

Return to bug 21983