| 1 |
<?php |
| 2 |
/** |
| 3 |
* List tables for the database |
| 4 |
* |
| 5 |
* @version 4 |
| 6 |
* @since 4.1.6.4 |
| 7 |
* @version 1.0.1 |
| 8 |
*/ |
| 9 |
|
| 10 |
$lp_db = LP_Database::getInstance(); |
| 11 |
|
| 12 |
$collate = $lp_db->wpdb->has_cap( 'collation' ) ? $lp_db->wpdb->get_charset_collate() : ''; |
| 13 |
|
| 14 |
// Max DB index length. See wp_get_db_schema(). |
| 15 |
$max_index_length = 191; |
| 16 |
|
| 17 |
return array( |
| 18 |
$lp_db->tb_lp_order_items => " |
| 19 |
CREATE TABLE IF NOT EXISTS {$lp_db->tb_lp_order_items} ( |
| 20 |
order_item_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 21 |
order_item_name longtext NOT NULL, |
| 22 |
order_id bigint(20) unsigned NOT NULL DEFAULT 0, |
| 23 |
item_id bigint(20) unsigned NOT NULL DEFAULT 0, |
| 24 |
item_type varchar(45) NOT NULL DEFAULT '', |
| 25 |
PRIMARY KEY (order_item_id), |
| 26 |
KEY order_id (order_id), |
| 27 |
KEY item_id (item_id), |
| 28 |
KEY item_type (item_type) |
| 29 |
) $collate; |
| 30 |
", |
| 31 |
$lp_db->tb_lp_order_itemmeta => " |
| 32 |
CREATE TABLE IF NOT EXISTS {$lp_db->tb_lp_order_itemmeta} ( |
| 33 |
meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 34 |
learnpress_order_item_id bigint(20) unsigned NOT NULL DEFAULT '0', |
| 35 |
meta_key varchar(255) NOT NULL DEFAULT '', |
| 36 |
meta_value varchar(255) NULL, |
| 37 |
extra_value longtext, |
| 38 |
PRIMARY KEY (meta_id), |
| 39 |
KEY learnpress_order_item_id (learnpress_order_item_id), |
| 40 |
KEY meta_key (meta_key({$max_index_length})), |
| 41 |
KEY meta_value (meta_value({$max_index_length})) |
| 42 |
) $collate; |
| 43 |
", |
| 44 |
$lp_db->tb_lp_question_answers => " |
| 45 |
CREATE TABLE IF NOT EXISTS {$lp_db->tb_lp_question_answers} ( |
| 46 |
question_answer_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 47 |
question_id bigint(20) unsigned NOT NULL DEFAULT '0', |
| 48 |
title text NOT NULL, |
| 49 |
`value` varchar(32) NOT NULL, |
| 50 |
`order` bigint(20) unsigned NOT NULL DEFAULT '1', |
| 51 |
is_true varchar(3), |
| 52 |
PRIMARY KEY (question_answer_id), |
| 53 |
KEY question_id (question_id) |
| 54 |
) $collate; |
| 55 |
", |
| 56 |
$lp_db->tb_lp_question_answermeta => " |
| 57 |
CREATE TABLE IF NOT EXISTS {$lp_db->tb_lp_question_answermeta} ( |
| 58 |
meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 59 |
learnpress_question_answer_id bigint(20) unsigned NOT NULL, |
| 60 |
meta_key varchar(255) NOT NULL DEFAULT '', |
| 61 |
meta_value longtext NULL, |
| 62 |
PRIMARY KEY (meta_id), |
| 63 |
KEY question_answer_meta (learnpress_question_answer_id, meta_key(150)) |
| 64 |
) $collate; |
| 65 |
", |
| 66 |
$lp_db->tb_lp_quiz_questions => " |
| 67 |
CREATE TABLE IF NOT EXISTS {$lp_db->tb_lp_quiz_questions} ( |
| 68 |
quiz_question_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 69 |
quiz_id bigint(20) unsigned NOT NULL DEFAULT '0', |
| 70 |
question_id bigint(20) unsigned NOT NULL DEFAULT '0', |
| 71 |
question_order bigint(20) unsigned NOT NULL DEFAULT '1', |
| 72 |
PRIMARY KEY (quiz_question_id), |
| 73 |
KEY quiz_id (quiz_id), |
| 74 |
KEY question_id (question_id) |
| 75 |
) $collate; |
| 76 |
", |
| 77 |
$lp_db->tb_lp_section_items => " |
| 78 |
CREATE TABLE IF NOT EXISTS {$lp_db->tb_lp_section_items} ( |
| 79 |
section_item_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 80 |
section_id bigint(20) unsigned NOT NULL DEFAULT '0', |
| 81 |
item_id bigint(20) unsigned NOT NULL DEFAULT '0', |
| 82 |
item_order bigint(20) unsigned NOT NULL DEFAULT '0', |
| 83 |
item_type varchar(45), |
| 84 |
PRIMARY KEY (section_item_id), |
| 85 |
KEY section_item (`section_id`, `item_id`) |
| 86 |
) $collate; |
| 87 |
", |
| 88 |
$lp_db->tb_lp_sections => " |
| 89 |
CREATE TABLE IF NOT EXISTS {$lp_db->tb_lp_sections} ( |
| 90 |
section_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 91 |
section_name varchar(255) NOT NULL DEFAULT '', |
| 92 |
section_course_id bigint(20) unsigned NOT NULL DEFAULT '0', |
| 93 |
section_order bigint(10) unsigned NOT NULL DEFAULT '1', |
| 94 |
section_description longtext NOT NULL, |
| 95 |
PRIMARY KEY (section_id), |
| 96 |
KEY section_course_id (section_course_id) |
| 97 |
) $collate; |
| 98 |
", |
| 99 |
$lp_db->tb_lp_sessions => " |
| 100 |
CREATE TABLE IF NOT EXISTS {$lp_db->tb_lp_sessions} ( |
| 101 |
session_id bigint(20) NOT NULL AUTO_INCREMENT, |
| 102 |
session_key char(32) NOT NULL, |
| 103 |
session_value longtext NOT NULL, |
| 104 |
session_expiry bigint(20) NOT NULL, |
| 105 |
UNIQUE KEY session_id (session_id), |
| 106 |
PRIMARY KEY (session_key) |
| 107 |
) $collate; |
| 108 |
", |
| 109 |
$lp_db->tb_lp_user_items => " |
| 110 |
CREATE TABLE IF NOT EXISTS {$lp_db->tb_lp_user_items} ( |
| 111 |
user_item_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 112 |
user_id bigint(20) unsigned NOT NULL DEFAULT '0', |
| 113 |
item_id bigint(20) unsigned NOT NULL DEFAULT '0', |
| 114 |
start_time datetime NULL DEFAULT NULL, |
| 115 |
end_time datetime NULL DEFAULT NULL, |
| 116 |
item_type varchar(45) NOT NULL DEFAULT '', |
| 117 |
status varchar(45) NOT NULL DEFAULT '', |
| 118 |
graduation varchar(20) NULL DEFAULT NULL, |
| 119 |
access_level int(3) NOT NULL DEFAULT 50, |
| 120 |
ref_id bigint(20) unsigned NOT NULL DEFAULT '0', |
| 121 |
ref_type varchar(45) DEFAULT '', |
| 122 |
parent_id bigint(20) unsigned NOT NULL DEFAULT '0', |
| 123 |
PRIMARY KEY (user_item_id), |
| 124 |
KEY parent_id (parent_id), |
| 125 |
KEY user_id (user_id), |
| 126 |
KEY item_id (item_id), |
| 127 |
KEY item_type (item_type), |
| 128 |
KEY ref_id (ref_id), |
| 129 |
KEY ref_type (ref_type), |
| 130 |
KEY status (status) |
| 131 |
) $collate; |
| 132 |
", |
| 133 |
$lp_db->tb_lp_user_itemmeta => " |
| 134 |
CREATE TABLE IF NOT EXISTS {$lp_db->tb_lp_user_itemmeta} ( |
| 135 |
meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 136 |
learnpress_user_item_id bigint(20) unsigned NOT NULL, |
| 137 |
meta_key varchar(255) NOT NULL DEFAULT '', |
| 138 |
meta_value varchar(255) NULL, |
| 139 |
extra_value longtext NULL, |
| 140 |
PRIMARY KEY (meta_id), |
| 141 |
KEY learnpress_user_item_id (learnpress_user_item_id), |
| 142 |
KEY meta_key (meta_key({$max_index_length})), |
| 143 |
KEY meta_value (meta_value({$max_index_length})) |
| 144 |
) $collate; |
| 145 |
", |
| 146 |
$lp_db->tb_lp_user_item_results => " |
| 147 |
CREATE TABLE IF NOT EXISTS {$lp_db->tb_lp_user_item_results} ( |
| 148 |
id bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 149 |
user_item_id bigint(20) unsigned NOT NULL, |
| 150 |
result longtext NULL, |
| 151 |
PRIMARY KEY (id), |
| 152 |
KEY user_item_id (user_item_id) |
| 153 |
) $collate; |
| 154 |
", |
| 155 |
$lp_db->tb_lp_files => " |
| 156 |
CREATE TABLE IF NOT EXISTS {$lp_db->tb_lp_files} ( |
| 157 |
file_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 158 |
file_name varchar(191) NOT NULL DEFAULT '', |
| 159 |
file_type varchar(100) NOT NULL DEFAULT '', |
| 160 |
item_id bigint(20) unsigned NOT NULL DEFAULT '0', |
| 161 |
item_type varchar(100) NOT NULL DEFAULT '', |
| 162 |
method varchar(10) NOT NULL DEFAULT 'upload', |
| 163 |
file_path varchar(255) NOT NULL DEFAULT '', |
| 164 |
orders int(4) NOT NULL DEFAULT '0', |
| 165 |
created_at datetime NULL DEFAULT NULL, |
| 166 |
PRIMARY KEY (file_id), |
| 167 |
KEY file_name (file_name), |
| 168 |
KEY item_id (item_id), |
| 169 |
KEY item_type (item_type) |
| 170 |
) $collate; |
| 171 |
", |
| 172 |
$lp_db->tb_lp_courses => " |
| 173 |
CREATE TABLE IF NOT EXISTS {$lp_db->tb_lp_courses} ( |
| 174 |
ID bigint(20) unsigned NOT NULL, |
| 175 |
json LONGTEXT NOT NULL, |
| 176 |
price_to_sort FLOAT, |
| 177 |
is_sale int(1) default 0, |
| 178 |
post_author bigint unsigned, |
| 179 |
post_date_gmt datetime, |
| 180 |
post_content LONGTEXT, |
| 181 |
post_title text not null, |
| 182 |
post_status varchar(20) default 'publish' not null, |
| 183 |
post_name varchar(200) default '', |
| 184 |
menu_order int default 0, |
| 185 |
lang varchar(20), |
| 186 |
PRIMARY KEY (ID), |
| 187 |
KEY post_title (post_title(191)), |
| 188 |
KEY post_status (post_status), |
| 189 |
KEY post_name (post_name(191)), |
| 190 |
KEY id_status (ID, post_status) |
| 191 |
) $collate; |
| 192 |
", |
| 193 |
$lp_db->tb_lp_mcp_api_keys => " |
| 194 |
CREATE TABLE IF NOT EXISTS {$lp_db->tb_lp_mcp_api_keys} ( |
| 195 |
key_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 196 |
user_id bigint(20) unsigned NOT NULL, |
| 197 |
description varchar(200) NULL DEFAULT NULL, |
| 198 |
permissions varchar(10) NOT NULL DEFAULT 'read', |
| 199 |
consumer_key char(64) NOT NULL, |
| 200 |
consumer_secret char(64) NOT NULL, |
| 201 |
truncated_key char(7) NOT NULL, |
| 202 |
last_access datetime NULL DEFAULT NULL, |
| 203 |
call_count bigint(20) unsigned NOT NULL DEFAULT 0, |
| 204 |
created_at datetime NOT NULL, |
| 205 |
updated_at datetime NULL DEFAULT NULL, |
| 206 |
PRIMARY KEY (key_id), |
| 207 |
UNIQUE KEY consumer_key (consumer_key), |
| 208 |
KEY user_id (user_id) |
| 209 |
) $collate; |
| 210 |
", |
| 211 |
$lp_db->tb_thim_cache => " |
| 212 |
CREATE TABLE IF NOT EXISTS {$lp_db->tb_thim_cache} ( |
| 213 |
key_cache VARCHAR (100) NOT NULL UNIQUE, |
| 214 |
value LONGTEXT NOT NULL, |
| 215 |
expiration VARCHAR (50), |
| 216 |
PRIMARY KEY (key_cache) |
| 217 |
) $collate; |
| 218 |
", |
| 219 |
); |
| 220 |
|