diff options
Diffstat (limited to '')
-rw-r--r-- | scripts/migrate_from_redis.pl | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/scripts/migrate_from_redis.pl b/scripts/migrate_from_redis.pl new file mode 100644 index 0000000..61490c1 --- /dev/null +++ b/scripts/migrate_from_redis.pl @@ -0,0 +1,41 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use jitterbug::Schema; + +use YAML qw/LoadFile/; +use JSON; + +my $conf = shift || die "config is missing"; +my $data = shift || die "data is missing"; + +$conf = LoadFile($conf); +$data = LoadFile($data); + +my $schema = jitterbug::Schema->connect( + @{ $conf->{plugins}->{DBIC}->{schema}->{connect_info} } ); + +my $project = $schema->resultset('Project')->create( + { + name => $data->{desc}->{name}, + url => $data->{desc}->{url}, + description => $data->{desc}->{description}, + owner => JSON::encode_json( $data->{desc}->{owner} ), + } +); + +foreach my $build ( @{ $data->{builds} } ) { + my $sha256 = delete $build->{commit}; + my $timestamp = $build->{timestamp}; + my $tests = delete $build->{version}; + $build->{build}->{version} = $tests; + $schema->resultset('Commit')->create( + { + sha256 => $sha256, + projectid => $project->projectid, + timestamp => $timestamp, + content => JSON::encode_json($build), + } + ); +} |