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

(-)a/installer/data/mysql/kohastructure.sql (-1 / +20 lines)
Lines 1323-1329 CREATE TABLE `letter` ( -- table for all notice templates in Koha Link Here
1323
  `is_html` tinyint(1) default 0, -- does this notice or slip use HTML (1 for yes, 0 for no)
1323
  `is_html` tinyint(1) default 0, -- does this notice or slip use HTML (1 for yes, 0 for no)
1324
  `title` varchar(200) NOT NULL default '', -- subject line of the notice
1324
  `title` varchar(200) NOT NULL default '', -- subject line of the notice
1325
  `content` text, -- body text for the notice or slip
1325
  `content` text, -- body text for the notice or slip
1326
  PRIMARY KEY  (`module`,`code`, `branchcode`)
1326
  `message_transport_type` varchar(20) NOT NULL DEFAULT 'email', -- transport type for this notice
1327
  PRIMARY KEY  (`module`,`code`, `branchcode`, `message_transport_type`),
1328
  CONSTRAINT `message_transport_type_fk` FOREIGN KEY (`message_transport_type`)
1329
  REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE
1327
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1330
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1328
1331
1329
--
1332
--
Lines 2488-2493 CREATE TABLE `message_transport_types` ( Link Here
2488
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2491
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2489
2492
2490
--
2493
--
2494
-- Table structure for table `overduerules_transport_types`
2495
--
2496
2497
DROP TABLE IF EXISTS `overduerules_transport_types`;
2498
CREATE TABLE overduerules_transport_types(
2499
    `id` INT(11) NOT NULL AUTO_INCREMENT,
2500
    `branchcode` varchar(10) NOT NULL DEFAULT '',
2501
    `categorycode` VARCHAR(10) NOT NULL DEFAULT '',
2502
    `letternumber` INT(1) NOT NULL DEFAULT 1,
2503
    `message_transport_type` VARCHAR(20) NOT NULL DEFAULT 'email',
2504
    PRIMARY KEY (id),
2505
    CONSTRAINT overduerules_fk FOREIGN KEY (branchcode, categorycode) REFERENCES overduerules (branchcode, categorycode) ON DELETE CASCADE ON UPDATE CASCADE,
2506
    CONSTRAINT mtt_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types (message_transport_type) ON DELETE CASCADE ON UPDATE CASCADE
2507
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2508
2509
--
2491
-- Table structure for table `message_attributes`
2510
-- Table structure for table `message_attributes`
2492
--
2511
--
2493
2512
(-)a/installer/data/mysql/updatedatabase.pl (-2 / +60 lines)
Lines 6396-6402 if ( CheckVersion($DBversion) ) { Link Here
6396
    $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReadometer','0','Display Readometer from IDreamBooks.com','','YesNo');");
6396
    $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReadometer','0','Display Readometer from IDreamBooks.com','','YesNo');");
6397
    $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksResults','0','Display IDreamBooks.com rating in search results','','YesNo');");
6397
    $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksResults','0','Display IDreamBooks.com rating in search results','','YesNo');");
6398
    print "Upgrade to $DBversion done (Add IDreamBooks enhanced content)\n";
6398
    print "Upgrade to $DBversion done (Add IDreamBooks enhanced content)\n";
6399
    SetVersion($DBversion);
6399
   SetVersion ($DBversion);
6400
}
6400
}
6401
6401
6402
$DBversion = "3.11.00.018";
6402
$DBversion = "3.11.00.018";
Lines 7139-7144 if ( CheckVersion($DBversion) ) { Link Here
7139
    SetVersion ($DBversion);
7139
    SetVersion ($DBversion);
7140
}
7140
}
7141
7141
7142
7143
7144
7145
7146
7147
7148
7149
$DBversion = "3.13.00.XXX";
7150
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7151
7152
    $dbh->do( q{
7153
        ALTER TABLE letter ADD COLUMN message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email' AFTER content
7154
    } );
7155
7156
    $dbh->do( q{
7157
        ALTER TABLE letter ADD CONSTRAINT message_transport_type_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types(message_transport_type);
7158
    } );
7159
7160
    $dbh->do( q{
7161
        ALTER TABLE letter DROP PRIMARY KEY, ADD PRIMARY KEY (`module`,`code`,`branchcode`, message_transport_type);
7162
    } );
7163
7164
    $dbh->do( q{
7165
        CREATE TABLE overduerules_transport_types(
7166
            id INT(11) NOT NULL AUTO_INCREMENT,
7167
            branchcode varchar(10) NOT NULL DEFAULT '',
7168
            categorycode VARCHAR(10) NOT NULL DEFAULT '',
7169
            letternumber INT(1) NOT NULL DEFAULT 1,
7170
            message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email',
7171
            PRIMARY KEY (id),
7172
            CONSTRAINT overduerules_fk FOREIGN KEY (branchcode, categorycode) REFERENCES overduerules (branchcode, categorycode) ON DELETE CASCADE ON UPDATE CASCADE,
7173
            CONSTRAINT mtt_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types (message_transport_type) ON DELETE CASCADE ON UPDATE CASCADE
7174
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7175
    } );
7176
7177
    my $sth = $dbh->prepare( q{
7178
        SELECT * FROM overduerules;
7179
    } );
7180
7181
    $sth->execute;
7182
    my $sth_insert_mtt = $dbh->prepare( q{
7183
        INSERT INTO overduerules_transport_types (branchcode, categorycode, letternumber, message_transport_type) VALUES ( ?, ?, ?, ? )
7184
    } );
7185
    while ( my $row = $sth->fetchrow_hashref ) {
7186
        my $branchcode = $row->{branchcode};
7187
        my $categorycode = $row->{categorycode};
7188
        for my $letternumber ( 1 .. 3 ) {
7189
            next unless $row->{"letter$letternumber"};
7190
            $sth_insert_mtt->execute(
7191
                $branchcode, $categorycode, $letternumber, 'email'
7192
            );
7193
        }
7194
    }
7195
7196
    print "Upgrade done (Bug 9016: Adds the association table overduerules_transport_types)\n";
7197
    SetVersion($DBversion);
7198
}
7199
7200
7142
=head1 FUNCTIONS
7201
=head1 FUNCTIONS
7143
7202
7144
=head2 TableExists($table)
7203
=head2 TableExists($table)
7145
- 

Return to bug 9016