Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tool to generate initial migrations
- 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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
|