diff options
author | franck cuny <franck@lumberjaph.net> | 2010-10-03 14:54:40 +0200 |
---|---|---|
committer | franck cuny <franck@lumberjaph.net> | 2010-10-03 14:54:40 +0200 |
commit | 10eabd14b4d11603b436ca7291f56215c55e5404 (patch) | |
tree | a480b9202d7f2d8e1531c80c8aa88a42128656d8 /scripts | |
parent | update makefile (diff) | |
download | jitterbug-10eabd14b4d11603b436ca7291f56215c55e5404.tar.gz |
script to import frmo redis; more data to tests
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), + } + ); +} |