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 7155-7160 if ( CheckVersion($DBversion) ) { Link Here
7155
    SetVersion($DBversion);
7155
    SetVersion($DBversion);
7156
}
7156
}
7157
7157
7158
7159
7160
7161
7162
7163
7164
7165
$DBversion = "3.13.00.XXX";
7166
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7167
7168
    $dbh->do( q{
7169
        ALTER TABLE letter ADD COLUMN message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email' AFTER content
7170
    } );
7171
7172
    $dbh->do( q{
7173
        ALTER TABLE letter ADD CONSTRAINT message_transport_type_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types(message_transport_type);
7174
    } );
7175
7176
    $dbh->do( q{
7177
        ALTER TABLE letter DROP PRIMARY KEY, ADD PRIMARY KEY (`module`,`code`,`branchcode`, message_transport_type);
7178
    } );
7179
7180
    $dbh->do( q{
7181
        CREATE TABLE overduerules_transport_types(
7182
            id INT(11) NOT NULL AUTO_INCREMENT,
7183
            branchcode varchar(10) NOT NULL DEFAULT '',
7184
            categorycode VARCHAR(10) NOT NULL DEFAULT '',
7185
            letternumber INT(1) NOT NULL DEFAULT 1,
7186
            message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email',
7187
            PRIMARY KEY (id),
7188
            CONSTRAINT overduerules_fk FOREIGN KEY (branchcode, categorycode) REFERENCES overduerules (branchcode, categorycode) ON DELETE CASCADE ON UPDATE CASCADE,
7189
            CONSTRAINT mtt_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types (message_transport_type) ON DELETE CASCADE ON UPDATE CASCADE
7190
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7191
    } );
7192
7193
    my $sth = $dbh->prepare( q{
7194
        SELECT * FROM overduerules;
7195
    } );
7196
7197
    $sth->execute;
7198
    my $sth_insert_mtt = $dbh->prepare( q{
7199
        INSERT INTO overduerules_transport_types (branchcode, categorycode, letternumber, message_transport_type) VALUES ( ?, ?, ?, ? )
7200
    } );
7201
    while ( my $row = $sth->fetchrow_hashref ) {
7202
        my $branchcode = $row->{branchcode};
7203
        my $categorycode = $row->{categorycode};
7204
        for my $letternumber ( 1 .. 3 ) {
7205
            next unless $row->{"letter$letternumber"};
7206
            $sth_insert_mtt->execute(
7207
                $branchcode, $categorycode, $letternumber, 'email'
7208
            );
7209
        }
7210
    }
7211
7212
    print "Upgrade done (Bug 9016: Adds the association table overduerules_transport_types)\n";
7213
    SetVersion($DBversion);
7214
}
7215
7216
7158
=head1 FUNCTIONS
7217
=head1 FUNCTIONS
7159
7218
7160
=head2 TableExists($table)
7219
=head2 TableExists($table)
7161
- 

Return to bug 9016