+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(<<SQL, undef, $params{type}, $params{schema}, $params{table});
+ SELECT constraint_name
+ FROM information_schema.table_constraints
+ WHERE (constraint_type = ?)
+ AND (table_schema = ?)
+ AND (table_name = ?)
+SQL
+
+ $self->db_query(qq|ALTER TABLE $params{schema}."$params{table}" DROP CONSTRAINT "${_}"|) for map { $_->[0] } @{ $constraints };
+}
+
+sub convert_column_to_html {
+ my ($self, $table, $column) = @_;
+
+ my $sth = $self->dbh->prepare(qq|UPDATE $table SET $column = ? WHERE id = ?|) || $self->dberror;
+
+ foreach my $row (selectall_hashref_query($::form, $self->dbh, qq|SELECT id, $column FROM $table WHERE $column IS NOT NULL|)) {
+ next if !$row->{$column} || (($row->{$column} =~ m{^<[a-z]+>}) && ($row->{$column} =~ m{</[a-z]+>$}));
+
+ my $new_content = "" . $::request->presenter->escape($row->{$column});
+ $new_content =~ s{\r}{}g;
+ $new_content =~ s{\n\n+}{</p><p>}g;
+ $new_content =~ s{\n}{<br />}g;
+ $new_content = "<p>${new_content}</p>" if $new_content;
+
+ $sth->execute($new_content, $row->{id}) if $new_content ne $row->{$column};
+ }
+
+ $sth->finish;
+}
+