[Koha-patches] [PATCH] Update the database as follow-up to Bug 5795
Amit Gupta
amit.gupta at osslabs.biz
Thu May 3 14:28:23 CEST 2012
If value is not exist it insert other wise update the
existing value.
To Test:
1) Go to mysql use koha database
2) select * from systempreferences where variable = 'ReservesControlBranch';
3) Show old result if value is present other wise it shows
+-----------------------+-----------------+-------------------------------+-------------------------------------------------+--------+
| variable | value | options | explanation | type |
+-----------------------+-----------------+-------------------------------+-------------------------------------------------+--------+
| ReservesControlBranch | ItemHomeLibrary | ItemHomeLibrary|PatronLibrary | Branch checked for members reservations rights. | Choice |
+-----------------------+-----------------+-------------------------------+-------------------------------------------------+--------+
---
installer/data/mysql/updatedatabase.pl | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 84f0437..839613e 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -5212,6 +5212,18 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
SetVersion($DBversion);
}
+$DBversion = "3.08.00.XXX";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+ if (C4::Context->preference('ReservesControlBranch')){
+ my $sth = $dbh->prepare("UPDATE systempreferences SET value = ? WHERE variable = 'ReservesControlBranch'");
+ $sth->execute(C4::Context->preference('ReservesControlBranch'));
+ }else{
+ $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('ReservesControlBranch','ItemHomeLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights.','Choice')");
+ }
+ print "Upgrade to $DBversion done (Insert/Update ReservesControlBranch systempreference into systempreferences table )\n";
+ SetVersion($DBversion);
+}
+
=head1 FUNCTIONS
=head2 TableExists($table)
--
1.6.4.2
More information about the Koha-patches
mailing list