class_name => 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator',
delegate_name => 'deploy_method',
attributes_to_assume => [qw(schema schema_version)],
- attributes_to_copy => [qw( databases script_directory sql_translator_args )],
+ attributes_to_copy => [qw( ignore_ddl databases script_directory sql_translator_args )],
},
'DBIx::Class::DeploymentHandler::WithApplicatorDumple' => {
interface_role => 'DBIx::Class::DeploymentHandler::HandlesVersioning',
with 'DBIx::Class::DeploymentHandler::HandlesDeploy';
+has ignore_ddl => (
+ isa => 'Bool',
+ is => 'ro',
+ default => undef,
+);
+
has schema => (
isa => 'DBIx::Class::Schema',
is => 'ro',
return $sql;
}
+method _deploy($version) {
+ if (!$self->ignore_ddl) {
+ return $self->_run_sql_and_perl($self->_ddl_schema_consume_filenames(
+ $self->storage->sqlt_type,
+ $version,
+ ));
+ } else {
+ my $sqlt = SQL::Translator->new({
+ add_drop_table => 1,
+ parser => 'SQL::Translator::Parser::YAML',
+ producer => $self->storage->sqlt_type;
+ %{$sqltargs},
+ });
+
+ my $yaml_filename = $self->$from_file($version);
+
+ my @sql = $sqlt->translate($yaml_filename);
+ croak("Failed to translate to $db, skipping. (" . $sqlt->error . ")")
+ unless $sql;
+ }
+}
+
sub deploy {
my $self = shift;
my $version = (shift @_ || {})->{version} || $self->schema_version;
log_info { "deploying version $version" };
-
- return $self->_run_sql_and_perl($self->_ddl_schema_consume_filenames(
- $self->storage->sqlt_type,
- $version,
- ));
+ $self->_deploy($version);
}
sub preinstall {
my $dir = $self->script_directory;
my $version = $self->schema_version;
+ return if $self->ignore_ddl;
+
my $sqlt = SQL::Translator->new({
add_drop_table => 1,
parser => 'SQL::Translator::Parser::YAML',
my $dir = $self->script_directory;
my $sqltargs = $self->sql_translator_args;
+ return if $self->ignore_ddl;
+
my $schema_version = $self->schema_version;
$sqltargs = {