From 10eabd14b4d11603b436ca7291f56215c55e5404 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Sun, 3 Oct 2010 14:54:40 +0200 Subject: script to import frmo redis; more data to tests --- scripts/migrate_from_redis.pl | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 scripts/migrate_from_redis.pl (limited to 'scripts/migrate_from_redis.pl') 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), + } + ); +} -- cgit 1.4.1