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

(-)a/installer/data/mysql/atomicupdate/bug_34520_item_groups_fk.pl (+30 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "34520",
5
    description => "Correct item_groups FK in reserves table",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
        if ( foreign_key_exists( 'reserves', 'reserves_ibfk_ig' ) ) {
11
            $dbh->do(
12
                q|
13
                ALTER TABLE reserves
14
                DROP FOREIGN KEY reserves_ibfk_ig
15
            |
16
            );
17
18
            $dbh->do(
19
                q|
20
                ALTER TABLE reserves
21
                ADD CONSTRAINT reserves_ibfk_ig
22
                    FOREIGN KEY (item_group_id)
23
                    REFERENCES item_groups (item_group_id) ON DELETE SET NULL ON UPDATE CASCADE
24
            |
25
            );
26
        }
27
28
        say $out "FK 'reserves_ibfk_ig' on reserves updated to ON DELETE SET NULL";
29
    },
30
};
(-)a/installer/data/mysql/kohastructure.sql (-2 / +1 lines)
Lines 5182-5188 CREATE TABLE `reserves` ( Link Here
5182
  CONSTRAINT `reserves_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
5182
  CONSTRAINT `reserves_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
5183
  CONSTRAINT `reserves_ibfk_5` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE,
5183
  CONSTRAINT `reserves_ibfk_5` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE,
5184
  CONSTRAINT `reserves_ibfk_6` FOREIGN KEY (`desk_id`) REFERENCES `desks` (`desk_id`) ON DELETE SET NULL ON UPDATE CASCADE,
5184
  CONSTRAINT `reserves_ibfk_6` FOREIGN KEY (`desk_id`) REFERENCES `desks` (`desk_id`) ON DELETE SET NULL ON UPDATE CASCADE,
5185
  CONSTRAINT `reserves_ibfk_ig` FOREIGN KEY (`item_group_id`) REFERENCES `item_groups` (`item_group_id`) ON DELETE CASCADE ON UPDATE CASCADE
5185
  CONSTRAINT `reserves_ibfk_ig` FOREIGN KEY (`item_group_id`) REFERENCES `item_groups` (`item_group_id`) ON DELETE SET NULL ON UPDATE CASCADE
5186
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5186
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5187
/*!40101 SET character_set_client = @saved_cs_client */;
5187
/*!40101 SET character_set_client = @saved_cs_client */;
5188
5188
5189
- 

Return to bug 34520