From: ivan Date: Sat, 27 Oct 2007 12:04:55 +0000 (+0000) Subject: Update Table.pm, add local_options X-Git-Tag: DBIx_DBSchema_0_35~2 X-Git-Url: http://git.freeside.biz/gitweb/?p=DBIx-DBSchema.git;a=commitdiff_plain;h=7a15dfc7862428fb4c543698bf981231ca8f2983 Update Table.pm, add local_options --- diff --git a/Changes b/Changes index 39a69ec..f0c68ef 100644 --- a/Changes +++ b/Changes @@ -5,6 +5,7 @@ Revision history for Perl extension DBIx::DBSchema. - Update mysql driver to handle BIGSERIAL columns - Update Column.pm, move all mysql and Pg-specific code to DBD driver callbacks + - Update Table.pm, add local_options 0.34 Sun Aug 19 10:08:51 PDT 2007 - More work on update schema from Slaven Rezic , diff --git a/DBSchema/Table.pm b/DBSchema/Table.pm index 16ba3a0..6463ee0 100644 --- a/DBSchema/Table.pm +++ b/DBSchema/Table.pm @@ -10,7 +10,7 @@ use DBIx::DBSchema::Index; use DBIx::DBSchema::ColGroup::Unique; use DBIx::DBSchema::ColGroup::Index; -$VERSION = '0.05'; +$VERSION = '0.06'; $DEBUG = 0; =head1 NAME @@ -87,10 +87,11 @@ Creates a new DBIx::DBSchema::Table object. The preferred usage is to pass a hash reference of named parameters. { - name => TABLE_NAME, - primary_key => PRIMARY_KEY, - columns => COLUMNS, - indices => INDICES, + name => TABLE_NAME, + primary_key => PRIMARY_KEY, + columns => COLUMNS, + indices => INDICES, + local_options => OPTIONS, #deprecated# unique => UNIQUE, #deprecated# index => INDEX, } @@ -100,6 +101,8 @@ empty). COLUMNS is a reference to an array of DBIx::DBSchema::Column objects (see L). INDICES is a reference to an array of DBIx::DBSchema::Index objects (see L), or a hash reference of index names (keys) and DBIx::DBSchema::Index objects (values). +OPTIONS is a scalar of database-specific table options, such as "WITHOUT OIDS" +for Pg or "TYPE=InnoDB" for mysql. Deprecated options: @@ -346,6 +349,21 @@ sub name { } } +=item local_options [ OPTIONS ] + +Returns or sets the database-specific table options string. + +=cut + +sub local_options { + my($self,$value)=@_; + if ( defined($value) ) { + $self->{local_options} = $value; + } else { + $self->{local_options}; + } +} + =item primary_key [ PRIMARY_KEY ] Returns or sets the primary key. @@ -531,7 +549,8 @@ sub sql_create_table { my $indexnum = 1; my @r = ( - "CREATE TABLE ". $self->name. " (\n ". join(",\n ", @columns). "\n)\n" + "CREATE TABLE ". $self->name. " (\n ". join(",\n ", @columns). "\n)\n". + $self->local_options ); if ( $self->_unique ) {