From 448ffb8109b668764c04981b7f4fe23c94a055ea Mon Sep 17 00:00:00 2001 From: tipaul Date: Thu, 21 Nov 2002 09:22:06 +0000 Subject: [PATCH] deleting unused scripts --- acqui.simple/savebiblio.pl | 46 ------- misc/fixborrower.pl | 250 ------------------------------------- misc/fixcatalog.pl | 36 ------ misc/fixorders.pl | 45 ------- misc/fixorders.pl2 | 14 --- misc/fixrefs.pl | 36 ------ misc/makebaskets.pl | 43 ------- misc/makeformats.pl | 50 -------- orderbreakdown.pl | 41 ------ updater/updatedatabase2.pl | 192 ---------------------------- 10 files changed, 753 deletions(-) delete mode 100755 acqui.simple/savebiblio.pl delete mode 100755 misc/fixborrower.pl delete mode 100755 misc/fixcatalog.pl delete mode 100755 misc/fixorders.pl delete mode 100755 misc/fixorders.pl2 delete mode 100755 misc/fixrefs.pl delete mode 100755 misc/makebaskets.pl delete mode 100755 misc/makeformats.pl delete mode 100755 orderbreakdown.pl delete mode 100755 updater/updatedatabase2.pl diff --git a/acqui.simple/savebiblio.pl b/acqui.simple/savebiblio.pl deleted file mode 100755 index 33871f6086..0000000000 --- a/acqui.simple/savebiblio.pl +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/perl - - -# Copyright 2000-2002 Katipo Communications -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -use CGI; -use strict; -use C4::Catalogue; -use C4::Biblio; - -my $input = new CGI; -my $biblio = { - title => $input->param('title'), - subtitle => $input->param('subtitle')?$input->param('subtitle'):"", - author => $input->param('author')?$input->param('author'):"", - seriestitle => $input->param('seriestitle')?$input->param('seriestitle'):"", - copyright => $input->param('copyrightdate')?$input->param('copyrightdate'):"", - abstract => $input->param('abstract')?$input->param('abstract'):"", - notes => $input->param('notes')?$input->param('notes'):"" -}; # my $biblio -my $biblionumber; - -if (! $biblio->{'title'}) { - print $input->redirect('addbiblio.pl?error=notitle'); -} else { - - $biblionumber = &newbiblio($biblio); - &newsubtitle($biblionumber, $biblio->{'subtitle'}); - - print $input->redirect("additem.pl?biblionumber=$biblionumber"); -} # else diff --git a/misc/fixborrower.pl b/misc/fixborrower.pl deleted file mode 100755 index be091d84b8..0000000000 --- a/misc/fixborrower.pl +++ /dev/null @@ -1,250 +0,0 @@ -#!/usr/bin/perl - -# This script will convert a database into the newer, proper -# form ... I think. - - - -# Copyright 2000-2002 Katipo Communications -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -use C4::Context; -use strict; - -my $dbh = C4::Context->dbh; - -my $query = "Select * from categories where (categorycode like 'L%' or categorycode like 'F%' -or categorycode like 'S%' or categorycode like 'O%' or categorycode like 'H%') and (categorycode <>'HR' -and categorycode <> 'ST')"; - -my $sth=$dbh->prepare($query); -$sth->execute; - -while (my $data=$sth->fetchrow_hashref){ - #update borrowers corresponding - #update categories - - my $temp=substr($data->{'categorycode'},0,1); - $query="update borrowers set area='$temp' where categorycode='$data->{'categorycode'}'"; - my $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - - $temp=substr($data->{'categorycode'},1,1); - $query="update borrowers set categorycode='$temp' where categorycode='$data->{'categorycode'}'"; - $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - - $query="delete from categories where categorycode='$data->{'categorycode'}'"; - $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - -} - -$query = "Select * from categories where (categorycode like 'V%') and (categorycode <>'HR' -and categorycode <> 'ST')"; - -my $sth=$dbh->prepare($query); # FIXME - There's already a $sth in this scope -$sth->execute; - -while (my $data=$sth->fetchrow_hashref){ - #update borrowers corresponding - #update categories -# my $temp=substr($data->{'categorycode'},0,1); - $query="update borrowers set area='V' where categorycode='$data->{'categorycode'}'"; - my $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - - my $temp=substr($data->{'categorycode'},1,1); - $query="update borrowers set categorycode='$temp' where categorycode='$data->{'categorycode'}'"; - $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - - $query="delete from categories where categorycode='$data->{'categorycode'}'"; - $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - -} - -my $query = "Select * from categories where categorycode = 'ST'"; # FIXME - There's already a $query in this scope -my $sth=$dbh->prepare($query); # FIXME - There's already a $sth in this scope -$sth->execute; - -while (my $data=$sth->fetchrow_hashref){ - #update borrowers corresponding - #update categories - $query="update borrowers set area='' where categorycode='$data->{'categorycode'}'"; - my $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - - $query="update borrowers set categorycode='W' where categorycode='$data->{'categorycode'}'"; - $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - - $query="delete from categories where categorycode='$data->{'categorycode'}'"; - $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - -} - -my $query = "Select * from categories where categorycode = 'BR' or categorycode='CO' or categorycode='IS'"; # FIXME - There's already a $query in this scope -my $sth=$dbh->prepare($query); # FIXME - There's already a $sth in this scope -$sth->execute; - -while (my $data=$sth->fetchrow_hashref){ - #update borrowers corresponding - #update categories - $query="update borrowers set area='' where categorycode='$data->{'categorycode'}'"; - my $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - - $query="update borrowers set categorycode='I' where categorycode='$data->{'categorycode'}'"; - $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - - $query="delete from categories where categorycode='$data->{'categorycode'}'"; - $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - -} - -my $query = "Select * from categories where categorycode = 'TD' or categorycode='TR'"; # FIXME - There's already a $query in this scope -my $sth=$dbh->prepare($query); # FIXME - There's already a $sth in this scope -$sth->execute; - -while (my $data=$sth->fetchrow_hashref){ - #update borrowers corresponding - #update categories - $query="update borrowers set area='X' where categorycode='$data->{'categorycode'}'"; - my $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - - $query="update borrowers set categorycode='A' where categorycode='$data->{'categorycode'}'"; - $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - - $query="delete from categories where categorycode='$data->{'categorycode'}'"; - $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - -} - -my $query = "Select * from categories where categorycode = 'HR'"; # FIXME - There's already a $query in this scope -my $sth=$dbh->prepare($query); # FIXME - There's already a $sth in this scope -$sth->execute; - -while (my $data=$sth->fetchrow_hashref){ - #update borrowers corresponding - #update categories - $query="update borrowers set area='K' where categorycode='$data->{'categorycode'}'"; - my $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - - $query="update borrowers set categorycode='A' where categorycode='$data->{'categorycode'}'"; - $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - - $query="delete from categories where categorycode='$data->{'categorycode'}'"; - $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - -} - -my $query = "Select * from categories where categorycode = 'IL'"; # FIXME - There's already a $query in this scope -my $sth=$dbh->prepare($query); # FIXME - There's already a $sth in this scope -$sth->execute; - -while (my $data=$sth->fetchrow_hashref){ - #update borrowers corresponding - #update categories - $query="update borrowers set area='Z' where categorycode='$data->{'categorycode'}'"; - my $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - - $query="update borrowers set categorycode='L' where categorycode='$data->{'categorycode'}'"; - $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - - $query="delete from categories where categorycode='$data->{'categorycode'}'"; - $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - -} - -my $query = "Select * from categories where categorycode = 'TB'"; # FIXME - There's already a $query in this scope -my $sth=$dbh->prepare($query); # FIXME - There's already a $sth in this scope -$sth->execute; -while (my $data=$sth->fetchrow_hashref){ - #update borrowers corresponding - #update categories - - $query="update borrowers set area='' where categorycode='$data->{'categorycode'}'"; - my $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - - $query="update borrowers set categorycode='P' where categorycode='$data->{'categorycode'}'"; - $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - - $query="delete from categories where categorycode='$data->{'categorycode'}'"; - $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - -} - -$sth->finish; - -my @queryValues = - ("insert into categories values ('E','Senior Citizen',5,99,0,'A',0,0,0,99,1)", - "insert into categories values ('A','Adult',5,99,0,'A',0,0,0,99,1)", - "insert into categories values ('C','Child',5,16,0,'A',0,0,0,99,0)", - "insert into categories values ('B','Housebound',5,99,0,'E',0,0,0,99,0)", - "insert into categories values ('F','Family',5,99,0,'A',0,0,0,99,1)", - "insert into categories values ('W','Workers',5,99,0,'A',0,0,0,99,0)", - "insert into categories values ('I','Institution',5,99,0,'A',0,0,0,99,0)", - "insert into categories values ('P','Privileged',5,99,0,'A',0,0,0,99,0)", - "insert into categories values ('L','Library',5,99,0,'A',0,0,0,99,0)" - ); - -foreach $query (@queryValues) { - $sth=$dbh->prepare($query); - $sth->execute; - $sth->finish; -} diff --git a/misc/fixcatalog.pl b/misc/fixcatalog.pl deleted file mode 100755 index d2295572a8..0000000000 --- a/misc/fixcatalog.pl +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/perl - - -# Copyright 2000-2002 Katipo Communications -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -use C4::Context; -use strict; - -my $dbh = C4::Context->dbh; - -my $sth=$dbh->prepare("Select biblio.biblionumber,biblio.title from biblio,catalogueentry where catalogueentry.entrytype -='t' and catalogueentry.catalogueentry=biblio.title limit 500"); -$sth->execute; -while (my $data=$sth->fetchrow_hashref){ - my $query="Update catalogueentry set biblionumber='$data->{'biblionumber'}' where catalogueentry.catalogueentry = - \"$data->{'title'}\" and catalogueentry.entrytype='t'"; - my $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; -} -$sth->finish; diff --git a/misc/fixorders.pl b/misc/fixorders.pl deleted file mode 100755 index e85764cefd..0000000000 --- a/misc/fixorders.pl +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/perl - - -# Copyright 2000-2002 Katipo Communications -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -use strict; -use C4::Context; - -my $dbh = C4::Context->dbh; - -my $sth=$dbh->prepare("Select ordernumber,biblionumber from aqorders order by ordernumber"); -$sth->execute; -my $number; -my $i=92000; -while (my $data=$sth->fetchrow_hashref){ - if ($data->{'ordernumber'} != $number){ - } else { - my $query="update aqorders set ordernumber=$i where ordernumber=$data->{'ordernumber'} and biblionumber=$data->{'biblionumber'}"; - my $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - $query="update aqorderbreakdown set ordernumber=$i where ordernumber=$data->{'ordernumber'}"; - $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; - $i++; - } - $number=$data->{'ordernumber'}; -} -$sth->finish; diff --git a/misc/fixorders.pl2 b/misc/fixorders.pl2 deleted file mode 100755 index 99497232f2..0000000000 --- a/misc/fixorders.pl2 +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/perl - - -use strict; -my $olddat; -while (my $dat =){ - my @data=split(/\t/,$dat); - if ($dat eq $olddat){ -# print "oi"; - } else { - print $dat; - } - $olddat=$dat; -} diff --git a/misc/fixrefs.pl b/misc/fixrefs.pl deleted file mode 100755 index 5989cd1f50..0000000000 --- a/misc/fixrefs.pl +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/perl - - -# Copyright 2000-2002 Katipo Communications -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -use strict; -use C4::Context; - -my $dbh = C4::Context->dbh; -my $count=0; -my $query="Select * from biblioitems where itemtype='REF' or itemtype='TREF'"; -my $sth=$dbh->prepare($query); -$sth->execute; - -while (my $data=$sth->fetchrow_hashref){ - $query="update items set notforloan=1 where biblioitemnumber='$data->{'biblioitemnumber'}'"; - my $sth2=$dbh->prepare($query); - $sth2->execute; - $sth2->finish; -} -$sth->finish; diff --git a/misc/makebaskets.pl b/misc/makebaskets.pl deleted file mode 100755 index 3e0b745f4c..0000000000 --- a/misc/makebaskets.pl +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/perl - - -# Copyright 2000-2002 Katipo Communications -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -use strict; -use C4::Context; - -my $dbh = C4::Context->dbh; -my $count=0; -my $basket='HLT-'; -for (my $i=1;$i<59;$i++){ - my $query = "Select authorisedby,entrydate from aqorders where booksellerid='$i'"; - $query.=" group by authorisedby,entrydate order by entrydate"; - my $sth=$dbh->prepare($query); - $sth->execute; - while (my $data=$sth->fetchrow_hashref){ - $basket=$count; - $data->{'authorisedby'}=~ s/\'/\\\'/g; - my $query2="update aqorders set basketno='$basket' where booksellerid='$i' and authorisedby= - '$data->{'authorisedby'}' and entrydate='$data->{'entrydate'}'"; - my $sth2=$dbh->prepare($query2); - $sth2->execute; - $sth2->finish; - $count++; - } - $sth->finish; -} diff --git a/misc/makeformats.pl b/misc/makeformats.pl deleted file mode 100755 index 66093238b4..0000000000 --- a/misc/makeformats.pl +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/perl - - -# Copyright 2000-2002 Katipo Communications -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -use strict; -use C4::Context; - -my $dbh = C4::Context->dbh; -my $count=0; -my $query="Select biblionumber from aqorders where datereceived = '0000-00-00'"; -my $sth=$dbh->prepare($query); -$sth->execute; - -my $query2="Select max(biblioitemnumber) from biblioitems"; -my $sth2=$dbh->prepare($query2); -$sth2->execute; -my $data=$sth2->fetchrow_hashref; -my $bibitemno=$data->{'max(biblioitemnumber)'}; -print $bibitemno; -$bibitemno++; -$sth2->finish; -while (my $data=$sth->fetchrow_hashref){ - $sth2=$dbh->prepare("insert into biblioitems (biblioitemnumber,biblionumber) values - ($bibitemno,$data->{'biblionumber'})"); - $sth2->execute; - $sth2->finish; - $sth2=$dbh->prepare("update aqorders set biblioitemnumber=$bibitemno where biblionumber - =$data->{'biblionumber'}"); - $sth2->execute; - $sth2->finish; - $bibitemno++ - -} -$sth->finish; diff --git a/orderbreakdown.pl b/orderbreakdown.pl deleted file mode 100755 index 7007be27c7..0000000000 --- a/orderbreakdown.pl +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/perl - -#script to display info about acquisitions -#written by chris@katipo.co.nz 31/01/2000 - - -# Copyright 2000-2002 Katipo Communications -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -use C4::Acquisitions; -use C4::Biblio; -use C4::Output; -use CGI; -my $input=new CGI; -print $input->header(); -my $id=$input->param('id'); -my ($count,$order)=breakdown($id); -print startpage; -print mktablehdr; -#print $id; -for (my$i=0;$i<$count;$i++){ -print mktablerow(5,'white',"Ordernumber:$order->[$i]->{'ordernumber'}", -"Line umber:$order->[$i]->{'linenumber'}","Branch Code:$order->[$i]->{'branchcode'}", -"Bookfundid:$order->[$i]->{'bookfundid'}","Allocation:$order->[$i]->{'allocation'}"); -} -print mktableft; -print endpage; diff --git a/updater/updatedatabase2.pl b/updater/updatedatabase2.pl deleted file mode 100755 index de59fc2e7c..0000000000 --- a/updater/updatedatabase2.pl +++ /dev/null @@ -1,192 +0,0 @@ -#!/usr/bin/perl - -# WARNING : this script is intended to be run as is only on a sample DB. -# in the sample DB downloadable from sourceforge, the aqbookfund table is full of trash data. -# this script drops this table and refill it with correct data. -# some tables have strange data too, so primary key cannot be created. - -# if you want to apply this patch on a running DB : -# - do a backup ! -# - remove the lines between and -# - remove the # before the lines between and -# this will cause a primary key to be created if possible on your DB -# YOU'VE BEEN WARNING !!!!! - - - -# Copyright 2000-2002 Katipo Communications -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA - -use C4::Context; -use C4::Catalogue; -use DBI; -use C4::Acquisitions; -use C4::Output; - -sub droptable { - my ($dbh,$tablename)=@_; - if ($tables{$tablename}) { # FIXME - $tables undefined - print " - $tablename...\n"; - my $sti=$dbh->prepare("DROP TABLE $tablename"); - $sti->execute; - return 1; - } - return 0; -} -sub dosql { - my ($dbh,$sql_cmd)=@_; - my $sti=$dbh->prepare($sql_cmd); - $sti->execute; - if ($sti->err) { - print "error : ".$sti->errstr." \n tried to execute : $sql_cmd\n"; - $sti->finish; - } -} - - -my $dbh = C4::Context->dbh; - -my %tables; -my $sth=$dbh->prepare("show tables"); -$sth->execute; -while (my ($table) = $sth->fetchrow) { - $tables{$table}=1; -} - -print "creating thesaurus...\n"; -dosql($dbh,"CREATE TABLE bibliothesaurus (code BIGINT not null AUTO_INCREMENT, freelib CHAR (255) not null , stdlib CHAR (255) not null , type CHAR (80) not null , PRIMARY KEY (code), INDEX (freelib),index(stdlib),index(type))"); - my $sti=$dbh->prepare("select subject from bibliosubject"); - $sti->execute; - $i=0; - while ($line =$sti->fetchrow_hashref) { - $i++; - print "$i $line->{'subject'}\n"; - $sti2=$dbh->prepare("select count(*) as t from bibliothesaurus where freelib=".$dbh->quote($line->{'subject'})); - $sti2->execute; - if ($sti2->err) { - print "error : ".$sti2->errstr." \n tried to execute : $sql_cmd\n"; - # FIXME - $sql_cmd undefined - die; - } - $line2=$sti2->fetchrow_hashref; - if ($line2->{'t'} ==0) { - dosql($dbh,"insert into bibliothesaurus (freelib,stdlib) values (".$dbh->quote($line->{'subject'}).",".$dbh->quote($line->{'subject'}).")"); - } else { - print "pas ecriture pour : $line->{'subject'}\n"; - } - - } - -#aqbookfund : the sample db is full of trash data. Delete and recreate -# - print "aqbookfund..."; - dosql($dbh,"delete from aqbookfund"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '5', 'Young Adult Fiction', '3')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '4', 'Fiction', '2')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '2', 'Talking books', '4')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '13', 'Newspapers & journals', '4')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '10', 'Te Ao Maori', '1')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '15', 'CDs, CD Roms, Maps, etc', '4')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '9', 'Junior Fiction', '3')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '7', 'Junior Non-Fiction', '3')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '72', 'Creative NZ', '4')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '11', 'Reference', '1')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '12', 'Videos', '4')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '8', 'Junior Paperback', '3')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '73', 'Large Print Link-up', '2')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '3', 'Large Print', '2')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '71', 'Creative NZ NonFiction', '1')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '6', 'Picture Books', '3')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '14', 'Nga pukapuka Maori', '3')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '80', 'Donations, junior books', '5')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '81', 'Donations, adult books', '5')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '82', 'Donations, magazines', '5')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '83', 'Donations, non books', '5')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '91', 'Vertical File', '5')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '100', 'Loans', '6')"); - dosql($dbh,"INSERT INTO aqbookfund VALUES( '1', 'Test', '1')"); -# - dosql($dbh,"ALTER TABLE aqbookfund DROP PRIMARY KEY, ADD PRIMARY KEY(bookfundid);"); - print "done\n accountlines..."; - dosql($dbh,"ALTER TABLE accountlines CHANGE itemnumber itemnumber INT (11) not null;"); - dosql($dbh,"ALTER TABLE accountlines DROP PRIMARY KEY, ADD PRIMARY KEY(borrowernumber,accountno,itemnumber);"); -# accountoffset not done (not possible ?) -#additionalauthor : not possible (no field useable, 1 index OK) - print "done\n aqbooksellers..."; - dosql($dbh,"ALTER TABLE aqbooksellers CHANGE id id INT (11) not null;"); - dosql($dbh,"ALTER TABLE aqbooksellers DROP PRIMARY KEY, ADD PRIMARY KEY(id);"); - print "done\n aqbudget..."; - dosql($dbh,"ALTER TABLE aqbudget DROP PRIMARY KEY, ADD PRIMARY KEY(bookfundid, bookfundid);"); - print "done\n aqorderbreakdown..."; - dosql($dbh,"ALTER TABLE aqorderbreakdown CHANGE ordernumber ordernumber INT (11) not null;"); - dosql($dbh,"ALTER TABLE aqorderbreakdown CHANGE linenumber linenumber INT (11) not null;"); - dosql($dbh,"ALTER TABLE aqorderbreakdown CHANGE branchcode branchcode CHAR (4) not null;"); -# -# ALTER TABLE aqorderbreakdown DROP PRIMARY KEY, ADD PRIMARY KEY(ordernumber,linenumber,branchcode);"); -# - - print "done\n biblio/borrowers..."; - dosql($dbh,"ALTER TABLE aqorderdelivery DROP PRIMARY KEY, ADD PRIMARY KEY(ordernumber);"); - dosql($dbh,"ALTER TABLE aqorders DROP PRIMARY KEY, ADD PRIMARY KEY(ordernumber);"); - dosql($dbh,"ALTER TABLE biblio DROP PRIMARY KEY, ADD PRIMARY KEY(biblionumber);"); - dosql($dbh,"ALTER TABLE biblioitems DROP PRIMARY KEY, ADD PRIMARY KEY(biblionumber, biblioitemnumber)"); - dosql($dbh,"CREATE INDEX SUBTITLE ON bibliosubtitle (subtitle(80))"); - dosql($dbh,"ALTER TABLE borexp CHANGE borrowernumber borrowernumber INT (11) not null"); - dosql($dbh,"ALTER TABLE borexp CHANGE newexp newexp DATE not null"); - dosql($dbh,"ALTER TABLE branches DROP PRIMARY KEY, ADD PRIMARY KEY(branchcode)"); - dosql($dbh,"ALTER TABLE deletedbiblio DROP PRIMARY KEY, ADD PRIMARY KEY(biblionumber, biblionumber)"); - dosql($dbh,"ALTER TABLE deletedbiblioitems DROP PRIMARY KEY, ADD PRIMARY KEY(biblioitemnumber)"); - dosql($dbh,"ALTER TABLE deletedborrowers DROP PRIMARY KEY, ADD PRIMARY KEY(borrowernumber)"); - dosql($dbh,"ALTER TABLE deleteditems DROP PRIMARY KEY, ADD PRIMARY KEY(itemnumber)"); - dosql($dbh,"ALTER TABLE issues CHANGE date_due date_due DATE not null"); -# -# ALTER TABLE issues DROP PRIMARY KEY, ADD PRIMARY KEY(borrowernumber,itemnumber,date_due)"); -# - print "done\n items..."; - dosql($dbh,"ALTER TABLE items DROP PRIMARY KEY, ADD PRIMARY KEY(itemnumber)"); - dosql($dbh,"ALTER TABLE itemsprices CHANGE itemnumber itemnumber INT (11) not null"); - dosql($dbh,"ALTER TABLE itemsprices DROP PRIMARY KEY, ADD PRIMARY KEY(itemnumber)"); - dosql($dbh,"ALTER TABLE itemtypes DROP PRIMARY KEY, ADD PRIMARY KEY(itemtype)"); - print "done\n various..."; - dosql($dbh,"ALTER TABLE categories DROP PRIMARY KEY, ADD PRIMARY KEY(categorycode)"); - dosql($dbh,"ALTER TABLE categoryitem DROP PRIMARY KEY, ADD PRIMARY KEY(categorycode,itemtype)"); - dosql($dbh,"ALTER TABLE currency CHANGE currency currency VARCHAR (10) not null"); - dosql($dbh,"ALTER TABLE currency CHANGE rate rate FLOAT (7,5) not null"); - dosql($dbh,"ALTER TABLE currency DROP PRIMARY KEY, ADD PRIMARY KEY(currency)"); - dosql($dbh,"ALTER TABLE printers CHANGE printername printername CHAR (40) not null"); - dosql($dbh,"ALTER TABLE printers DROP PRIMARY KEY, ADD PRIMARY KEY(printername)"); -# -# ALTER TABLE reserves DROP PRIMARY KEY, ADD PRIMARY KEY(borrowernumber,biblionumber,reservedate) -# - dosql($dbh,"ALTER TABLE stopwords CHANGE word word VARCHAR (255) not null"); - dosql($dbh,"ALTER TABLE stopwords DROP PRIMARY KEY, ADD PRIMARY KEY(word)"); - dosql($dbh,"ALTER TABLE systempreferences DROP PRIMARY KEY, ADD PRIMARY KEY(variable)"); - dosql($dbh,"ALTER TABLE users CHANGE usercode usercode VARCHAR (10) not null"); - dosql($dbh,"ALTER TABLE users DROP PRIMARY KEY, ADD PRIMARY KEY(usercode)"); - -print "dropping tables...\n"; -my $total=0; -$total += droptable($dbh,'branchcategories'); -$total += droptable($dbh,'classification'); -$total += droptable($dbh,'multipart'); -$total += droptable($dbh,'multivolume'); -$total += droptable($dbh,'newitems'); -$total += droptable($dbh,'procedures'); -$total += droptable($dbh,'publisher'); -$total += droptable($dbh,'searchstats'); -$total += droptable($dbh,'serialissues'); -print " $total tables dropped\n"; -- 2.39.2