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

(-)a/installer/data/mysql/kohastructure.sql (-1 / +20 lines)
Lines 1352-1358 CREATE TABLE `letter` ( -- table for all notice templates in Koha Link Here
1352
  `is_html` tinyint(1) default 0, -- does this notice or slip use HTML (1 for yes, 0 for no)
1352
  `is_html` tinyint(1) default 0, -- does this notice or slip use HTML (1 for yes, 0 for no)
1353
  `title` varchar(200) NOT NULL default '', -- subject line of the notice
1353
  `title` varchar(200) NOT NULL default '', -- subject line of the notice
1354
  `content` text, -- body text for the notice or slip
1354
  `content` text, -- body text for the notice or slip
1355
  PRIMARY KEY  (`module`,`code`, `branchcode`)
1355
  `message_transport_type` varchar(20) NOT NULL DEFAULT 'email', -- transport type for this notice
1356
  PRIMARY KEY  (`module`,`code`, `branchcode`, `message_transport_type`),
1357
  CONSTRAINT `message_transport_type_fk` FOREIGN KEY (`message_transport_type`)
1358
  REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE
1356
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1359
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1357
1360
1358
--
1361
--
Lines 2544-2549 CREATE TABLE `message_transport_types` ( Link Here
2544
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2547
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2545
2548
2546
--
2549
--
2550
-- Table structure for table `overduerules_transport_types`
2551
--
2552
2553
DROP TABLE IF EXISTS `overduerules_transport_types`;
2554
CREATE TABLE overduerules_transport_types(
2555
    `id` INT(11) NOT NULL AUTO_INCREMENT,
2556
    `branchcode` varchar(10) NOT NULL DEFAULT '',
2557
    `categorycode` VARCHAR(10) NOT NULL DEFAULT '',
2558
    `letternumber` INT(1) NOT NULL DEFAULT 1,
2559
    `message_transport_type` VARCHAR(20) NOT NULL DEFAULT 'email',
2560
    PRIMARY KEY (id),
2561
    CONSTRAINT overduerules_fk FOREIGN KEY (branchcode, categorycode) REFERENCES overduerules (branchcode, categorycode) ON DELETE CASCADE ON UPDATE CASCADE,
2562
    CONSTRAINT mtt_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types (message_transport_type) ON DELETE CASCADE ON UPDATE CASCADE
2563
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2564
2565
--
2547
-- Table structure for table `message_attributes`
2566
-- Table structure for table `message_attributes`
2548
--
2567
--
2549
2568
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +58 lines)
Lines 8083-8088 if ( CheckVersion($DBversion) ) { Link Here
8083
    SetVersion($DBversion);
8083
    SetVersion($DBversion);
8084
}
8084
}
8085
8085
8086
8087
8088
8089
8090
8091
8092
$DBversion = "3.15.00.XXX";
8093
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
8094
8095
    $dbh->do( q{
8096
        ALTER TABLE letter ADD COLUMN message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email' AFTER content
8097
    } );
8098
8099
    $dbh->do( q{
8100
        ALTER TABLE letter ADD CONSTRAINT message_transport_type_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types(message_transport_type);
8101
    } );
8102
8103
    $dbh->do( q{
8104
        ALTER TABLE letter DROP PRIMARY KEY, ADD PRIMARY KEY (`module`,`code`,`branchcode`, message_transport_type);
8105
    } );
8106
8107
    $dbh->do( q{
8108
        CREATE TABLE overduerules_transport_types(
8109
            id INT(11) NOT NULL AUTO_INCREMENT,
8110
            branchcode varchar(10) NOT NULL DEFAULT '',
8111
            categorycode VARCHAR(10) NOT NULL DEFAULT '',
8112
            letternumber INT(1) NOT NULL DEFAULT 1,
8113
            message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email',
8114
            PRIMARY KEY (id),
8115
            CONSTRAINT overduerules_fk FOREIGN KEY (branchcode, categorycode) REFERENCES overduerules (branchcode, categorycode) ON DELETE CASCADE ON UPDATE CASCADE,
8116
            CONSTRAINT mtt_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types (message_transport_type) ON DELETE CASCADE ON UPDATE CASCADE
8117
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8118
    } );
8119
8120
    my $sth = $dbh->prepare( q{
8121
        SELECT * FROM overduerules;
8122
    } );
8123
8124
    $sth->execute;
8125
    my $sth_insert_mtt = $dbh->prepare( q{
8126
        INSERT INTO overduerules_transport_types (branchcode, categorycode, letternumber, message_transport_type) VALUES ( ?, ?, ?, ? )
8127
    } );
8128
    while ( my $row = $sth->fetchrow_hashref ) {
8129
        my $branchcode = $row->{branchcode};
8130
        my $categorycode = $row->{categorycode};
8131
        for my $letternumber ( 1 .. 3 ) {
8132
            next unless $row->{"letter$letternumber"};
8133
            $sth_insert_mtt->execute(
8134
                $branchcode, $categorycode, $letternumber, 'email'
8135
            );
8136
        }
8137
    }
8138
8139
    print "Upgrade done (Bug 9016: Adds the association table overduerules_transport_types)\n";
8140
    SetVersion($DBversion);
8141
}
8142
8143
8086
=head1 FUNCTIONS
8144
=head1 FUNCTIONS
8087
8145
8088
=head2 TableExists($table)
8146
=head2 TableExists($table)
8089
- 

Return to bug 9016