summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/sqlite-migration17
1 files changed, 10 insertions, 7 deletions
diff --git a/bin/sqlite-migration b/bin/sqlite-migration
index 86c7d66..2b2d235 100755
--- a/bin/sqlite-migration
+++ b/bin/sqlite-migration
@@ -17,6 +17,8 @@ our $VERSION = '0.00';
my $dbname = shift // 'dbdb';
+say "connecting to databases...";
+
my $old_dbh = DBI->connect( "dbi:SQLite:dbname=iris.sqlite", q{}, q{} );
my $dbh = DBI->connect( "dbi:Pg:dbname=$dbname;host=localhost;port=5432",
'dbdb', $ENV{DBDB_PASSWORD} );
@@ -75,6 +77,7 @@ sub get_id {
}
}
+say "checking tables...";
if ( not table_exists('lines') ) {
$dbh->do(
qq{
@@ -179,6 +182,8 @@ $timer->attr(
max => $total,
);
+print "copying data\n\n";
+
my $i = 0;
for my $row ( @{ $old_dbh->selectall_arrayref('select * from departures') } ) {
@@ -188,10 +193,8 @@ for my $row ( @{ $old_dbh->selectall_arrayref('select * from departures') } ) {
$train_no, $line_no, $platform
) = @{$row};
- if ( ( ++$i % 20 ) == 0 ) {
- print $timer->report(
- "\r\e[2Kmain table: %40b ETR %E", $i
- );
+ if ( ( ++$i % 100 ) == 0 ) {
+ print $timer->report( "\r\e[2Kmain table: %40b ETR %E", $i );
}
my $station_id = get_id( 'station_codes', $station );
@@ -220,14 +223,13 @@ for my $row ( @{ $old_dbh->selectall_arrayref('select * from departures') } ) {
}
}
+print "\n";
$timer->restart(
min => 1,
max => $total,
);
for my $msg ( 1 .. 99 ) {
- print $timer->report(
- "\r\e[2Kmsg table : %40b ETR %E", $msg
- );
+ print $timer->report( "\r\e[2Kmsg table : %40b ETR %E", $msg );
for my $row ( @{ $old_dbh->selectall_arrayref("select * from msg_$msg") } )
{
if ( not table_has_departure( "msg_$msg", @{$row} ) ) {
@@ -235,6 +237,7 @@ for my $msg ( 1 .. 99 ) {
}
}
}
+print "\ndone!\n";
__END__