aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/update-schema8
1 files changed, 8 insertions, 0 deletions
diff --git a/bin/update-schema b/bin/update-schema
index dff2255d5..d40df1689 100755
--- a/bin/update-schema
+++ b/bin/update-schema
@@ -195,6 +195,7 @@ else {
# By querying the database schema, we can see where we're currently at
# (assuming schema change files are never half-applied, which should be the case)
sub get_db_version {
+ return '0036' if constraint_contains('problem_cobrand_check', 'a-z0-9_');
return '0035' if column_exists('problem', 'bodies_missing');
return '0034' if ! function_exists('ms_current_timestamp');
return '0033' if ! function_exists('angle_between');
@@ -257,6 +258,13 @@ sub constraint_exists {
return dbh()->selectrow_array('select count(*) from pg_constraint where conname = ?', {}, $constraint);
}
+# Returns true if a check constraint contains a certain string
+sub constraint_contains {
+ my ( $constraint, $check ) = @_;
+ my ($consrc) = dbh()->selectrow_array('select consrc from pg_constraint where conname = ?', {}, $constraint);
+ return $consrc =~ /$check/;
+}
+
# Returns true if a function exists
sub function_exists {
my $fn = shift;