diff options
author | Matthew Somerville <matthew@mysociety.org> | 2015-05-20 10:25:16 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2015-09-29 16:46:53 +0100 |
commit | 361990d4409ccda79e9f0cf166a505eefeac4495 (patch) | |
tree | 6fea825e1ce4e43b314d5b8b83c73d4c052116bd /bin | |
parent | 1dd68c2f6fed08b90fdaea8efd8c6bcf0399b8d8 (diff) |
Allow underscore in cobrand name/data in database.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/update-schema | 8 |
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; |