2017-04-23 18:49:07 +00:00
|
|
|
#!/usr/bin/perl -w -I.
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Data::Dumper;
|
2017-04-23 18:51:48 +00:00
|
|
|
use RSSTootalizer::Migration;
|
2017-04-23 18:49:07 +00:00
|
|
|
|
|
|
|
our $config = "";
|
2017-04-23 18:51:48 +00:00
|
|
|
open CONFIG, "rsstootalizer.conf.json" or die "Cannot open rsstootalizer.conf.json";
|
2017-04-23 18:49:07 +00:00
|
|
|
{
|
|
|
|
$/ = undef;
|
|
|
|
$config = <CONFIG>;
|
|
|
|
}
|
|
|
|
close CONFIG;
|
|
|
|
$config = decode_json($config);
|
|
|
|
|
|
|
|
# Force Unicode output
|
|
|
|
binmode STDERR, ":utf8";
|
|
|
|
binmode STDOUT, ":utf8";
|
|
|
|
|
|
|
|
my @migrations = glob ("migrations/*sql");
|
|
|
|
foreach my $migration (@migrations){
|
|
|
|
print "Running migration $migration\n";
|
2017-04-23 18:51:48 +00:00
|
|
|
if (!RSSTootalizer::Migration->get_by("name", $migration)){
|
2017-04-23 18:49:07 +00:00
|
|
|
open (M, $migration);
|
|
|
|
my $sql;
|
|
|
|
{
|
|
|
|
$/ = undef;
|
|
|
|
$sql = <M>;
|
|
|
|
}
|
|
|
|
close M;
|
2017-04-23 18:51:48 +00:00
|
|
|
RSSTootalizer::DB->doINSERT($sql);
|
2017-04-23 18:49:07 +00:00
|
|
|
my %migdata;
|
|
|
|
$migdata{name} = $migration;
|
2017-04-23 18:51:48 +00:00
|
|
|
RSSTootalizer::Migration->create(%migdata);
|
2017-04-23 18:49:07 +00:00
|
|
|
}
|
|
|
|
}
|