From: Jess Robinson Date: Sun, 12 Mar 2006 00:01:27 +0000 (+0000) Subject: Oops, deploy only drops tables if you tell it to.. X-Git-Tag: v0.06000~60^2~28 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cb561d1a7f53ab9a2e505d86c64cfc6977b4db78;hp=85dea9a95925c5a8c6b15f7ab59d06a737015812;p=dbsrgits%2FDBIx-Class.git Oops, deploy only drops tables if you tell it to.. Also add sizes to varchar fields in dbictest schema --- diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 84e5263..a50b26b 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -543,9 +543,9 @@ Attempts to deploy the schema to the current storage =cut sub deploy { - my ($self) = shift; + my ($self, $sqltargs) = @_; $self->throw_exception("Can't deploy without storage") unless $self->storage; - $self->storage->deploy($self); + $self->storage->deploy($self, undef, $sqltargs); } 1; diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index f6e682d..f780d55 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -543,7 +543,7 @@ sub last_insert_id { sub sqlt_type { shift->dbh->{Driver}->{Name} } sub deployment_statements { - my ($self, $schema, $type) = @_; + my ($self, $schema, $type, $sqltargs) = @_; $type ||= $self->sqlt_type; eval "use SQL::Translator"; $self->throw_exception("Can't deploy without SQL::Translator: $@") if $@; @@ -551,30 +551,14 @@ sub deployment_statements { $self->throw_exception($@) if $@; eval "use SQL::Translator::Producer::${type};"; $self->throw_exception($@) if $@; - 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)}, - ); - + my $tr = SQL::Translator->new(%$sqltargs); SQL::Translator::Parser::DBIx::Class::parse( $tr, $schema ); return "SQL::Translator::Producer::${type}"->can('produce')->($tr); } sub deploy { - my ($self, $schema, $type) = @_; - foreach(split(";\n", $self->deployment_statements($schema, $type))) { + my ($self, $schema, $type, $sqltargs) = @_; + foreach(split(";\n", $self->deployment_statements($schema, $type, $sqltargs))) { $self->debugfh->print("$_\n") if $self->debug; $self->dbh->do($_) or warn "SQL was:\n $_"; } diff --git a/t/lib/DBICTest/Schema/Artist.pm b/t/lib/DBICTest/Schema/Artist.pm index 43504b3..f4c6706 100644 --- a/t/lib/DBICTest/Schema/Artist.pm +++ b/t/lib/DBICTest/Schema/Artist.pm @@ -13,6 +13,7 @@ DBICTest::Schema::Artist->add_columns( }, 'name' => { data_type => 'varchar', + size => 100, is_nullable => 1, }, ); diff --git a/t/lib/DBICTest/Schema/CD.pm b/t/lib/DBICTest/Schema/CD.pm index 7487644..90e4c0c 100644 --- a/t/lib/DBICTest/Schema/CD.pm +++ b/t/lib/DBICTest/Schema/CD.pm @@ -16,9 +16,11 @@ DBICTest::Schema::CD->add_columns( }, 'title' => { data_type => 'varchar', + size => 100, }, 'year' => { data_type => 'varchar', + size => 100, }, ); DBICTest::Schema::CD->set_primary_key('cdid'); diff --git a/t/lib/DBICTest/Schema/LinerNotes.pm b/t/lib/DBICTest/Schema/LinerNotes.pm index 19e4025..013cf91 100644 --- a/t/lib/DBICTest/Schema/LinerNotes.pm +++ b/t/lib/DBICTest/Schema/LinerNotes.pm @@ -10,6 +10,7 @@ DBICTest::Schema::LinerNotes->add_columns( }, 'notes' => { data_type => 'varchar', + size => 100, }, ); DBICTest::Schema::LinerNotes->set_primary_key('liner_id'); diff --git a/t/lib/DBICTest/Schema/Producer.pm b/t/lib/DBICTest/Schema/Producer.pm index d1cbc18..36b63a1 100644 --- a/t/lib/DBICTest/Schema/Producer.pm +++ b/t/lib/DBICTest/Schema/Producer.pm @@ -11,6 +11,7 @@ __PACKAGE__->add_columns( }, 'name' => { data_type => 'varchar', + size => 100, }, ); __PACKAGE__->set_primary_key('producerid'); diff --git a/t/lib/DBICTest/Schema/SelfRef.pm b/t/lib/DBICTest/Schema/SelfRef.pm index 2817b67..474c1a2 100644 --- a/t/lib/DBICTest/Schema/SelfRef.pm +++ b/t/lib/DBICTest/Schema/SelfRef.pm @@ -11,6 +11,7 @@ __PACKAGE__->add_columns( }, 'name' => { data_type => 'varchar', + size => 100, }, ); __PACKAGE__->set_primary_key('id'); diff --git a/t/lib/DBICTest/Schema/Tag.pm b/t/lib/DBICTest/Schema/Tag.pm index 4fdf230..b93b622 100644 --- a/t/lib/DBICTest/Schema/Tag.pm +++ b/t/lib/DBICTest/Schema/Tag.pm @@ -15,7 +15,8 @@ DBICTest::Schema::Tag->add_columns( data_type => 'integer', }, 'tag' => { - data_type => 'varchar' + data_type => 'varchar', + size => 100, }, ); DBICTest::Schema::Tag->set_primary_key('tagid'); diff --git a/t/lib/DBICTest/Schema/Track.pm b/t/lib/DBICTest/Schema/Track.pm index d20c908..9bbefff 100644 --- a/t/lib/DBICTest/Schema/Track.pm +++ b/t/lib/DBICTest/Schema/Track.pm @@ -18,6 +18,7 @@ DBICTest::Schema::Track->add_columns( }, 'title' => { data_type => 'varchar', + size => 100, }, ); DBICTest::Schema::Track->set_primary_key('trackid'); diff --git a/t/lib/DBICTest/Schema/TreeLike.pm b/t/lib/DBICTest/Schema/TreeLike.pm index 49abb69..9fde9f3 100644 --- a/t/lib/DBICTest/Schema/TreeLike.pm +++ b/t/lib/DBICTest/Schema/TreeLike.pm @@ -9,7 +9,9 @@ __PACKAGE__->table('treelike'); __PACKAGE__->add_columns( 'id' => { data_type => 'integer', is_auto_increment => 1 }, 'parent' => { data_type => 'integer' }, - 'name' => { data_type => 'varchar' }, + 'name' => { data_type => 'varchar', + size => 100, + }, ); __PACKAGE__->set_primary_key(qw/id/); __PACKAGE__->belongs_to('parent', 'TreeLike',