| 1 |
<?php |
| 2 |
namespace StoreEngine\Database; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
class CreateEmailLog { |
| 9 |
public static function up( $prefix, $charset_collate ) { |
| 10 |
$table_name = $prefix . 'storeengine_email_log'; |
| 11 |
$sql = "CREATE TABLE IF NOT EXISTS {$table_name} ( |
| 12 |
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 13 |
`sent_at_gmt` datetime NOT NULL, |
| 14 |
`email_type` varchar(100) NOT NULL, |
| 15 |
`recipient` varchar(320) NOT NULL, |
| 16 |
`subject` varchar(500) NOT NULL, |
| 17 |
`status` varchar(20) NOT NULL, |
| 18 |
`customer_id` bigint(20) unsigned NULL DEFAULT NULL, |
| 19 |
`order_id` bigint(20) unsigned NULL DEFAULT NULL, |
| 20 |
`related_entity_type` varchar(50) NULL DEFAULT NULL, |
| 21 |
`related_entity_id` bigint(20) unsigned NULL DEFAULT NULL, |
| 22 |
`error_message` text NULL DEFAULT NULL, |
| 23 |
`payload` longtext NULL DEFAULT NULL, |
| 24 |
PRIMARY KEY (`id`), |
| 25 |
KEY `sent_at_gmt` (`sent_at_gmt`), |
| 26 |
KEY `email_type` (`email_type`), |
| 27 |
KEY `status` (`status`), |
| 28 |
KEY `recipient` (`recipient`(191)), |
| 29 |
KEY `customer_id` (`customer_id`), |
| 30 |
KEY `order_id` (`order_id`), |
| 31 |
KEY `related` (`related_entity_type`, `related_entity_id`) |
| 32 |
) $charset_collate;"; |
| 33 |
|
| 34 |
dbDelta( $sql ); |
| 35 |
} |
| 36 |
} |
| 37 |
|