Skip to content

Commit

Permalink
add tool to generate initial migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Axel 'fREW' Schmidt committed Sep 19, 2012
1 parent d0b620f commit e27144e
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions maint/gen-migration
@@ -0,0 +1,40 @@
#!/usr/bin/env perl

use 5.16.1;
use warnings;

use rlib;

use DU::DeploymentHandler;
use DU::Schema;

use SQL::Translator;
use SQL::Translator::Producer::SQLite;
$SQL::Translator::Producer::SQLite::NO_QUOTES = 0;

my $d = DU::DeploymentHandler->new({
schema => 'DU::Schema',
databases => 'SQLite',
sql_translator_args => {
add_drop_table => 0,
no_comments => 1,
producer_args => { no_transaction => 1 },
},
});

if ($DU::Schema::VERSION > 1) {
$d->deploy_method->prepare_protoschema({
# Exclude __VERSION so that it gets installed separately
parser_args => {
sources => [grep { $_ ne '__VERSION' } DU::Schema->sources],
}
}, '_ddl_protoschema_produce_filename');

$d->prepare_upgrade({
from_version => $DU::Schema::VERSION - 1,
to_version => $DU::Schema::VERSION,
});
} else {
$d->prepare_install
}

0 comments on commit e27144e

Please sign in to comment.