From: ivan Date: Thu, 2 Nov 2006 07:40:56 +0000 (+0000) Subject: Fixes for dropping nullability on old Pg (<= 7.2) X-Git-Tag: DBIx_DBSchema_0_32~3 X-Git-Url: http://git.freeside.biz/gitweb/?p=DBIx-DBSchema.git;a=commitdiff_plain;h=ff35fb1ceeb8e908df42c94cd0b78f0e9ddc93c9 Fixes for dropping nullability on old Pg (<= 7.2) --- diff --git a/DBSchema/Column.pm b/DBSchema/Column.pm index 14351ec..f981ede 100644 --- 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 ) { - 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...