Bugzilla – Attachment 20814 Details for
Bug 9016
Multi transport types for notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9016: DB changes: new table overduerules_transport_types
Bug-9016-DB-changes-new-table-overduerulestranspor.patch (text/plain), 5.85 KB, created by
Jonathan Druart
on 2013-09-06 09:05:45 UTC
(
hide
)
Description:
Bug 9016: DB changes: new table overduerules_transport_types
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2013-09-06 09:05:45 UTC
Size:
5.85 KB
patch
obsolete
>From 0508d45bb909f85c8281d8deee5b54117cb06332 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Fri, 6 Sep 2013 09:36:42 +0200 >Subject: [PATCH] Bug 9016: DB changes: new table overduerules_transport_types > >This patch adds: >- a new table overduerules_transport_types. >- a new column letter.message_transport_type. >- a new primary key for letter. >- fill the new table with existing values. > >Test plan: >After applying this patch and executing the updatedatabase entry, verify >that the overduerules_transport_types table contains a row for each >entry in the overduerules table. >The message_transport_type column should contain 'email'. >--- > installer/data/mysql/kohastructure.sql | 21 ++++++++++- > installer/data/mysql/updatedatabase.pl | 61 +++++++++++++++++++++++++++++++- > 2 files changed, 80 insertions(+), 2 deletions(-) > >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 7628983..6ba4d5a 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -1321,7 +1321,10 @@ CREATE TABLE `letter` ( -- table for all notice templates in Koha > `is_html` tinyint(1) default 0, -- does this notice or slip use HTML (1 for yes, 0 for no) > `title` varchar(200) NOT NULL default '', -- subject line of the notice > `content` text, -- body text for the notice or slip >- PRIMARY KEY (`module`,`code`, `branchcode`) >+ `message_transport_type` varchar(20) NOT NULL DEFAULT 'email', -- transport type for this notice >+ PRIMARY KEY (`module`,`code`, `branchcode`, `message_transport_type`), >+ CONSTRAINT `message_transport_type_fk` FOREIGN KEY (`message_transport_type`) >+ REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE > ) ENGINE=InnoDB DEFAULT CHARSET=utf8; > > -- >@@ -2486,6 +2489,22 @@ CREATE TABLE `message_transport_types` ( > ) ENGINE=InnoDB DEFAULT CHARSET=utf8; > > -- >+-- Table structure for table `overduerules_transport_types` >+-- >+ >+DROP TABLE IF EXISTS `overduerules_transport_types`; >+CREATE TABLE overduerules_transport_types( >+ `id` INT(11) NOT NULL AUTO_INCREMENT, >+ `branchcode` varchar(10) NOT NULL DEFAULT '', >+ `categorycode` VARCHAR(10) NOT NULL DEFAULT '', >+ `letternumber` INT(1) NOT NULL DEFAULT 1, >+ `message_transport_type` VARCHAR(20) NOT NULL DEFAULT 'email', >+ PRIMARY KEY (id), >+ CONSTRAINT overduerules_fk FOREIGN KEY (branchcode, categorycode) REFERENCES overduerules (branchcode, categorycode) ON DELETE CASCADE ON UPDATE CASCADE, >+ CONSTRAINT mtt_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types (message_transport_type) ON DELETE CASCADE ON UPDATE CASCADE >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ >+-- > -- Table structure for table `message_attributes` > -- > >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 74aeb3e..e1ef546 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -6396,7 +6396,7 @@ if ( CheckVersion($DBversion) ) { > $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReadometer','0','Display Readometer from IDreamBooks.com','','YesNo');"); > $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksResults','0','Display IDreamBooks.com rating in search results','','YesNo');"); > print "Upgrade to $DBversion done (Add IDreamBooks enhanced content)\n"; >- SetVersion($DBversion); >+ SetVersion ($DBversion); > } > > $DBversion = "3.11.00.018"; >@@ -7067,6 +7067,65 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+ >+ >+ >+ >+ >+ >+ >+$DBversion = "3.13.00.XXX"; >+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { >+ >+ $dbh->do( q{ >+ ALTER TABLE letter ADD COLUMN message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email' AFTER content >+ } ); >+ >+ $dbh->do( q{ >+ ALTER TABLE letter ADD CONSTRAINT message_transport_type_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types(message_transport_type); >+ } ); >+ >+ $dbh->do( q{ >+ ALTER TABLE letter DROP PRIMARY KEY, ADD PRIMARY KEY (`module`,`code`,`branchcode`, message_transport_type); >+ } ); >+ >+ $dbh->do( q{ >+ CREATE TABLE overduerules_transport_types( >+ id INT(11) NOT NULL AUTO_INCREMENT, >+ branchcode varchar(10) NOT NULL DEFAULT '', >+ categorycode VARCHAR(10) NOT NULL DEFAULT '', >+ letternumber INT(1) NOT NULL DEFAULT 1, >+ message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email', >+ PRIMARY KEY (id), >+ CONSTRAINT overduerules_fk FOREIGN KEY (branchcode, categorycode) REFERENCES overduerules (branchcode, categorycode) ON DELETE CASCADE ON UPDATE CASCADE, >+ CONSTRAINT mtt_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types (message_transport_type) ON DELETE CASCADE ON UPDATE CASCADE >+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ } ); >+ >+ my $sth = $dbh->prepare( q{ >+ SELECT * FROM overduerules; >+ } ); >+ >+ $sth->execute; >+ my $sth_insert_mtt = $dbh->prepare( q{ >+ INSERT INTO overduerules_transport_types (branchcode, categorycode, letternumber, message_transport_type) VALUES ( ?, ?, ?, ? ) >+ } ); >+ while ( my $row = $sth->fetchrow_hashref ) { >+ my $branchcode = $row->{branchcode}; >+ my $categorycode = $row->{categorycode}; >+ for my $letternumber ( 1 .. 3 ) { >+ next unless $row->{"letter$letternumber"}; >+ $sth_insert_mtt->execute( >+ $branchcode, $categorycode, $letternumber, 'email' >+ ); >+ } >+ } >+ >+ print "Upgrade done (Bug 9016: Adds the association table overduerules_transport_types)\n"; >+ SetVersion($DBversion); >+} >+ >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9016
:
13276
|
20814
|
20815
|
20816
|
20916
|
21164
|
21165
|
21166
|
21167
|
21636
|
21637
|
21638
|
21639
|
22814
|
23272
|
23273
|
23289
|
23290
|
23291
|
23292
|
23293
|
23562
|
23955
|
23956
|
23957
|
23958
|
23959
|
23960
|
24571
|
24572
|
24573
|
24574
|
24575
|
24576
|
25006
|
25123
|
25124
|
25125
|
25126
|
25127
|
25128
|
25129
|
25130
|
25415
|
25416
|
25417
|
25418
|
25419
|
25420
|
25421
|
25422
|
25606
|
25899
|
26182
|
26209
|
26210
|
26211
|
26216
|
26226
|
26233
|
26648
|
26649
|
26650
|
26656
|
26657
|
26658
|
26659
|
26660
|
26661
|
26662
|
26663
|
26664
|
26665
|
26666
|
26667
|
26668
|
26670
|
26672
|
26673
|
27794
|
27795
|
27796
|
27797
|
27798
|
27799
|
27800
|
27801
|
27802
|
27803
|
27804
|
27805
|
27806
|
27807
|
27808
|
27809