From: Arthur Axel 'fREW' Schmidt Date: Tue, 23 Feb 2010 00:44:33 +0000 (-0600) Subject: remove dead function, fix logic error, add (for now) proxy method X-Git-Tag: v0.001000_01~156 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ceef4ff5cf15c44f451cd4d3300dea25fcf58599;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git remove dead function, fix logic error, add (for now) proxy method --- diff --git a/lib/DBIx/Class/DeploymentHandler.pm b/lib/DBIx/Class/DeploymentHandler.pm index cbae8ca..6bbde02 100644 --- a/lib/DBIx/Class/DeploymentHandler.pm +++ b/lib/DBIx/Class/DeploymentHandler.pm @@ -11,14 +11,14 @@ has schema => ( isa => 'DBIx::Class::Schema', is => 'ro', required => 1, - handles => [qw{schema_version}], + handles => [qw( schema_version )], ); has upgrade_directory => ( isa => 'Str', is => 'ro', required => 1, - default => 'sql', + default => 'upgrades', ); has backup_directory => ( @@ -66,9 +66,11 @@ method _build_version_rs { $self->schema->resultset('VersionResult') } method backup { $self->storage->backup($self->backup_directory) } +method create_ddl_dir { $self->storage->create_ddl_dir( $self->schema, @_ ) } + method install($new_version) { carp 'Install not possible as versions table already exists in database' - unless $self->is_installed; + if $self->is_installed; $new_version ||= $self->schema_version; @@ -179,70 +181,6 @@ method apply_statement($statement) { $self->storage->dbh->do($_) or carp "SQL was: $_" } -sub _create_db_to_schema_diff { - my $self = shift; - - my %driver_to_db_map = ( - 'mysql' => 'MySQL' - ); - - my $db = $driver_to_db_map{$self->storage->dbh->{Driver}{Name}}; - unless ($db) { - # croak? - print "Sorry, this is an unsupported DB\n"; - return; - } - - $self->throw_exception($self->storage->_sqlt_version_error) - unless $self->storage->_sqlt_version_ok; - - my $db_tr = SQL::Translator->new({ - add_drop_table => 1, - parser => 'DBI', - parser_args => { dbh => $self->storage->dbh }, - producer => $db, - }); - - my $dbic_tr = SQL::Translator->new({ - parser => 'SQL::Translator::Parser::DBIx::Class', - data => $self, - producer => $db, - }); - - $db_tr->schema->name('db_schema'); - $dbic_tr->schema->name('dbic_schema'); - - # is this really necessary? - foreach my $tr ($db_tr, $dbic_tr) { - my $data = $tr->data; - $tr->parser->($tr, $$data); - } - - my $diff = SQL::Translator::Diff::schema_diff( - $db_tr->schema, $db, - $dbic_tr->schema, $db, { - ignore_constraint_names => 1, - ignore_index_names => 1, - caseopt => 1, - } - ); - - my $filename = $self->ddl_filename( - $db, - $self->schema_version, - $self->upgrade_directory, - 'PRE', - ); - - open my $file, '>', $filename - or $self->throw_exception("Can't open $filename for writing ($!)"); - print {$file} $diff; - close $file; - - carp "WARNING: There may be differences between your DB and your DBIC schema.\n" . - "Please review and if necessary run the SQL in $filename to sync your DB.\n"; -} - method _read_sql_file($file) { return unless $file;