bad4b969020a5bd5f482eac78dd5dfa97625a39f
[koha.git] / misc / migration_tools / 22_to_30 / convert_to_utf8.pl
1 #!/usr/bin/perl
2
3 # small script to convert mysql tables to utf-8
4
5 use strict;
6 BEGIN {
7     # find Koha's Perl modules
8     # test carefully before changing this
9     use FindBin;
10     eval { require "$FindBin::Bin/../../kohalib.pl" };
11 }
12 use C4::Context;
13
14 my $dbh=C4::Context->dbh();
15
16 my $database=C4::Context->config("database");
17 my $query="Show tables";
18 my $sth=$dbh->prepare($query);
19 $sth->execute();
20 while (my @table=$sth->fetchrow_array()){
21     print "Altering table $table[0]\n";
22     my $alter_query="ALTER TABLE $table[0] convert to CHARACTER SET UTF8 collate utf8_general_ci";
23     my $sth2=$dbh->prepare($alter_query);
24     $sth2->execute();
25     $sth2->finish();
26
27 }
28 $sth->finish();
29 $dbh->disconnect();