aboutsummaryrefslogtreecommitdiffstats
path: root/bin/update-schema
diff options
context:
space:
mode:
Diffstat (limited to 'bin/update-schema')
-rwxr-xr-xbin/update-schema7
1 files changed, 6 insertions, 1 deletions
diff --git a/bin/update-schema b/bin/update-schema
index 8f31085c9..1cfb59f52 100755
--- a/bin/update-schema
+++ b/bin/update-schema
@@ -78,6 +78,8 @@ print "= Dry run =\n" unless $commit;
my $upgrade = !$downgrade;
+my $db_fts_config = FixMyStreet->config('DB_FULL_TEXT_SEARCH_CONFIG') || 'english';
+
sub get_statements {
my $path = shift;
open(my $FP, '<', $path) or die $!;
@@ -91,6 +93,7 @@ sub get_statements {
$in_function = 1 if /create (or replace )?function/i;
$in_function = 0 if /language (sql|'plpgsql')/i;
if ($s =~ /;/ && !$in_function) {
+ $s =~ s/DB_FULL_TEXT_SEARCH_CONFIG/$db_fts_config/g;
push @statements, $s;
$s = '';
}
@@ -212,6 +215,8 @@ else {
# (assuming schema change files are never half-applied, which should be the case)
sub get_db_version {
return 'EMPTY' if ! table_exists('problem');
+ return '0074' if index_exists('users_fulltext_idx');
+ return '0073' if index_exists('problem_fulltext_idx');
return '0072' if constraint_contains('contacts_state_check', 'staff');
return '0071' if table_exists('manifest_theme');
return '0070' if column_like('alert_type', "ref='new_problems'", 'head_title', '{{SITE_NAME}}');
@@ -319,7 +324,7 @@ sub constraint_exists {
# Returns true if a check constraint contains a certain string
sub constraint_contains {
my ( $constraint, $check ) = @_;
- my ($consrc) = $db->dbh->selectrow_array('select consrc from pg_constraint where conname = ?', {}, $constraint);
+ my ($consrc) = $db->dbh->selectrow_array('select pg_get_expr(conbin, conrelid) from pg_constraint where conname = ?', {}, $constraint);
return unless $consrc;
return $consrc =~ /$check/;
}