AddMissingDonorIdToDonationComments.php
1 year ago
MoveDonationCommentToDonationMetaTable.php
3 years ago
RecalculateExchangeRate.php
1 year ago
SetAutomaticFormattingOption.php
3 years ago
UnserializeTitlePrefix.php
1 year ago
AddMissingDonorIdToDonationComments.php
64 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Donations\Migrations; |
| 4 | |
| 5 | use Give\Framework\Database\DB; |
| 6 | use Give\Framework\Migrations\Contracts\Migration; |
| 7 | |
| 8 | /** |
| 9 | * Class AddMissingDonorIdToDonationComment |
| 10 | * |
| 11 | * @since 2.24.0 |
| 12 | */ |
| 13 | class AddMissingDonorIdToDonationComments extends Migration |
| 14 | { |
| 15 | /** |
| 16 | * @inheritdoc |
| 17 | */ |
| 18 | public function run() |
| 19 | { |
| 20 | $commentMetaTable = DB::prefix('give_commentmeta'); |
| 21 | $commentTable = DB::prefix('give_comments'); |
| 22 | $donationMetaTable = DB::prefix('give_donationmeta'); |
| 23 | |
| 24 | DB::query( |
| 25 | " |
| 26 | UPDATE |
| 27 | $commentMetaTable AS cm |
| 28 | INNER JOIN $commentTable AS c ON c.comment_ID = cm.give_comment_id |
| 29 | INNER JOIN $donationMetaTable AS dm ON c.comment_parent = dm.donation_id |
| 30 | SET |
| 31 | cm.meta_value = dm.meta_value |
| 32 | WHERE |
| 33 | dm.meta_key = '_give_payment_donor_id' |
| 34 | AND cm.meta_key = '_give_donor_id' |
| 35 | AND(cm.meta_value IS NULL OR cm.meta_value = '') |
| 36 | " |
| 37 | ); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * @inheritdoc |
| 42 | */ |
| 43 | public static function id() |
| 44 | { |
| 45 | return 'add-missing-donor-id-in-donation-comments'; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * @inheritdoc |
| 50 | */ |
| 51 | public static function title() |
| 52 | { |
| 53 | return 'Add missing donor id in donation comments'; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * @inheritdoc |
| 58 | */ |
| 59 | public static function timestamp() |
| 60 | { |
| 61 | return strtotime('2022-12-19'); |
| 62 | } |
| 63 | } |
| 64 |