diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/update-schema | 8 | ||||
-rwxr-xr-x | bin/zurich-overdue-alert | 4 |
2 files changed, 10 insertions, 2 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); +} + diff --git a/bin/zurich-overdue-alert b/bin/zurich-overdue-alert index 4a507c481..500c6b016 100755 --- a/bin/zurich-overdue-alert +++ b/bin/zurich-overdue-alert @@ -23,9 +23,9 @@ exit if FixMyStreet::Cobrand::Zurich::is_public_holiday($now) or FixMyStreet::Co my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker('zurich')->new(); my %bodies = map { $_->id => $_ } FixMyStreet::App->model("DB::Body")->all; -loop_through( 'alert-moderation-overdue.txt', 0, 1, [ 'unconfirmed', 'confirmed' ] ); +loop_through( 'alert-moderation-overdue.txt', 0, 1, [ 'unconfirmed' ] ); loop_through( 'alert-overdue.txt', 1, 6, 'in progress' ); -loop_through( 'alert-overdue.txt', 0, 6, 'planned' ); +loop_through( 'alert-overdue.txt', 0, 6, ['confirmed', 'planned'] ); sub loop_through { my ( $template, $include_parent, $days, $states ) = @_; |