PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / Campaigns / Migrations / Tables / CreateCampaignFormsTable.php

CreateCampaignFormsTable.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/Campaigns/Migrations/Tables/CreateCampaignFormsTable.php

66 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Campaigns\Migrations\Tables;
4
5 use Give\Framework\Database\DB;
6 use Give\Framework\Database\Exceptions\DatabaseQueryException;
7 use Give\Framework\Migrations\Contracts\Migration;
8 use Give\Framework\Migrations\Exceptions\DatabaseMigrationException;
9
10 /**
11 * @since 4.0.0
12 * Creates give_campaign_forms table
13 */
14 class CreateCampaignFormsTable extends Migration
15 {
16 /**
17 * @inheritdoc
18 */
19 public static function id(): string
20 {
21 return 'give-campaigns-create-give-campaign-forms-table';
22 }
23
24 /**
25 * @inheritdoc
26 */
27 public static function title(): string
28 {
29 return 'Create give_campaign_forms table';
30 }
31
32 /**
33 * @inheritdoc
34 */
35 public static function timestamp(): string
36 {
37 return strtotime('2024-08-26 00:00:01');
38 }
39
40 /**
41 * @inheritDoc
42 * @throws DatabaseMigrationException
43 */
44 public function run(): void
45 {
46 global $wpdb;
47
48 $table = $wpdb->give_campaign_forms;
49 $charset = DB::get_charset_collate();
50
51 $sql = "CREATE TABLE $table (
52 campaign_id INT UNSIGNED NOT NULL,
53 form_id INT UNSIGNED NOT NULL,
54 KEY form_id (form_id),
55 KEY campaign_id (campaign_id),
56 PRIMARY KEY (campaign_id, form_id)
57 ) $charset";
58
59 try {
60 DB::delta($sql);
61 } catch (DatabaseQueryException $exception) {
62 throw new DatabaseMigrationException("An error occurred while creating the $table table", 0, $exception);
63 }
64 }
65 }
66