Bugzilla – Attachment 85242 Details for
Bug 18745
Serial claims: save supplier info on serial-level
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18745: Add foreign key constraint on subscription.aqbooksellerid
Bug-18745-Add-foreign-key-constraint-on-subscripti.patch (text/plain), 4.76 KB, created by
Julian Maurice
on 2019-02-18 12:50:51 UTC
(
hide
)
Description:
Bug 18745: Add foreign key constraint on subscription.aqbooksellerid
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2019-02-18 12:50:51 UTC
Size:
4.76 KB
patch
obsolete
>From fd9b2e714e80bb5dbf8ad18bfa75ed21042d55b1 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Mon, 18 Feb 2019 13:45:41 +0100 >Subject: [PATCH] Bug 18745: Add foreign key constraint on > subscription.aqbooksellerid > >--- > C4/Serials.pm | 4 ++++ > installer/data/mysql/atomicupdate/bug_18745.perl | 11 +++++++++++ > installer/data/mysql/kohastructure.sql | 5 +++-- > serials/subscription-add.pl | 4 ++-- > 4 files changed, 20 insertions(+), 4 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index be6ed77b18..4fc190de4d 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -1318,6 +1318,8 @@ sub ModSubscription { > $itemtype, $previousitemtype > ) = @_; > >+ $aqbooksellerid ||= undef; >+ > my $dbh = C4::Context->dbh; > my $query = "UPDATE subscription > SET librarian=?, branchcode=?, aqbooksellerid=?, cost=?, aqbudgetid=?, >@@ -1380,6 +1382,8 @@ sub NewSubscription { > ) = @_; > my $dbh = C4::Context->dbh; > >+ $aqbooksellerid ||= undef; >+ > #save subscription (insert into database) > my $query = qq| > INSERT INTO subscription >diff --git a/installer/data/mysql/atomicupdate/bug_18745.perl b/installer/data/mysql/atomicupdate/bug_18745.perl >index c301d03eb7..dbc90e042b 100644 >--- a/installer/data/mysql/atomicupdate/bug_18745.perl >+++ b/installer/data/mysql/atomicupdate/bug_18745.perl >@@ -1,5 +1,16 @@ > $DBversion = 'XXX'; > if( CheckVersion( $DBversion ) ) { >+ $dbh->do(q{ >+ UPDATE subscription >+ SET aqbooksellerid = NULL >+ WHERE aqbooksellerid = 0 >+ }); >+ $dbh->do(q{ >+ ALTER TABLE subscription >+ MODIFY COLUMN aqbooksellerid int(11) NULL DEFAULT NULL, >+ ADD CONSTRAINT subscription_ibfk_aqbooksellerid FOREIGN KEY (aqbooksellerid) REFERENCES aqbooksellers (id) ON DELETE RESTRICT ON UPDATE CASCADE >+ }); >+ > if (!column_exists('serial', 'aqbooksellerid')) { > $dbh->do(q{ > ALTER TABLE `serial` >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index ead5203f6a..55181de388 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -2132,7 +2132,7 @@ CREATE TABLE `subscription` ( -- information related to the subscription > `subscriptionid` int(11) NOT NULL auto_increment, -- unique key for this subscription > `librarian` varchar(100) default '', -- the librarian's username from borrowers.userid > `startdate` date default NULL, -- start date for this subscription >- `aqbooksellerid` int(11) default 0, -- foreign key for aqbooksellers.id to link to the vendor >+ `aqbooksellerid` int(11) NULL DEFAULT NULL, -- foreign key for aqbooksellers.id to link to the vendor > `cost` int(11) default 0, > `aqbudgetid` int(11) default 0, > `weeklength` int(11) default 0, -- subscription length in weeks (will not be filled in if monthlength or numberlength is set) >@@ -2174,7 +2174,8 @@ CREATE TABLE `subscription` ( -- information related to the subscription > PRIMARY KEY (`subscriptionid`), > KEY `by_biblionumber` (`biblionumber`), > CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE, >- CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE >+ CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE, >+ CONSTRAINT subscription_ibfk_aqbooksellerid FOREIGN KEY (aqbooksellerid) REFERENCES aqbooksellers (id) ON DELETE RESTRICT ON UPDATE CASCADE > ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; > > -- >diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl >index 31198c6518..32043a7fe1 100755 >--- a/serials/subscription-add.pl >+++ b/serials/subscription-add.pl >@@ -312,7 +312,7 @@ sub redirect_add_subscription { > > my $auser = $query->param('user'); > my $branchcode = $query->param('branchcode'); >- my $aqbooksellerid = $query->param('aqbooksellerid'); >+ my $aqbooksellerid = $query->param('aqbooksellerid') || undef; > my $cost = $query->param('cost'); > my $aqbudgetid = $query->param('aqbudgetid'); > my @irregularity = $query->multi_param('irregularity'); >@@ -390,7 +390,7 @@ sub redirect_mod_subscription { > my $librarian => scalar $query->param('librarian'), > my $branchcode = $query->param('branchcode'); > my $cost = $query->param('cost'); >- my $aqbooksellerid = $query->param('aqbooksellerid'); >+ my $aqbooksellerid = $query->param('aqbooksellerid') || undef; > my $biblionumber = $query->param('biblionumber'); > my $aqbudgetid = $query->param('aqbudgetid'); > >-- >2.20.1
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 18745
:
64083
|
65791
|
85240
|
85241
|
85242
|
87102
|
87103
|
87104
|
124951
|
138423
|
138424