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

(-)a/installer/data/mysql/kohastructure.sql (-1 / +20 lines)
Lines 1346-1352 CREATE TABLE `letter` ( -- table for all notice templates in Koha Link Here
1346
  `is_html` tinyint(1) default 0, -- does this notice or slip use HTML (1 for yes, 0 for no)
1346
  `is_html` tinyint(1) default 0, -- does this notice or slip use HTML (1 for yes, 0 for no)
1347
  `title` varchar(200) NOT NULL default '', -- subject line of the notice
1347
  `title` varchar(200) NOT NULL default '', -- subject line of the notice
1348
  `content` text, -- body text for the notice or slip
1348
  `content` text, -- body text for the notice or slip
1349
  PRIMARY KEY  (`module`,`code`, `branchcode`)
1349
  `message_transport_type` varchar(20) NOT NULL DEFAULT 'email', -- transport type for this notice
1350
  PRIMARY KEY  (`module`,`code`, `branchcode`, `message_transport_type`),
1351
  CONSTRAINT `message_transport_type_fk` FOREIGN KEY (`message_transport_type`)
1352
  REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE
1350
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1353
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1351
1354
1352
--
1355
--
Lines 2549-2554 CREATE TABLE `message_transport_types` ( Link Here
2549
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2552
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2550
2553
2551
--
2554
--
2555
-- Table structure for table `overduerules_transport_types`
2556
--
2557
2558
DROP TABLE IF EXISTS `overduerules_transport_types`;
2559
CREATE TABLE overduerules_transport_types(
2560
    `id` INT(11) NOT NULL AUTO_INCREMENT,
2561
    `branchcode` varchar(10) NOT NULL DEFAULT '',
2562
    `categorycode` VARCHAR(10) NOT NULL DEFAULT '',
2563
    `letternumber` INT(1) NOT NULL DEFAULT 1,
2564
    `message_transport_type` VARCHAR(20) NOT NULL DEFAULT 'email',
2565
    PRIMARY KEY (id),
2566
    CONSTRAINT overduerules_fk FOREIGN KEY (branchcode, categorycode) REFERENCES overduerules (branchcode, categorycode) ON DELETE CASCADE ON UPDATE CASCADE,
2567
    CONSTRAINT mtt_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types (message_transport_type) ON DELETE CASCADE ON UPDATE CASCADE
2568
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2569
2570
--
2552
-- Table structure for table `message_attributes`
2571
-- Table structure for table `message_attributes`
2553
--
2572
--
2554
2573
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +59 lines)
Lines 7778-7783 if(CheckVersion($DBversion)) { Link Here
7778
    SetVersion($DBversion);
7778
    SetVersion($DBversion);
7779
}
7779
}
7780
7780
7781
7782
7783
7784
7785
7786
7787
7788
$DBversion = "3.15.00.XXX";
7789
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7790
7791
    $dbh->do( q{
7792
        ALTER TABLE letter ADD COLUMN message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email' AFTER content
7793
    } );
7794
7795
    $dbh->do( q{
7796
        ALTER TABLE letter ADD CONSTRAINT message_transport_type_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types(message_transport_type);
7797
    } );
7798
7799
    $dbh->do( q{
7800
        ALTER TABLE letter DROP PRIMARY KEY, ADD PRIMARY KEY (`module`,`code`,`branchcode`, message_transport_type);
7801
    } );
7802
7803
    $dbh->do( q{
7804
        CREATE TABLE overduerules_transport_types(
7805
            id INT(11) NOT NULL AUTO_INCREMENT,
7806
            branchcode varchar(10) NOT NULL DEFAULT '',
7807
            categorycode VARCHAR(10) NOT NULL DEFAULT '',
7808
            letternumber INT(1) NOT NULL DEFAULT 1,
7809
            message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email',
7810
            PRIMARY KEY (id),
7811
            CONSTRAINT overduerules_fk FOREIGN KEY (branchcode, categorycode) REFERENCES overduerules (branchcode, categorycode) ON DELETE CASCADE ON UPDATE CASCADE,
7812
            CONSTRAINT mtt_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types (message_transport_type) ON DELETE CASCADE ON UPDATE CASCADE
7813
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7814
    } );
7815
7816
    my $sth = $dbh->prepare( q{
7817
        SELECT * FROM overduerules;
7818
    } );
7819
7820
    $sth->execute;
7821
    my $sth_insert_mtt = $dbh->prepare( q{
7822
        INSERT INTO overduerules_transport_types (branchcode, categorycode, letternumber, message_transport_type) VALUES ( ?, ?, ?, ? )
7823
    } );
7824
    while ( my $row = $sth->fetchrow_hashref ) {
7825
        my $branchcode = $row->{branchcode};
7826
        my $categorycode = $row->{categorycode};
7827
        for my $letternumber ( 1 .. 3 ) {
7828
            next unless $row->{"letter$letternumber"};
7829
            $sth_insert_mtt->execute(
7830
                $branchcode, $categorycode, $letternumber, 'email'
7831
            );
7832
        }
7833
    }
7834
7835
    print "Upgrade done (Bug 9016: Adds the association table overduerules_transport_types)\n";
7836
    SetVersion($DBversion);
7837
}
7838
7839
7781
=head1 FUNCTIONS
7840
=head1 FUNCTIONS
7782
7841
7783
=head2 TableExists($table)
7842
=head2 TableExists($table)
7784
- 

Return to bug 9016