From: Jess Robinson Date: Sat, 11 Mar 2006 23:09:06 +0000 (+0000) Subject: deploy debugging and drop table statements X-Git-Tag: v0.06000~60^2~29 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=85dea9a95925c5a8c6b15f7ab59d06a737015812;p=dbsrgits%2FDBIx-Class.git deploy debugging and drop table statements --- diff --git a/Changes b/Changes index 835055f..0b11f96 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for DBIx::Class +0.05990_03 + - deploy now adds drop statements before creates + - deploy outputs debugging statements if DBIX_CLASS_STORAGE_DBI_DEBUG is set + 0.05990_02 2006-03-10 13:31:37 - remove test dep on YAML - additional speed tweaks for C3 diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 03f3a6c..f6e682d 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -551,7 +551,23 @@ sub deployment_statements { $self->throw_exception($@) if $@; eval "use SQL::Translator::Producer::${type};"; $self->throw_exception($@) if $@; - my $tr = SQL::Translator->new(); + my $tr = SQL::Translator->new( + # Print debug info + debug => 1, + # Print Parse::RecDescent trace + trace => 0, + # Don't include comments in output + no_comments => 1, + # Print name mutations, conflicts + show_warnings => 0, + # Add "drop table" statements + add_drop_table => 1, + # Validate schema object + validate => 1, + # Make all table names CAPS in producers which support this option + format_table_name => sub {my $tablename = shift; return uc($tablename)}, + ); + SQL::Translator::Parser::DBIx::Class::parse( $tr, $schema ); return "SQL::Translator::Producer::${type}"->can('produce')->($tr); } @@ -559,6 +575,7 @@ sub deployment_statements { sub deploy { my ($self, $schema, $type) = @_; foreach(split(";\n", $self->deployment_statements($schema, $type))) { + $self->debugfh->print("$_\n") if $self->debug; $self->dbh->do($_) or warn "SQL was:\n $_"; } }