X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/c7f211c743829e058b9e8ddf8e30428c934a433b..76273adac85df187367d7f2c60ae5f018915a969:/SL/DBUpgrade2/Base.pm diff --git a/SL/DBUpgrade2/Base.pm b/SL/DBUpgrade2/Base.pm index 9978b207e..4a817c423 100644 --- a/SL/DBUpgrade2/Base.pm +++ b/SL/DBUpgrade2/Base.pm @@ -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