PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.15.4
GiveWP – Donation Plugin and Fundraising Platform v4.15.4
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 2.31.0 2.31.1 All 253 releases
give / src / EventTickets / Migrations / CreateEventTicketTypesTable.php
CreateEventTicketTypesTable.php
61 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\EventTickets\Migrations;
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 3.6.0
12 */
13 class CreateEventTicketTypesTable extends Migration {
14 /**
15 * @inheritdoc
16 */
17 public static function id() {
18 return 'give-events-create-events-ticket-types-table';
19 }
20
21 public static function title() {
22 return 'Create give_event_ticket_types table';
23 }
24
25 /**
26 * @inheritdoc
27 */
28 public static function timestamp() {
29 return strtotime( '2022-01-29 01:00:00' );
30 }
31
32 /**
33 * @inheritdoc
34 * @throws DatabaseMigrationException
35 */
36 public function run() {
37 global $wpdb;
38
39 $table = $wpdb->give_event_ticket_types;
40 $charset = DB::get_charset_collate();
41
42 $sql = "CREATE TABLE $table (
43 id INT UNSIGNED NOT NULL AUTO_INCREMENT,
44 event_id INT UNSIGNED NOT NULL,
45 title TEXT NULL,
46 description TEXT NULL,
47 price INT UNSIGNED NOT NULL,
48 capacity INT UNSIGNED NULL,
49 created_at DATETIME NOT NULL,
50 updated_at DATETIME NOT NULL,
51 PRIMARY KEY (id)
52 ) $charset";
53
54 try {
55 DB::delta( $sql );
56 } catch ( DatabaseQueryException $exception ) {
57 throw new DatabaseMigrationException( "An error occurred while creating the $table table", 0, $exception );
58 }
59 }
60 };
61