| 1 |
<?php |
| 2 |
|
| 3 |
namespace StoreEngine\Database; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; |
| 7 |
} |
| 8 |
|
| 9 |
class CreateApiKeys { |
| 10 |
|
| 11 |
public static function up( $prefix, $charset_collate ) { |
| 12 |
$table_name = $prefix . 'storeengine_api_keys'; |
| 13 |
$sql = "CREATE TABLE IF NOT EXISTS {$table_name} ( |
| 14 |
`key_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 15 |
`user_id` bigint(20) unsigned NOT NULL, |
| 16 |
`description` varchar(200) DEFAULT NULL, |
| 17 |
`permissions` varchar(10) NOT NULL, |
| 18 |
`consumer_key` char(64) NOT NULL, |
| 19 |
`consumer_secret` char(43) NOT NULL, |
| 20 |
`nonces` longtext, |
| 21 |
`truncated_key` char(7) NOT NULL, |
| 22 |
`last_access` TIMESTAMP DEFAULT NULL, |
| 23 |
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, |
| 24 |
PRIMARY KEY (`key_id`), |
| 25 |
KEY `consumer_key` (`consumer_key`), |
| 26 |
KEY `consumer_secret` (`consumer_secret`) |
| 27 |
) $charset_collate;"; |
| 28 |
|
| 29 |
dbDelta( $sql ); |
| 30 |
} |
| 31 |
} |
| 32 |
|