Bugzilla – Attachment 103608 Details for
Bug 23081
Make items.issues and deleteditems.issues default to 0 instead of null
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23081: Change issues fields in items and deleteditems to default to zero
Bug-23081-Change-issues-fields-in-items-and-delete.patch (text/plain), 5.05 KB, created by
Lucas Gass (lukeg)
on 2020-04-23 21:54:29 UTC
(
hide
)
Description:
Bug 23081: Change issues fields in items and deleteditems to default to zero
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2020-04-23 21:54:29 UTC
Size:
5.05 KB
patch
obsolete
>From eb4de3a4aa7302e6f2bc8d384a19ec9d994bd780 Mon Sep 17 00:00:00 2001 >From: Andrew Fuerste-Henry <andrew@bywatersolutions.com> >Date: Thu, 23 Apr 2020 18:14:59 +0000 >Subject: [PATCH] Bug 23081: Change issues fields in items and deleteditems to > default to zero > >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >--- > Koha/Schema/Result/Deleteditem.pm | 8 ++++++-- > Koha/Schema/Result/Item.pm | 8 ++++++-- > .../bug_23081-change-default-of-issues-field.perl | 15 +++++++++++++++ > installer/data/mysql/kohastructure.sql | 4 ++-- > 4 files changed, 29 insertions(+), 6 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_23081-change-default-of-issues-field.perl > >diff --git a/Koha/Schema/Result/Deleteditem.pm b/Koha/Schema/Result/Deleteditem.pm >index 70a3e36eb0..98f1ca9ac8 100644 >--- a/Koha/Schema/Result/Deleteditem.pm >+++ b/Koha/Schema/Result/Deleteditem.pm >@@ -156,7 +156,8 @@ __PACKAGE__->table("deleteditems"); > =head2 issues > > data_type: 'smallint' >- is_nullable: 1 >+ is_nullable: 0 >+ default_value: 0 > > =head2 renewals > >@@ -341,7 +342,10 @@ __PACKAGE__->add_columns( > "coded_location_qualifier", > { data_type => "varchar", is_nullable => 1, size => 10 }, > "issues", >- { data_type => "smallint", is_nullable => 1 }, >+ { data_type => "smallint", >+ is_nullable => 0, >+ default_value => 0, >+ }, > "renewals", > { data_type => "smallint", is_nullable => 1 }, > "reserves", >diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm >index 58cddf4502..cc80b2ba72 100644 >--- a/Koha/Schema/Result/Item.pm >+++ b/Koha/Schema/Result/Item.pm >@@ -159,7 +159,8 @@ __PACKAGE__->table("items"); > =head2 issues > > data_type: 'smallint' >- is_nullable: 1 >+ is_nullable: 0 >+ default_value: 0 > > =head2 renewals > >@@ -355,7 +356,10 @@ __PACKAGE__->add_columns( > "coded_location_qualifier", > { data_type => "varchar", is_nullable => 1, size => 10 }, > "issues", >- { data_type => "smallint", is_nullable => 1 }, >+ { data_type => "smallint", >+ is_nullable => 0, >+ default_value => 0, >+ }, > "renewals", > { data_type => "smallint", is_nullable => 1 }, > "reserves", >diff --git a/installer/data/mysql/atomicupdate/bug_23081-change-default-of-issues-field.perl b/installer/data/mysql/atomicupdate/bug_23081-change-default-of-issues-field.perl >new file mode 100644 >index 0000000000..204d9999b3 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_23081-change-default-of-issues-field.perl >@@ -0,0 +1,15 @@ >+$DBversion = 'XXX'; # will be replaced by the RM >+if( CheckVersion( $DBversion ) ) { >+ # you can use $dbh here like: >+ $dbh->do( "UPDATE items set issues=0 where issues is null" ); >+ $dbh->do( "UPDATE deleteditems set issues=0 where issues is null" ); >+ $dbh->do( "ALTER TABLE items ALTER issues set default 0" ); >+ $dbh->do( "ALTER TABLE deleteditems ALTER issues set default 0" ); >+ # or perform some test and warn >+ # if( !column_exists( 'biblio', 'biblionumber' ) ) { >+ # warn "There is something wrong"; >+ # } >+ >+ # Always end with this (adjust the bug info) >+ NewVersion( $DBversion, 23081, "Set default to 0 for items.issues"); >+} >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 0b49e522e0..1cb3165eee 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -638,7 +638,7 @@ CREATE TABLE `deleteditems` ( > `withdrawn_on` datetime DEFAULT NULL, -- the date and time an item was last marked as withdrawn, NULL if not withdrawn > `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o) > `coded_location_qualifier` varchar(10) default NULL, -- coded location qualifier(MARC21 952$f) >- `issues` smallint(6) default NULL, -- number of times this item has been checked out >+ `issues` smallint(6) default 0, -- number of times this item has been checked out > `renewals` smallint(6) default NULL, -- number of times this item has been renewed > `reserves` smallint(6) default NULL, -- number of times this item has been placed on hold/reserved > `restricted` tinyint(1) default NULL, -- authorized value defining use restrictions for this item (MARC21 952$5) >@@ -843,7 +843,7 @@ CREATE TABLE `items` ( -- holdings/item information > `withdrawn_on` datetime DEFAULT NULL, -- the date and time an item was last marked as withdrawn, NULL if not withdrawn > `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o) > `coded_location_qualifier` varchar(10) default NULL, -- coded location qualifier(MARC21 952$f) >- `issues` smallint(6) default NULL, -- number of times this item has been checked out/issued >+ `issues` smallint(6) default 0, -- number of times this item has been checked out/issued > `renewals` smallint(6) default NULL, -- number of times this item has been renewed > `reserves` smallint(6) default NULL, -- number of times this item has been placed on hold/reserved > `restricted` tinyint(1) default NULL, -- authorized value defining use restrictions for this item (MARC21 952$5) >-- >2.11.0
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 23081
:
103601
|
103605
|
103606
|
103608
|
103725
|
103726
|
103741
|
103742
|
103743
|
103744
|
104706