|
Line 0
Link Here
|
|
|
1 |
use Modern::Perl; |
| 2 |
|
| 3 |
return { |
| 4 |
bug_number => "30300", |
| 5 |
description => "Add Patron expiry to messaging preference", |
| 6 |
up => sub { |
| 7 |
my ($args) = @_; |
| 8 |
my ( $dbh, $out ) = @$args{qw(dbh out)}; |
| 9 |
my $attribute = $dbh->do( |
| 10 |
q{ |
| 11 |
SELECT message_attribute_id |
| 12 |
FROM message_attributes |
| 13 |
WHERE message_name = "Patron_Expiry" |
| 14 |
} |
| 15 |
); |
| 16 |
unless ( $attribute == 1 ) { |
| 17 |
$dbh->do( |
| 18 |
q{ |
| 19 |
INSERT IGNORE INTO `message_attributes` |
| 20 |
(message_name, `takes_days`) |
| 21 |
VALUES ('Patron_Expiry', 0) |
| 22 |
} |
| 23 |
); |
| 24 |
say $out "Message attribute added"; |
| 25 |
my $query = q{ |
| 26 |
SELECT message_attribute_id |
| 27 |
FROM message_attributes |
| 28 |
WHERE message_name = "Patron_Expiry" |
| 29 |
}; |
| 30 |
my $sth = $dbh->prepare($query); |
| 31 |
$sth->execute(); |
| 32 |
my $results = $sth->fetchrow_hashref; |
| 33 |
my $message_attribute_id = $results->{message_attribute_id}; |
| 34 |
|
| 35 |
$dbh->do( |
| 36 |
q{ |
| 37 |
INSERT IGNORE INTO `message_transports` |
| 38 |
(`message_attribute_id`, `message_transport_type`, `is_digest`, `letter_module`, `letter_code`) |
| 39 |
VALUES (?, 'email', 0, 'circulation', 'MEMBERSHIP_EXPIRY'), |
| 40 |
(?, 'sms', 0, 'circulation', 'MEMBERSHIP_EXPIRY'), |
| 41 |
(?, 'phone', 0, 'circulation', 'MEMBERSHIP_EXPIRY'), |
| 42 |
( ?, 'itiva', 0, 'circulation', 'MEMBERSHIP_EXPIRY' ) |
| 43 |
}, {}, $message_attribute_id, $message_attribute_id, $message_attribute_id, $message_attribute_id |
| 44 |
|
| 45 |
); |
| 46 |
say $out "MEMBERSHIP_EXPIRY added to message_transports"; |
| 47 |
} else { |
| 48 |
say $out "Patron_Expiry message attribute exists, skipping update"; |
| 49 |
} |
| 50 |
}, |
| 51 |
} |