1 $DBversion = 'XXX'; # will be replaced by the RM
2 if( CheckVersion( $DBversion ) ) {
3 if ( TableExists( 'branch_borrower_circ_rules' ) ) {
4 if ( column_exists( 'branch_borrower_circ_rules', 'maxissueqty' ) ) {
6 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
7 SELECT categorycode, branchcode, NULL, 'patron_maxissueqty', COALESCE( maxissueqty, '' )
8 FROM branch_borrower_circ_rules
11 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
12 SELECT categorycode, branchcode, NULL, 'patron_maxonsiteissueqty', COALESCE( maxonsiteissueqty, '' )
13 FROM branch_borrower_circ_rules
15 $dbh->do("DROP TABLE branch_borrower_circ_rules");
19 if ( TableExists( 'default_borrower_circ_rules' ) ) {
20 if ( column_exists( 'default_borrower_circ_rules', 'maxissueqty' ) ) {
22 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
23 SELECT categorycode, NULL, NULL, 'patron_maxissueqty', COALESCE( maxissueqty, '' )
24 FROM default_borrower_circ_rules
27 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
28 SELECT categorycode, NULL, NULL, 'patron_maxonsiteissueqty', COALESCE( maxonsiteissueqty, '' )
29 FROM default_borrower_circ_rules
31 $dbh->do("DROP TABLE default_borrower_circ_rules");
35 if ( column_exists( 'default_circ_rules', 'maxissueqty' ) ) {
37 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
38 SELECT NULL, NULL, NULL, 'patron_maxissueqty', COALESCE( maxissueqty, '' )
39 FROM default_circ_rules
42 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
43 SELECT NULL, NULL, NULL, 'patron_maxonsiteissueqty', COALESCE( maxonsiteissueqty, '' )
44 FROM default_circ_rules
46 $dbh->do("ALTER TABLE default_circ_rules DROP COLUMN maxissueqty, DROP COLUMN maxonsiteissueqty");
49 if ( column_exists( 'default_branch_circ_rules', 'maxissueqty' ) ) {
51 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
52 SELECT NULL, branchcode, NULL, 'patron_maxissueqty', COALESCE( maxissueqty, '' )
53 FROM default_branch_circ_rules
56 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
57 SELECT NULL, NULL, NULL, 'patron_maxonsiteissueqty', COALESCE( maxonsiteissueqty, '' )
58 FROM default_branch_circ_rules
60 $dbh->do("ALTER TABLE default_branch_circ_rules DROP COLUMN maxissueqty, DROP COLUMN maxonsiteissueqty");
63 SetVersion( $DBversion );
64 print "Upgrade to $DBversion done (Bug 18925 - Move maxissueqty and maxonsiteissueqty to circulation_rules)\n";