Michael P. Soulier wrote:
> my $sql =<<EOF;
> ALTER TABLE instances ADD COLUMN udp_icpside_address_override inet
> DEFAULT NULL;
> ALTER TABLE instances ADD COLUMN udp_setside_address_override inet
> DEFAULT NULL;
> UPDATE instances SET udp_icpside_address_override =
> $udp_icpside_address_override;
> UPDATE instances SET udp_setside_address_override =
> $udp_setside_address_override;
> ALTER TABLE instances DROP COLUMN public_ip;
> ALTER TABLE instances DROP COLUMN public_ip_override;
> ALTER TABLE instances DROP COLUMN lan_mode;
Ok, using the default to set the value on the new column seems to avoid
this...
my $sql =<<EOF;
ALTER TABLE instances DROP COLUMN public_ip;
ALTER TABLE instances DROP COLUMN public_ip_override;
ALTER TABLE instances DROP COLUMN lan_mode;
ALTER TABLE instances ADD COLUMN udp_icpside_address_override inet
DEFAULT $udp_icpside_address_override;
ALTER TABLE instances ADD COLUMN udp_setside_address_override inet
DEFAULT $udp_setside_address_override;
ALTER TABLE instances ALTER COLUMN udp_icpside_address_override SET
DEFAULT NULL;
ALTER TABLE instances ALTER COLUMN udp_setside_address_override SET
DEFAULT NULL;
EOF
$dbh->do($sql);
But I don't understand why this was required. What's wrong with adding a
column and copying data into it in a transaction?
Mike