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 2555-2560 CREATE TABLE `message_transport_types` ( Link Here
2555
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2558
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2556
2559
2557
--
2560
--
2561
-- Table structure for table `overduerules_transport_types`
2562
--
2563
2564
DROP TABLE IF EXISTS `overduerules_transport_types`;
2565
CREATE TABLE overduerules_transport_types(
2566
    `id` INT(11) NOT NULL AUTO_INCREMENT,
2567
    `branchcode` varchar(10) NOT NULL DEFAULT '',
2568
    `categorycode` VARCHAR(10) NOT NULL DEFAULT '',
2569
    `letternumber` INT(1) NOT NULL DEFAULT 1,
2570
    `message_transport_type` VARCHAR(20) NOT NULL DEFAULT 'email',
2571
    PRIMARY KEY (id),
2572
    CONSTRAINT overduerules_fk FOREIGN KEY (branchcode, categorycode) REFERENCES overduerules (branchcode, categorycode) ON DELETE CASCADE ON UPDATE CASCADE,
2573
    CONSTRAINT mtt_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types (message_transport_type) ON DELETE CASCADE ON UPDATE CASCADE
2574
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2575
2576
--
2558
-- Table structure for table `message_attributes`
2577
-- Table structure for table `message_attributes`
2559
--
2578
--
2560
2579
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +58 lines)
Lines 7953-7958 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
7953
    SetVersion($DBversion);
7953
    SetVersion($DBversion);
7954
}
7954
}
7955
7955
7956
7957
7958
7959
7960
7961
7962
$DBversion = "3.15.00.XXX";
7963
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7964
7965
    $dbh->do( q{
7966
        ALTER TABLE letter ADD COLUMN message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email' AFTER content
7967
    } );
7968
7969
    $dbh->do( q{
7970
        ALTER TABLE letter ADD CONSTRAINT message_transport_type_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types(message_transport_type);
7971
    } );
7972
7973
    $dbh->do( q{
7974
        ALTER TABLE letter DROP PRIMARY KEY, ADD PRIMARY KEY (`module`,`code`,`branchcode`, message_transport_type);
7975
    } );
7976
7977
    $dbh->do( q{
7978
        CREATE TABLE overduerules_transport_types(
7979
            id INT(11) NOT NULL AUTO_INCREMENT,
7980
            branchcode varchar(10) NOT NULL DEFAULT '',
7981
            categorycode VARCHAR(10) NOT NULL DEFAULT '',
7982
            letternumber INT(1) NOT NULL DEFAULT 1,
7983
            message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email',
7984
            PRIMARY KEY (id),
7985
            CONSTRAINT overduerules_fk FOREIGN KEY (branchcode, categorycode) REFERENCES overduerules (branchcode, categorycode) ON DELETE CASCADE ON UPDATE CASCADE,
7986
            CONSTRAINT mtt_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types (message_transport_type) ON DELETE CASCADE ON UPDATE CASCADE
7987
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7988
    } );
7989
7990
    my $sth = $dbh->prepare( q{
7991
        SELECT * FROM overduerules;
7992
    } );
7993
7994
    $sth->execute;
7995
    my $sth_insert_mtt = $dbh->prepare( q{
7996
        INSERT INTO overduerules_transport_types (branchcode, categorycode, letternumber, message_transport_type) VALUES ( ?, ?, ?, ? )
7997
    } );
7998
    while ( my $row = $sth->fetchrow_hashref ) {
7999
        my $branchcode = $row->{branchcode};
8000
        my $categorycode = $row->{categorycode};
8001
        for my $letternumber ( 1 .. 3 ) {
8002
            next unless $row->{"letter$letternumber"};
8003
            $sth_insert_mtt->execute(
8004
                $branchcode, $categorycode, $letternumber, 'email'
8005
            );
8006
        }
8007
    }
8008
8009
    print "Upgrade done (Bug 9016: Adds the association table overduerules_transport_types)\n";
8010
    SetVersion($DBversion);
8011
}
8012
8013
7956
=head1 FUNCTIONS
8014
=head1 FUNCTIONS
7957
8015
7958
=head2 TableExists($table)
8016
=head2 TableExists($table)
7959
- 

Return to bug 9016