AddCampaignId.php
8 months ago
AddCampaignIdColumn.php
8 months ago
AddPaymentModeToSubscriptionTable.php
3 years ago
BackfillMissingCampaignIdForDonations.php
1 year ago
CreateSubscriptionTables.php
4 years ago
UpdateProductID.php
8 months ago
AddCampaignIdColumn.php
52 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Subscriptions\Migrations; |
| 4 | |
| 5 | use Give\Framework\Database\DB; |
| 6 | use Give\Framework\Migrations\Contracts\Migration; |
| 7 | use Give\Framework\Migrations\Exceptions\DatabaseMigrationException; |
| 8 | |
| 9 | /** |
| 10 | * @since 4.11.0 |
| 11 | */ |
| 12 | class AddCampaignIdColumn extends Migration |
| 13 | { |
| 14 | /** |
| 15 | * @inheritDoc |
| 16 | */ |
| 17 | public static function id(): string |
| 18 | { |
| 19 | return 'add_campaign_id_to_subscriptions_table'; |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * @inheritDoc |
| 24 | */ |
| 25 | public static function title(): string |
| 26 | { |
| 27 | return 'Add Campaign ID to subscriptions table'; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * @inheritdoc |
| 32 | */ |
| 33 | public static function timestamp(): string |
| 34 | { |
| 35 | return strtotime('2025-10-01 00:00:00'); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * @inheritDoc |
| 40 | * @throws DatabaseMigrationException |
| 41 | */ |
| 42 | public function run() |
| 43 | { |
| 44 | $table = DB::prefix('give_subscriptions'); |
| 45 | $columnAdded = maybe_add_column($table, 'campaign_id', "ALTER TABLE $table ADD COLUMN campaign_id INT UNSIGNED NULL"); |
| 46 | |
| 47 | if ( ! $columnAdded) { |
| 48 | throw new DatabaseMigrationException("An error occurred while updating the $table table"); |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 |