projects
/
DBIx-DBSchema.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
7d32dbb
)
Fixes for dropping nullability on old Pg (<= 7.2)
author
ivan
<ivan>
Thu, 2 Nov 2006 07:40:56 +0000
(07:40 +0000)
committer
ivan
<ivan>
Thu, 2 Nov 2006 07:40:56 +0000
(07:40 +0000)
DBSchema/Column.pm
patch
|
blob
|
history
diff --git
a/DBSchema/Column.pm
b/DBSchema/Column.pm
index
14351ec
..
f981ede
100644
(file)
--- a/
DBSchema/Column.pm
+++ b/
DBSchema/Column.pm
@@
-456,7
+456,16
@@
sub sql_alter_column {
# this one could be more complicated, need to set a DEFAULT value and update
# the table first...
if ( $self->null && ! $new->null ) {
# this one could be more complicated, need to set a DEFAULT value and update
# the table first...
if ( $self->null && ! $new->null ) {
- push @r, "ALTER TABLE $table ALTER COLUMN $name SET NOT NULL";
+
+ if ( $driver eq 'Pg' && $dbh->{'pg_server_version'} < 70300 ) {
+ push @r, "UPDATE pg_attribute SET attnotnull = TRUE
+ WHERE attname = '$name'
+ AND attrelid = ( SELECT oid FROM pg_class
+ WHERE relname = '$table'
+ )";
+ } else {
+ push @r, "ALTER TABLE $table ALTER COLUMN $name SET NOT NULL";
+ }
}
# change other stuff...
}
# change other stuff...