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

(-)a/installer/data/mysql/atomicupdate/bug_40704.pl (+45 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_success say_info);
3
4
return {
5
    bug_number  => "40704",
6
    description => "Add column issues.deleted_itemnumber and old_issues.deleted_itemnumber",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        unless ( column_exists( 'issues', 'deleted_itemnumber' ) ) {
12
            $dbh->do(
13
                q{
14
                ALTER TABLE issues
15
                ADD COLUMN `deleted_itemnumber` int(11) DEFAULT NULL COMMENT 'foreign key, linking this to the deleteditems table for the item that was checked out' AFTER itemnumber;
16
            }
17
            );
18
        }
19
        unless ( foreign_key_exists( 'issues', 'issues_ibfk_deleteditems_itemnumber' ) ) {
20
            $dbh->do(
21
                q{
22
                ALTER TABLE issues
23
                ADD CONSTRAINT `issues_ibfk_deleteditems_itemnumber` FOREIGN KEY (`deleted_itemnumber`) REFERENCES `deleteditems` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL
24
            }
25
            );
26
        }
27
28
        unless ( column_exists( 'old_issues', 'deleted_itemnumber' ) ) {
29
            $dbh->do(
30
                q{
31
                ALTER TABLE old_issues
32
                ADD COLUMN `deleted_itemnumber` int(11) DEFAULT NULL COMMENT 'foreign key, linking this to the deleteditems table for the item that was checked out' AFTER itemnumber;
33
            }
34
            );
35
        }
36
        unless ( foreign_key_exists( 'old_issues', 'old_issues_ibfk_deleteditems_itemnumber' ) ) {
37
            $dbh->do(
38
                q{
39
                ALTER TABLE old_issues
40
                ADD CONSTRAINT `old_issues_ibfk_deleteditems_itemnumber` FOREIGN KEY (`deleted_itemnumber`) REFERENCES `deleteditems` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL
41
            }
42
            );
43
        }
44
    },
45
};
(-)a/installer/data/mysql/kohastructure.sql (-1 / +2 lines)
Lines 5034-5039 CREATE TABLE `old_issues` ( Link Here
5034
  `borrowernumber` int(11) DEFAULT NULL COMMENT 'foreign key, linking this to the borrowers table for the patron this item was checked out to',
5034
  `borrowernumber` int(11) DEFAULT NULL COMMENT 'foreign key, linking this to the borrowers table for the patron this item was checked out to',
5035
  `issuer_id` int(11) DEFAULT NULL COMMENT 'foreign key, linking this to the borrowers table for the user who checked out this item',
5035
  `issuer_id` int(11) DEFAULT NULL COMMENT 'foreign key, linking this to the borrowers table for the user who checked out this item',
5036
  `itemnumber` int(11) DEFAULT NULL COMMENT 'foreign key, linking this to the items table for the item that was checked out',
5036
  `itemnumber` int(11) DEFAULT NULL COMMENT 'foreign key, linking this to the items table for the item that was checked out',
5037
  `deleted_itemnumber` int(11) DEFAULT NULL COMMENT 'foreign key, linking this to the deleteditems table for the item that was checked out',
5037
  `booking_id` int(11) DEFAULT NULL COMMENT 'foreign key linking this checkout to the booking it fulfills',
5038
  `booking_id` int(11) DEFAULT NULL COMMENT 'foreign key linking this checkout to the booking it fulfills',
5038
  `date_due` datetime DEFAULT NULL COMMENT 'date the item is due (yyyy-mm-dd)',
5039
  `date_due` datetime DEFAULT NULL COMMENT 'date the item is due (yyyy-mm-dd)',
5039
  `branchcode` varchar(10) DEFAULT NULL COMMENT 'foreign key, linking to the branches table for the location the item was checked out',
5040
  `branchcode` varchar(10) DEFAULT NULL COMMENT 'foreign key, linking to the branches table for the location the item was checked out',
Lines 5058-5063 CREATE TABLE `old_issues` ( Link Here
5058
  KEY `old_issues_ibfk_borrowers_borrowernumber` (`issuer_id`),
5059
  KEY `old_issues_ibfk_borrowers_borrowernumber` (`issuer_id`),
5059
  CONSTRAINT `old_issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL,
5060
  CONSTRAINT `old_issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL,
5060
  CONSTRAINT `old_issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL,
5061
  CONSTRAINT `old_issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL,
5062
  CONSTRAINT `old_issues_ibfk_deleteditems_itemnumber` FOREIGN KEY (`deleted_itemnumber`) REFERENCES `deleteditems` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL,
5061
  CONSTRAINT `old_issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
5063
  CONSTRAINT `old_issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
5062
  CONSTRAINT `old_issues_booking_id_fk` FOREIGN KEY (`booking_id`) REFERENCES `bookings` (`booking_id`) ON DELETE SET NULL ON UPDATE CASCADE
5064
  CONSTRAINT `old_issues_booking_id_fk` FOREIGN KEY (`booking_id`) REFERENCES `bookings` (`booking_id`) ON DELETE SET NULL ON UPDATE CASCADE
5063
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5065
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5064
- 

Return to bug 40704