PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.13.1
GiveWP – Donation Plugin and Fundraising Platform v2.13.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 2.31.0 2.31.1 All 253 releases
give / src / Log / Migrations / CreateNewLogTable.php
CreateNewLogTable.php
67 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Log\Migrations;
4
5 use Give\Framework\Database\DB;
6 use Give\Framework\Migrations\Contracts\Migration;
7 use Give\Framework\Database\Exceptions\DatabaseQueryException;
8 use Give\Framework\Migrations\Exceptions\DatabaseMigrationException;
9
10
11
12 /**
13 * Class CreateNewLogTables
14 * @package Give\Log\Migrations
15 *
16 * @since 2.10.0
17 */
18 class CreateNewLogTable extends Migration {
19 /**
20 * @return string
21 */
22 public static function id() {
23 return 'create_new_log_table';
24 }
25
26 /**
27 * @return string
28 */
29 public static function title() {
30 return esc_html__( 'Create new give_log table', 'give' );
31 }
32
33 /**
34 * @return int
35 */
36 public static function timestamp() {
37 return strtotime( '2021-01-28 12:00' );
38 }
39
40
41 public function run() {
42 global $wpdb;
43
44 $table = "{$wpdb->prefix}give_log";
45 $charset = DB::get_charset_collate();
46
47 $sql = "CREATE TABLE {$table} (
48 id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
49 log_type VARCHAR(16) NOT NULL,
50 data text NOT NULL,
51 category VARCHAR(64) NOT NULL,
52 source VARCHAR(64) NOT NULL,
53 date DATETIME NOT NULL,
54 PRIMARY KEY (id),
55 KEY log_type (log_type),
56 KEY category (category),
57 KEY source (source)
58 ) {$charset}";
59
60 try {
61 DB::delta( $sql );
62 } catch ( DatabaseQueryException $exception ) {
63 throw new DatabaseMigrationException( 'An error occurred while creating the give_log table', 0, $exception );
64 }
65 }
66 }
67