X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/aa1a40e9141fd718e85e6e92f78adf301f53cf1f..64b49f6c38c2c5763f21df00c7b4580ff70893be:/SL/DBUpgrade2/Base.pm?ds=inline diff --git a/SL/DBUpgrade2/Base.pm b/SL/DBUpgrade2/Base.pm index 9978b207e..6f0bb829c 100644 --- a/SL/DBUpgrade2/Base.pm +++ b/SL/DBUpgrade2/Base.pm @@ -59,7 +59,7 @@ sub db_errstr { my $error = $handle ? $handle->errstr : $self->dbh->errstr; - return $::locale->is_utf8 ? Encode::decode('utf-8', $error) : $error; + return Encode::decode('utf-8', $error); } sub check_coa { @@ -119,6 +119,24 @@ sub add_print_templates { return 1; } +sub drop_constraints { + my ($self, %params) = @_; + + croak "Missing parameter 'table'" unless $params{table}; + $params{type} ||= 'FOREIGN KEY'; + $params{schema} ||= 'public'; + + my $constraints = $self->dbh->selectall_arrayref(<db_query(qq|ALTER TABLE auth."$params{table}" DROP CONSTRAINT "${_}"|) for map { $_->[0] } @{ $constraints }; +} + 1; __END__ @@ -259,6 +277,21 @@ used. =back +=item C + +Drops all constraints of a type (e.g. foreign keys) on a table. One +parameter is mandatory: C. Optional parameters include: + +=over 2 + +=item * C -- if missing defaults to C + +=item * C -- if missing defaults to C. Must be one of +the values contained in the C +view in the C column. + +=back + =item C Executes a named database upgrade script. This function is not