use DBIx::DBSchema::ColGroup::Unique;
use DBIx::DBSchema::ColGroup::Index;
-$VERSION = '0.05';
+$VERSION = '0.06';
$DEBUG = 0;
=head1 NAME
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,
}
(see L<DBIx::DBSchema::Column>). INDICES is a reference to an array of
DBIx::DBSchema::Index objects (see L<DBIx::DBSchema::Index>), 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:
}
}
+=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.
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 ) {
my $tempnum = 1;
###
- # columns
+ # columns (add/alter)
###
foreach my $column ( $new->columns ) {
warn "creating new index $table.$new\n" if $DEBUG > 1;
push @r, $new_indices{$new}->sql_create_index($table);
}
+
+ ###
+ # columns (drop)
+ ###
+
+ foreach my $column ( grep !$new->column($_), $self->columns ) {
+
+ warn "column $table.$column should be dropped.\n" if $DEBUG;
+
+ push @r, $self->column($column)->sql_drop_column( $dbh );
+
+ }
###
# return the statements