Skip to content

Commit

Permalink
Merge branch '5.0/pg-attachments-index-primary-key' into 5.0-trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrandtbuffalo committed Apr 10, 2024
2 parents 064acbd + d8ffad7 commit f71b4ab
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions etc/upgrade/5.0.6/indexes
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use strict;
use warnings;

if ( RT->Config->Get('DatabaseType') eq 'Pg' ) {
my $fulltext = RT->Config->Get('FullTextSearch');
if ( my $table = $fulltext->{Table} ) {
my $handle = RT->DatabaseHandle;
if ( my $indexes = { $handle->Indexes }->{ lc $table } ) {
if ( !grep { $_ eq lc "${table}_pkey" } @$indexes ) {
my $res = $handle->dbh->do("ALTER TABLE IF EXISTS $table ADD PRIMARY KEY(id)");
if ( !$res ) {
RT->Logger->error("Could not add PRIMARY KEY to table $table");
}
}
}
}
}

1;
3 changes: 2 additions & 1 deletion sbin/rt-setup-fulltext-index.in
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ elsif ( $DB{'type'} eq 'Pg' ) {
push @schema, split /;\n+/, <<SCHEMA;
CREATE TABLE $table (
id BIGSERIAL,
$column tsvector
$column tsvector,
PRIMARY KEY (id)
);
GRANT SELECT, INSERT, UPDATE, DELETE ON $table TO "$DB{user}"
SCHEMA
Expand Down

0 comments on commit f71b4ab

Please sign in to comment.