-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: register migration for setting up the campaign type for exis…
…ting campaigns (p2p)
- Loading branch information
Showing
3 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Give\Campaigns\Migrations\Tables; | ||
|
||
use Give\Framework\Database\DB; | ||
use Give\Framework\Database\Exceptions\DatabaseQueryException; | ||
use Give\Framework\Migrations\Contracts\Migration; | ||
use Give\Framework\Migrations\Exceptions\DatabaseMigrationException; | ||
|
||
/** | ||
* @unreleased | ||
* | ||
* Modifies the give_campaigns table by adding the campaign_type column | ||
*/ | ||
class AddCampaignTypeColumn extends Migration | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public static function id(): string | ||
{ | ||
return 'give-campaigns-add-campaign-type-column'; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public static function title(): string | ||
{ | ||
return 'Add campaign_type column to give_campaigns table'; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public static function timestamp(): string | ||
{ | ||
return strtotime('2024-08-26 00:00:01'); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
* @throws DatabaseMigrationException | ||
*/ | ||
public function run() | ||
{ | ||
global $wpdb; | ||
|
||
try { | ||
DB::query("ALTER TABLE {$wpdb->give_campaigns} ADD COLUMN `campaign_type` VARCHAR(12) NOT NULL DEFAULT ''"); | ||
} catch (DatabaseQueryException $exception) { | ||
throw new DatabaseMigrationException("An error occurred while updating the {$wpdb->give_campaigns} table", 0, $exception); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters