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

(-)a/installer/data/mysql/kohastructure.sql (-1 / +20 lines)
Lines 1354-1360 CREATE TABLE `letter` ( -- table for all notice templates in Koha Link Here
1354
  `is_html` tinyint(1) default 0, -- does this notice or slip use HTML (1 for yes, 0 for no)
1354
  `is_html` tinyint(1) default 0, -- does this notice or slip use HTML (1 for yes, 0 for no)
1355
  `title` varchar(200) NOT NULL default '', -- subject line of the notice
1355
  `title` varchar(200) NOT NULL default '', -- subject line of the notice
1356
  `content` text, -- body text for the notice or slip
1356
  `content` text, -- body text for the notice or slip
1357
  PRIMARY KEY  (`module`,`code`, `branchcode`)
1357
  `message_transport_type` varchar(20) NOT NULL DEFAULT 'email', -- transport type for this notice
1358
  PRIMARY KEY  (`module`,`code`, `branchcode`, `message_transport_type`),
1359
  CONSTRAINT `message_transport_type_fk` FOREIGN KEY (`message_transport_type`)
1360
  REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE
1358
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1361
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1359
1362
1360
--
1363
--
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 / +57 lines)
Lines 8243-8248 if ( CheckVersion($DBversion) ) { Link Here
8243
    SetVersion ($DBversion);
8243
    SetVersion ($DBversion);
8244
}
8244
}
8245
8245
8246
8247
8248
8249
8250
8251
$DBversion = "3.15.00.XXX";
8252
if ( CheckVersion($DBversion) ) {
8253
8254
    $dbh->do( q{
8255
        ALTER TABLE letter ADD COLUMN message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email' AFTER content
8256
    } );
8257
8258
    $dbh->do( q{
8259
        ALTER TABLE letter ADD CONSTRAINT message_transport_type_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types(message_transport_type);
8260
    } );
8261
8262
    $dbh->do( q{
8263
        ALTER TABLE letter DROP PRIMARY KEY, ADD PRIMARY KEY (`module`,`code`,`branchcode`, message_transport_type);
8264
    } );
8265
8266
    $dbh->do( q{
8267
        CREATE TABLE overduerules_transport_types(
8268
            id INT(11) NOT NULL AUTO_INCREMENT,
8269
            branchcode varchar(10) NOT NULL DEFAULT '',
8270
            categorycode VARCHAR(10) NOT NULL DEFAULT '',
8271
            letternumber INT(1) NOT NULL DEFAULT 1,
8272
            message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email',
8273
            PRIMARY KEY (id),
8274
            CONSTRAINT overduerules_fk FOREIGN KEY (branchcode, categorycode) REFERENCES overduerules (branchcode, categorycode) ON DELETE CASCADE ON UPDATE CASCADE,
8275
            CONSTRAINT mtt_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types (message_transport_type) ON DELETE CASCADE ON UPDATE CASCADE
8276
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8277
    } );
8278
8279
    my $sth = $dbh->prepare( q{
8280
        SELECT * FROM overduerules;
8281
    } );
8282
8283
    $sth->execute;
8284
    my $sth_insert_mtt = $dbh->prepare( q{
8285
        INSERT INTO overduerules_transport_types (branchcode, categorycode, letternumber, message_transport_type) VALUES ( ?, ?, ?, ? )
8286
    } );
8287
    while ( my $row = $sth->fetchrow_hashref ) {
8288
        my $branchcode = $row->{branchcode};
8289
        my $categorycode = $row->{categorycode};
8290
        for my $letternumber ( 1 .. 3 ) {
8291
            next unless $row->{"letter$letternumber"};
8292
            $sth_insert_mtt->execute(
8293
                $branchcode, $categorycode, $letternumber, 'email'
8294
            );
8295
        }
8296
    }
8297
8298
    print "Upgrade done (Bug 9016: Adds the association table overduerules_transport_types)\n";
8299
    SetVersion($DBversion);
8300
}
8301
8302
8246
=head1 FUNCTIONS
8303
=head1 FUNCTIONS
8247
8304
8248
=head2 TableExists($table)
8305
=head2 TableExists($table)
8249
- 

Return to bug 9016