aboutsummaryrefslogtreecommitdiffstats
path: root/bin/update-schema
diff options
context:
space:
mode:
authorHakim Cassimally <hakim@mysociety.org>2013-12-09 17:05:02 +0000
committerHakim Cassimally <hakim@mysociety.org>2013-12-09 17:05:02 +0000
commitbfaa47a733f378a2cd0d0cb0e838e6234aa9e1aa (patch)
tree4357ae15d02ed41fdbf77ffbedb021f1b23b9374 /bin/update-schema
parentc502dee1bc70a1306bfd7fdc84cbeef3c6a96c49 (diff)
parent69ceefba6185086fd86a4a8af6ad10eb93d4c7f0 (diff)
Merge branch 'zurich-problem-status-stats'
Diffstat (limited to 'bin/update-schema')
-rwxr-xr-xbin/update-schema8
1 files changed, 8 insertions, 0 deletions
diff --git a/bin/update-schema b/bin/update-schema
index 92868e1b6..ef33b82a7 100755
--- a/bin/update-schema
+++ b/bin/update-schema
@@ -85,6 +85,7 @@ print "Nothing to do\n" if $nothing;
# 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 '0030' if ! constraint_exists('admin_log_action_check');
return '0029' if column_exists('body', 'deleted');
return '0028' if table_exists('body');
return '0027' if column_exists('problem', 'subcategory');
@@ -134,3 +135,10 @@ sub column_like {
my ( $table, $where, $column, $contents ) = @_;
return dbh()->selectrow_array("select count(*) from $table WHERE $where AND $column LIKE ?", {}, "%$contents%");
}
+
+# Returns true if a check constraint on a table exists
+sub constraint_exists {
+ my ( $constraint ) = @_;
+ return dbh()->selectrow_array('select count(*) from pg_constraint where conname = ?', {}, $constraint);
+}
+