diff options
author | franck cuny <franck@lumberjaph.net> | 2011-02-13 16:20:59 +0100 |
---|---|---|
committer | franck cuny <franck@lumberjaph.net> | 2011-02-13 16:20:59 +0100 |
commit | e81938b20ae19d472a6f835f8af01a428b8724de (patch) | |
tree | d6cea5e811f60fcd8f3c94ee1d9b4cf247404531 /scripts/upgrade_db.pl | |
parent | Make jitterbug::Test use the current perl interp (diff) | |
parent | Merge branch 'feature/stack_builds' into devel (diff) | |
download | jitterbug-e81938b20ae19d472a6f835f8af01a428b8724de.tar.gz |
Merge branch 'devel'
* devel: add more tests inside the hook, we check if we can add more than one task for this project add configuration option to skip some branches; add tests for the Hook that's why we want datetime use DateTime update templates to show informations about running tasks column started_when: datetime when the build started prepare to update schema again display current build if any add sql schema for various version don't ignore .sql files script to migrate/upgrade dbix schema add version to our schema update templates and css we want a find, not a search here add pending status to the schema (TODO: need a script to migrate the schema) load tasks and display them on the dashboard
Diffstat (limited to '')
-rwxr-xr-x | scripts/upgrade_db.pl | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/scripts/upgrade_db.pl b/scripts/upgrade_db.pl new file mode 100755 index 0000000..00f6306 --- /dev/null +++ b/scripts/upgrade_db.pl @@ -0,0 +1,70 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use lib 'lib'; + +use YAML::Syck; +use DBIx::Class::DeploymentHandler; +use SQL::Translator; + +my $config = shift; +die "need configuration file" unless $config; + +my $schema = 'jitterbug::Schema'; + +my $version = eval "use $schema; $schema->VERSION" or die $@; + +print "processing version $version of $schema...\n"; + +my $jitterbug_conf = LoadFile($config); +my $dbix_conf = $jitterbug_conf->{plugins}->{DBIC}->{schema}; +my $s = $schema->connect( @{ $dbix_conf->{connect_info} } ); + +my $dh = DBIx::Class::DeploymentHandler->new( + { + schema => $s, + databases => [qw/ SQLite PostgreSQL MySQL /], + sql_translator_args => { add_drop_table => 0, }, + } +); + +print "generating deployment script\n"; +$dh->prepare_install; + +if ( $version > 1 ) { + print "generating upgrade script\n"; + $dh->prepare_upgrade( + { + from_version => $version - 1, + to_version => $version, + version_set => [ $version - 1, $version ], + } + ); + + print "generating downgrade script\n"; + $dh->prepare_downgrade( + { + from_version => $version, + to_version => $version - 1, + version_set => [ $version, $version - 1 ], + } + ); +} + +# print "generating graph\n"; + +# my $trans = SQL::Translator->new( +# parser => 'SQL::Translator::Parser::DBIx::Class', +# parser_args => { package => $schema }, +# producer_args => { +# show_constraints => 1, +# show_datatypes => 1, +# show_sizes => 1, +# show_fk_only => 0, +# } +# ); + +# $trans->translate; + +print "done\n"; |