@@ -10,44 +10,44 @@ |
||
10 | 10 | */ |
11 | 11 | class EE_DMS_4_5_0_update_wp_user_for_prices extends EE_Data_Migration_Script_Stage_Table |
12 | 12 | { |
13 | - public function __construct() |
|
14 | - { |
|
15 | - global $wpdb; |
|
16 | - $this->_pretty_name = esc_html__("Prices", "event_espresso"); |
|
17 | - $this->_old_table = $wpdb->prefix . "esp_price"; |
|
18 | - parent::__construct(); |
|
19 | - } |
|
13 | + public function __construct() |
|
14 | + { |
|
15 | + global $wpdb; |
|
16 | + $this->_pretty_name = esc_html__("Prices", "event_espresso"); |
|
17 | + $this->_old_table = $wpdb->prefix . "esp_price"; |
|
18 | + parent::__construct(); |
|
19 | + } |
|
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * @throws EE_Error |
|
24 | - * @throws ReflectionException |
|
25 | - */ |
|
26 | - protected function _migrate_old_row($old_row) |
|
27 | - { |
|
28 | - // foreach ticket row we add the id for the current logged in user. |
|
29 | - global $wpdb; |
|
30 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
31 | - $user_id = $user_id ?: 0; |
|
32 | - $updated = $wpdb->update( |
|
33 | - $this->_old_table, |
|
34 | - ['PRC_wp_user' => $user_id], |
|
35 | - ['PRC_ID' => $old_row['PRC_ID']], |
|
36 | - ['%d'], // PRC_wp_user |
|
37 | - ['%d'] // PRC_ID |
|
38 | - ); |
|
39 | - if (false === $updated) { |
|
40 | - $this->add_error( |
|
41 | - sprintf( |
|
42 | - esc_html__( |
|
43 | - "Error in updating table %s setting PRC_wp_user = %d where PRC_ID = %d", |
|
44 | - 'event_espresso' |
|
45 | - ), |
|
46 | - $this->_old_table, |
|
47 | - $user_id, |
|
48 | - $old_row['PRC_ID'] |
|
49 | - ) |
|
50 | - ); |
|
51 | - } |
|
52 | - } |
|
22 | + /** |
|
23 | + * @throws EE_Error |
|
24 | + * @throws ReflectionException |
|
25 | + */ |
|
26 | + protected function _migrate_old_row($old_row) |
|
27 | + { |
|
28 | + // foreach ticket row we add the id for the current logged in user. |
|
29 | + global $wpdb; |
|
30 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
31 | + $user_id = $user_id ?: 0; |
|
32 | + $updated = $wpdb->update( |
|
33 | + $this->_old_table, |
|
34 | + ['PRC_wp_user' => $user_id], |
|
35 | + ['PRC_ID' => $old_row['PRC_ID']], |
|
36 | + ['%d'], // PRC_wp_user |
|
37 | + ['%d'] // PRC_ID |
|
38 | + ); |
|
39 | + if (false === $updated) { |
|
40 | + $this->add_error( |
|
41 | + sprintf( |
|
42 | + esc_html__( |
|
43 | + "Error in updating table %s setting PRC_wp_user = %d where PRC_ID = %d", |
|
44 | + 'event_espresso' |
|
45 | + ), |
|
46 | + $this->_old_table, |
|
47 | + $user_id, |
|
48 | + $old_row['PRC_ID'] |
|
49 | + ) |
|
50 | + ); |
|
51 | + } |
|
52 | + } |
|
53 | 53 | } |
@@ -14,7 +14,7 @@ |
||
14 | 14 | { |
15 | 15 | global $wpdb; |
16 | 16 | $this->_pretty_name = esc_html__("Prices", "event_espresso"); |
17 | - $this->_old_table = $wpdb->prefix . "esp_price"; |
|
17 | + $this->_old_table = $wpdb->prefix."esp_price"; |
|
18 | 18 | parent::__construct(); |
19 | 19 | } |
20 | 20 |
@@ -10,44 +10,44 @@ |
||
10 | 10 | */ |
11 | 11 | class EE_DMS_4_5_0_update_wp_user_for_price_types extends EE_Data_Migration_Script_Stage_Table |
12 | 12 | { |
13 | - public function __construct() |
|
14 | - { |
|
15 | - global $wpdb; |
|
16 | - $this->_pretty_name = esc_html__("Price Types", "event_espresso"); |
|
17 | - $this->_old_table = $wpdb->prefix . "esp_price_type"; |
|
18 | - parent::__construct(); |
|
19 | - } |
|
13 | + public function __construct() |
|
14 | + { |
|
15 | + global $wpdb; |
|
16 | + $this->_pretty_name = esc_html__("Price Types", "event_espresso"); |
|
17 | + $this->_old_table = $wpdb->prefix . "esp_price_type"; |
|
18 | + parent::__construct(); |
|
19 | + } |
|
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * @throws EE_Error |
|
24 | - * @throws ReflectionException |
|
25 | - */ |
|
26 | - protected function _migrate_old_row($old_row) |
|
27 | - { |
|
28 | - // foreach ticket row we add the id for the current logged in user. |
|
29 | - global $wpdb; |
|
30 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
31 | - $user_id = $user_id ?: 0; |
|
32 | - $updated = $wpdb->update( |
|
33 | - $this->_old_table, |
|
34 | - ['PRT_wp_user' => $user_id], |
|
35 | - ['PRT_ID' => $old_row['PRT_ID']], |
|
36 | - ['%d'], // PRT_wp_user |
|
37 | - ['%d'] // PRT_ID |
|
38 | - ); |
|
39 | - if (false === $updated) { |
|
40 | - $this->add_error( |
|
41 | - sprintf( |
|
42 | - esc_html__( |
|
43 | - "Error in updating table %s setting PRT_wp_user = %d where PRT_ID = %d", |
|
44 | - 'event_espresso' |
|
45 | - ), |
|
46 | - $this->_old_table, |
|
47 | - $user_id, |
|
48 | - $old_row['PRT_ID'] |
|
49 | - ) |
|
50 | - ); |
|
51 | - } |
|
52 | - } |
|
22 | + /** |
|
23 | + * @throws EE_Error |
|
24 | + * @throws ReflectionException |
|
25 | + */ |
|
26 | + protected function _migrate_old_row($old_row) |
|
27 | + { |
|
28 | + // foreach ticket row we add the id for the current logged in user. |
|
29 | + global $wpdb; |
|
30 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
31 | + $user_id = $user_id ?: 0; |
|
32 | + $updated = $wpdb->update( |
|
33 | + $this->_old_table, |
|
34 | + ['PRT_wp_user' => $user_id], |
|
35 | + ['PRT_ID' => $old_row['PRT_ID']], |
|
36 | + ['%d'], // PRT_wp_user |
|
37 | + ['%d'] // PRT_ID |
|
38 | + ); |
|
39 | + if (false === $updated) { |
|
40 | + $this->add_error( |
|
41 | + sprintf( |
|
42 | + esc_html__( |
|
43 | + "Error in updating table %s setting PRT_wp_user = %d where PRT_ID = %d", |
|
44 | + 'event_espresso' |
|
45 | + ), |
|
46 | + $this->_old_table, |
|
47 | + $user_id, |
|
48 | + $old_row['PRT_ID'] |
|
49 | + ) |
|
50 | + ); |
|
51 | + } |
|
52 | + } |
|
53 | 53 | } |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | $stages = glob(EE_CORE . 'data_migration_scripts/4_7_0_stages/*'); |
11 | 11 | $class_to_filepath = []; |
12 | 12 | foreach ($stages as $filepath) { |
13 | - $matches = []; |
|
14 | - preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
15 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
13 | + $matches = []; |
|
14 | + preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
15 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
16 | 16 | } |
17 | 17 | // give addons a chance to autoload their stages too |
18 | 18 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_7_0__autoloaded_stages', $class_to_filepath); |
@@ -34,71 +34,71 @@ discard block |
||
34 | 34 | */ |
35 | 35 | class EE_DMS_Core_4_7_0 extends EE_Data_Migration_Script_Base |
36 | 36 | { |
37 | - /** |
|
38 | - * return EE_DMS_Core_4_7_0 |
|
39 | - * |
|
40 | - * @param TableManager|null $table_manager |
|
41 | - * @param TableAnalysis|null $table_analysis |
|
42 | - */ |
|
43 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
44 | - { |
|
45 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.7.0", "event_espresso"); |
|
46 | - $this->_priority = 10; |
|
47 | - $this->_migration_stages = [ |
|
48 | - new EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price(), |
|
49 | - new EE_DMS_4_7_0_Registration_Payments(), |
|
50 | - ]; |
|
51 | - parent::__construct($table_manager, $table_analysis); |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * @param array $version_array |
|
57 | - * @return bool |
|
58 | - * @throws EE_Error |
|
59 | - */ |
|
60 | - public function can_migrate_from_version($version_array) |
|
61 | - { |
|
62 | - $version_string = $version_array['Core']; |
|
63 | - if ( |
|
64 | - (version_compare($version_string, '4.7.0.decaf', '<') && |
|
65 | - version_compare($version_string, '4.6.0.decaf', '>=')) || |
|
66 | - (version_compare($version_string, '4.7.0.decaf', '>=') && |
|
67 | - ! $this->_get_table_analysis()->tableExists('esp_registration_payment') && |
|
68 | - $this->_get_table_analysis()->tableExists('esp_registration')) |
|
69 | - ) { |
|
70 | - return true; |
|
71 | - } elseif (! $version_string) { |
|
72 | - // no version string provided... this must be pre 4.3 |
|
73 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
74 | - } else { |
|
75 | - return false; |
|
76 | - } |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * @return bool |
|
82 | - * @throws EE_Error |
|
83 | - * @throws ReflectionException |
|
84 | - */ |
|
85 | - public function schema_changes_before_migration() |
|
86 | - { |
|
87 | - // relies on 4.1's EEH_Activation::create_table |
|
88 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
89 | - |
|
90 | - $table_name = 'esp_answer'; |
|
91 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
37 | + /** |
|
38 | + * return EE_DMS_Core_4_7_0 |
|
39 | + * |
|
40 | + * @param TableManager|null $table_manager |
|
41 | + * @param TableAnalysis|null $table_analysis |
|
42 | + */ |
|
43 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
44 | + { |
|
45 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.7.0", "event_espresso"); |
|
46 | + $this->_priority = 10; |
|
47 | + $this->_migration_stages = [ |
|
48 | + new EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price(), |
|
49 | + new EE_DMS_4_7_0_Registration_Payments(), |
|
50 | + ]; |
|
51 | + parent::__construct($table_manager, $table_analysis); |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * @param array $version_array |
|
57 | + * @return bool |
|
58 | + * @throws EE_Error |
|
59 | + */ |
|
60 | + public function can_migrate_from_version($version_array) |
|
61 | + { |
|
62 | + $version_string = $version_array['Core']; |
|
63 | + if ( |
|
64 | + (version_compare($version_string, '4.7.0.decaf', '<') && |
|
65 | + version_compare($version_string, '4.6.0.decaf', '>=')) || |
|
66 | + (version_compare($version_string, '4.7.0.decaf', '>=') && |
|
67 | + ! $this->_get_table_analysis()->tableExists('esp_registration_payment') && |
|
68 | + $this->_get_table_analysis()->tableExists('esp_registration')) |
|
69 | + ) { |
|
70 | + return true; |
|
71 | + } elseif (! $version_string) { |
|
72 | + // no version string provided... this must be pre 4.3 |
|
73 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
74 | + } else { |
|
75 | + return false; |
|
76 | + } |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * @return bool |
|
82 | + * @throws EE_Error |
|
83 | + * @throws ReflectionException |
|
84 | + */ |
|
85 | + public function schema_changes_before_migration() |
|
86 | + { |
|
87 | + // relies on 4.1's EEH_Activation::create_table |
|
88 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
89 | + |
|
90 | + $table_name = 'esp_answer'; |
|
91 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
92 | 92 | REG_ID int(10) unsigned NOT NULL, |
93 | 93 | QST_ID int(10) unsigned NOT NULL, |
94 | 94 | ANS_value text NOT NULL, |
95 | 95 | PRIMARY KEY (ANS_ID), |
96 | 96 | KEY REG_ID (REG_ID), |
97 | 97 | KEY QST_ID (QST_ID)"; |
98 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
98 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
99 | 99 | |
100 | - $table_name = 'esp_attendee_meta'; |
|
101 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
100 | + $table_name = 'esp_attendee_meta'; |
|
101 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
102 | 102 | ATT_ID bigint(20) unsigned NOT NULL, |
103 | 103 | ATT_fname varchar(45) NOT NULL, |
104 | 104 | ATT_lname varchar(45) NOT NULL, |
@@ -115,10 +115,10 @@ discard block |
||
115 | 115 | KEY ATT_email (ATT_email(191)), |
116 | 116 | KEY ATT_lname (ATT_lname), |
117 | 117 | KEY ATT_fname (ATT_fname)"; |
118 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
118 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
119 | 119 | |
120 | - $table_name = 'esp_country'; |
|
121 | - $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
120 | + $table_name = 'esp_country'; |
|
121 | + $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
122 | 122 | CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL, |
123 | 123 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
124 | 124 | CNT_name varchar(45) COLLATE utf8_bin NOT NULL, |
@@ -134,20 +134,20 @@ discard block |
||
134 | 134 | CNT_is_EU tinyint(1) DEFAULT '0', |
135 | 135 | CNT_active tinyint(1) DEFAULT '0', |
136 | 136 | PRIMARY KEY (CNT_ISO)"; |
137 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
137 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
138 | 138 | |
139 | - $table_name = 'esp_currency'; |
|
140 | - $sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL, |
|
139 | + $table_name = 'esp_currency'; |
|
140 | + $sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL, |
|
141 | 141 | CUR_single varchar(45) COLLATE utf8_bin DEFAULT 'dollar', |
142 | 142 | CUR_plural varchar(45) COLLATE utf8_bin DEFAULT 'dollars', |
143 | 143 | CUR_sign varchar(45) COLLATE utf8_bin DEFAULT '$', |
144 | 144 | CUR_dec_plc varchar(1) COLLATE utf8_bin NOT NULL DEFAULT '2', |
145 | 145 | CUR_active tinyint(1) DEFAULT '0', |
146 | 146 | PRIMARY KEY (CUR_code)"; |
147 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
147 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
148 | 148 | |
149 | - $table_name = 'esp_datetime'; |
|
150 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
149 | + $table_name = 'esp_datetime'; |
|
150 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
151 | 151 | EVT_ID bigint(20) unsigned NOT NULL, |
152 | 152 | DTT_name varchar(255) NOT NULL DEFAULT '', |
153 | 153 | DTT_description text NOT NULL, |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | KEY DTT_EVT_start (DTT_EVT_start), |
164 | 164 | KEY EVT_ID (EVT_ID), |
165 | 165 | KEY DTT_is_primary (DTT_is_primary)"; |
166 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
166 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
167 | 167 | |
168 | - $table_name = 'esp_event_meta'; |
|
169 | - $sql = " |
|
168 | + $table_name = 'esp_event_meta'; |
|
169 | + $sql = " |
|
170 | 170 | EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
171 | 171 | EVT_ID bigint(20) unsigned NOT NULL, |
172 | 172 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -182,38 +182,38 @@ discard block |
||
182 | 182 | EVT_donations tinyint(1) NULL, |
183 | 183 | PRIMARY KEY (EVTM_ID), |
184 | 184 | KEY EVT_ID (EVT_ID)"; |
185 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
185 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
186 | 186 | |
187 | - $table_name = 'esp_event_question_group'; |
|
188 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
187 | + $table_name = 'esp_event_question_group'; |
|
188 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
189 | 189 | EVT_ID bigint(20) unsigned NOT NULL, |
190 | 190 | QSG_ID int(10) unsigned NOT NULL, |
191 | 191 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
192 | 192 | PRIMARY KEY (EQG_ID), |
193 | 193 | KEY EVT_ID (EVT_ID), |
194 | 194 | KEY QSG_ID (QSG_ID)"; |
195 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
195 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
196 | 196 | |
197 | - $table_name = 'esp_event_venue'; |
|
198 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
197 | + $table_name = 'esp_event_venue'; |
|
198 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
199 | 199 | EVT_ID bigint(20) unsigned NOT NULL, |
200 | 200 | VNU_ID bigint(20) unsigned NOT NULL, |
201 | 201 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
202 | 202 | PRIMARY KEY (EVV_ID)"; |
203 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
203 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
204 | 204 | |
205 | - $table_name = 'esp_extra_meta'; |
|
206 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
205 | + $table_name = 'esp_extra_meta'; |
|
206 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
207 | 207 | OBJ_ID int(11) DEFAULT NULL, |
208 | 208 | EXM_type varchar(45) DEFAULT NULL, |
209 | 209 | EXM_key varchar(45) DEFAULT NULL, |
210 | 210 | EXM_value text, |
211 | 211 | PRIMARY KEY (EXM_ID), |
212 | 212 | KEY EXM_type (EXM_type, OBJ_ID, EXM_key(45))"; |
213 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
213 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
214 | 214 | |
215 | - $table_name = 'esp_line_item'; |
|
216 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
215 | + $table_name = 'esp_line_item'; |
|
216 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
217 | 217 | LIN_code varchar(245) NOT NULL DEFAULT '', |
218 | 218 | TXN_ID int(11) DEFAULT NULL, |
219 | 219 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | PRIMARY KEY (LIN_ID), |
232 | 232 | KEY LIN_code (LIN_code(191)), |
233 | 233 | KEY TXN_ID (TXN_ID)"; |
234 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
234 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
235 | 235 | |
236 | - $table_name = 'esp_log'; |
|
237 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
236 | + $table_name = 'esp_log'; |
|
237 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
238 | 238 | LOG_time datetime DEFAULT NULL, |
239 | 239 | OBJ_ID varchar(45) DEFAULT NULL, |
240 | 240 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -245,20 +245,20 @@ discard block |
||
245 | 245 | KEY LOG_time (LOG_time), |
246 | 246 | KEY OBJ (OBJ_type,OBJ_ID), |
247 | 247 | KEY LOG_type (LOG_type)"; |
248 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
248 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
249 | 249 | |
250 | - $table_name = 'esp_message_template'; |
|
251 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
250 | + $table_name = 'esp_message_template'; |
|
251 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
252 | 252 | GRP_ID int(10) unsigned NOT NULL, |
253 | 253 | MTP_context varchar(50) NOT NULL, |
254 | 254 | MTP_template_field varchar(30) NOT NULL, |
255 | 255 | MTP_content text NOT NULL, |
256 | 256 | PRIMARY KEY (MTP_ID), |
257 | 257 | KEY GRP_ID (GRP_ID)"; |
258 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
258 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
259 | 259 | |
260 | - $table_name = 'esp_message_template_group'; |
|
261 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
260 | + $table_name = 'esp_message_template_group'; |
|
261 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
262 | 262 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
263 | 263 | MTP_name varchar(245) NOT NULL DEFAULT '', |
264 | 264 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -270,19 +270,19 @@ discard block |
||
270 | 270 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
271 | 271 | PRIMARY KEY (GRP_ID), |
272 | 272 | KEY MTP_user_id (MTP_user_id)"; |
273 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
273 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
274 | 274 | |
275 | - $table_name = 'esp_event_message_template'; |
|
276 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
275 | + $table_name = 'esp_event_message_template'; |
|
276 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
277 | 277 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
278 | 278 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
279 | 279 | PRIMARY KEY (EMT_ID), |
280 | 280 | KEY EVT_ID (EVT_ID), |
281 | 281 | KEY GRP_ID (GRP_ID)"; |
282 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
282 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
283 | 283 | |
284 | - $table_name = 'esp_payment'; |
|
285 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
284 | + $table_name = 'esp_payment'; |
|
285 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
286 | 286 | TXN_ID int(10) unsigned DEFAULT NULL, |
287 | 287 | STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL, |
288 | 288 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | PRIMARY KEY (PAY_ID), |
300 | 300 | KEY PAY_timestamp (PAY_timestamp), |
301 | 301 | KEY TXN_ID (TXN_ID)"; |
302 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
302 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
303 | 303 | |
304 | - $table_name = 'esp_payment_method'; |
|
305 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
304 | + $table_name = 'esp_payment_method'; |
|
305 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
306 | 306 | PMD_type varchar(124) DEFAULT NULL, |
307 | 307 | PMD_name varchar(255) DEFAULT NULL, |
308 | 308 | PMD_desc text, |
@@ -318,36 +318,36 @@ discard block |
||
318 | 318 | PRIMARY KEY (PMD_ID), |
319 | 319 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
320 | 320 | KEY PMD_type (PMD_type)"; |
321 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
321 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
322 | 322 | |
323 | - $table_name = "esp_ticket_price"; |
|
324 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
323 | + $table_name = "esp_ticket_price"; |
|
324 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
325 | 325 | TKT_ID int(10) unsigned NOT NULL, |
326 | 326 | PRC_ID int(10) unsigned NOT NULL, |
327 | 327 | PRIMARY KEY (TKP_ID), |
328 | 328 | KEY TKT_ID (TKT_ID), |
329 | 329 | KEY PRC_ID (PRC_ID)"; |
330 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
330 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
331 | 331 | |
332 | - $table_name = "esp_datetime_ticket"; |
|
333 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
332 | + $table_name = "esp_datetime_ticket"; |
|
333 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
334 | 334 | DTT_ID int(10) unsigned NOT NULL, |
335 | 335 | TKT_ID int(10) unsigned NOT NULL, |
336 | 336 | PRIMARY KEY (DTK_ID), |
337 | 337 | KEY DTT_ID (DTT_ID), |
338 | 338 | KEY TKT_ID (TKT_ID)"; |
339 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
339 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
340 | 340 | |
341 | - $table_name = "esp_ticket_template"; |
|
342 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
341 | + $table_name = "esp_ticket_template"; |
|
342 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
343 | 343 | TTM_name varchar(45) NOT NULL, |
344 | 344 | TTM_description text, |
345 | 345 | TTM_file varchar(45), |
346 | 346 | PRIMARY KEY (TTM_ID)"; |
347 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
347 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
348 | 348 | |
349 | - $table_name = 'esp_question'; |
|
350 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
349 | + $table_name = 'esp_question'; |
|
350 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
351 | 351 | QST_display_text text NOT NULL, |
352 | 352 | QST_admin_label varchar(255) NOT NULL, |
353 | 353 | QST_system varchar(25) DEFAULT NULL, |
@@ -360,20 +360,20 @@ discard block |
||
360 | 360 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
361 | 361 | PRIMARY KEY (QST_ID), |
362 | 362 | KEY QST_order (QST_order)'; |
363 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
363 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
364 | 364 | |
365 | - $table_name = 'esp_question_group_question'; |
|
366 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
365 | + $table_name = 'esp_question_group_question'; |
|
366 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
367 | 367 | QSG_ID int(10) unsigned NOT NULL, |
368 | 368 | QST_ID int(10) unsigned NOT NULL, |
369 | 369 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
370 | 370 | PRIMARY KEY (QGQ_ID), |
371 | 371 | KEY QST_ID (QST_ID), |
372 | 372 | KEY QSG_ID_order (QSG_ID, QGQ_order)"; |
373 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
373 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
374 | 374 | |
375 | - $table_name = 'esp_question_option'; |
|
376 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
375 | + $table_name = 'esp_question_option'; |
|
376 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
377 | 377 | QSO_value varchar(255) NOT NULL, |
378 | 378 | QSO_desc text NOT NULL, |
379 | 379 | QST_ID int(10) unsigned NOT NULL, |
@@ -382,10 +382,10 @@ discard block |
||
382 | 382 | PRIMARY KEY (QSO_ID), |
383 | 383 | KEY QST_ID (QST_ID), |
384 | 384 | KEY QSO_order (QSO_order)"; |
385 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
385 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
386 | 386 | |
387 | - $table_name = 'esp_registration'; |
|
388 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
387 | + $table_name = 'esp_registration'; |
|
388 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
389 | 389 | EVT_ID bigint(20) unsigned NOT NULL, |
390 | 390 | ATT_ID bigint(20) unsigned NOT NULL, |
391 | 391 | TXN_ID int(10) unsigned NOT NULL, |
@@ -409,20 +409,20 @@ discard block |
||
409 | 409 | KEY TKT_ID (TKT_ID), |
410 | 410 | KEY EVT_ID (EVT_ID), |
411 | 411 | KEY STS_ID (STS_ID)"; |
412 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
412 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
413 | 413 | |
414 | - $table_name = 'esp_registration_payment'; |
|
415 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
414 | + $table_name = 'esp_registration_payment'; |
|
415 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
416 | 416 | REG_ID int(10) unsigned NOT NULL, |
417 | 417 | PAY_ID int(10) unsigned NULL, |
418 | 418 | RPY_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
419 | 419 | PRIMARY KEY (RPY_ID), |
420 | 420 | KEY REG_ID (REG_ID), |
421 | 421 | KEY PAY_ID (PAY_ID)"; |
422 | - $this->_table_is_new_in_this_version($table_name, $sql); |
|
422 | + $this->_table_is_new_in_this_version($table_name, $sql); |
|
423 | 423 | |
424 | - $table_name = 'esp_checkin'; |
|
425 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
424 | + $table_name = 'esp_checkin'; |
|
425 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
426 | 426 | REG_ID int(10) unsigned NOT NULL, |
427 | 427 | DTT_ID int(10) unsigned NOT NULL, |
428 | 428 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -430,10 +430,10 @@ discard block |
||
430 | 430 | PRIMARY KEY (CHK_ID), |
431 | 431 | KEY REG_ID (REG_ID), |
432 | 432 | KEY DTT_ID (DTT_ID)"; |
433 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
433 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
434 | 434 | |
435 | - $table_name = 'esp_state'; |
|
436 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
435 | + $table_name = 'esp_state'; |
|
436 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
437 | 437 | CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
438 | 438 | STA_abbrev varchar(24) COLLATE utf8_bin NOT NULL, |
439 | 439 | STA_name varchar(100) COLLATE utf8_bin NOT NULL, |
@@ -441,10 +441,10 @@ discard block |
||
441 | 441 | PRIMARY KEY (STA_ID), |
442 | 442 | KEY STA_abbrev (STA_abbrev), |
443 | 443 | KEY CNT_ISO (CNT_ISO)"; |
444 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
444 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
445 | 445 | |
446 | - $table_name = 'esp_status'; |
|
447 | - $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
446 | + $table_name = 'esp_status'; |
|
447 | + $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
448 | 448 | STS_code varchar(45) COLLATE utf8_bin NOT NULL, |
449 | 449 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
450 | 450 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -452,10 +452,10 @@ discard block |
||
452 | 452 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
453 | 453 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
454 | 454 | KEY STS_type (STS_type)"; |
455 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
455 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
456 | 456 | |
457 | - $table_name = 'esp_transaction'; |
|
458 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
457 | + $table_name = 'esp_transaction'; |
|
458 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
459 | 459 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
460 | 460 | TXN_total decimal(10,3) DEFAULT '0.00', |
461 | 461 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -467,10 +467,10 @@ discard block |
||
467 | 467 | PRIMARY KEY (TXN_ID), |
468 | 468 | KEY TXN_timestamp (TXN_timestamp), |
469 | 469 | KEY STS_ID (STS_ID)"; |
470 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
470 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
471 | 471 | |
472 | - $table_name = 'esp_venue_meta'; |
|
473 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
472 | + $table_name = 'esp_venue_meta'; |
|
473 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
474 | 474 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
475 | 475 | VNU_address varchar(255) DEFAULT NULL, |
476 | 476 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -489,10 +489,10 @@ discard block |
||
489 | 489 | KEY VNU_ID (VNU_ID), |
490 | 490 | KEY STA_ID (STA_ID), |
491 | 491 | KEY CNT_ISO (CNT_ISO)"; |
492 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
493 | - // modified tables |
|
494 | - $table_name = "esp_price"; |
|
495 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
492 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
493 | + // modified tables |
|
494 | + $table_name = "esp_price"; |
|
495 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
496 | 496 | PRT_ID tinyint(3) unsigned NOT NULL, |
497 | 497 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
498 | 498 | PRC_name varchar(245) NOT NULL, |
@@ -505,10 +505,10 @@ discard block |
||
505 | 505 | PRC_parent int(10) unsigned DEFAULT 0, |
506 | 506 | PRIMARY KEY (PRC_ID), |
507 | 507 | KEY PRT_ID (PRT_ID)"; |
508 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
508 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
509 | 509 | |
510 | - $table_name = "esp_price_type"; |
|
511 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
510 | + $table_name = "esp_price_type"; |
|
511 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
512 | 512 | PRT_name varchar(45) NOT NULL, |
513 | 513 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
514 | 514 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -517,10 +517,10 @@ discard block |
||
517 | 517 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
518 | 518 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
519 | 519 | PRIMARY KEY (PRT_ID)"; |
520 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
520 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
521 | 521 | |
522 | - $table_name = "esp_ticket"; |
|
523 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
522 | + $table_name = "esp_ticket"; |
|
523 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
524 | 524 | TTM_ID int(10) unsigned NOT NULL, |
525 | 525 | TKT_name varchar(245) NOT NULL DEFAULT '', |
526 | 526 | TKT_description text NOT NULL, |
@@ -542,10 +542,10 @@ discard block |
||
542 | 542 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
543 | 543 | PRIMARY KEY (TKT_ID), |
544 | 544 | KEY TKT_start_date (TKT_start_date)"; |
545 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
545 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
546 | 546 | |
547 | - $table_name = 'esp_question_group'; |
|
548 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
547 | + $table_name = 'esp_question_group'; |
|
548 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
549 | 549 | QSG_name varchar(255) NOT NULL, |
550 | 550 | QSG_identifier varchar(100) NOT NULL, |
551 | 551 | QSG_desc text NULL, |
@@ -558,36 +558,36 @@ discard block |
||
558 | 558 | PRIMARY KEY (QSG_ID), |
559 | 559 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
560 | 560 | KEY QSG_order (QSG_order)'; |
561 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
562 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
563 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
564 | - // (because many need to convert old string states to foreign keys into the states table) |
|
565 | - $script_4_1_defaults->insert_default_states(); |
|
566 | - $script_4_1_defaults->insert_default_countries(); |
|
567 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
568 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
569 | - $script_4_5_defaults->insert_default_price_types(); |
|
570 | - $script_4_5_defaults->insert_default_prices(); |
|
571 | - $script_4_5_defaults->insert_default_tickets(); |
|
572 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
573 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
574 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
575 | - $script_4_6_defaults->insert_default_currencies(); |
|
576 | - return true; |
|
577 | - } |
|
578 | - |
|
579 | - |
|
580 | - /** |
|
581 | - * @return boolean |
|
582 | - */ |
|
583 | - public function schema_changes_after_migration() |
|
584 | - { |
|
585 | - return true; |
|
586 | - } |
|
587 | - |
|
588 | - |
|
589 | - public function migration_page_hooks() |
|
590 | - { |
|
591 | - } |
|
561 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
562 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
563 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
564 | + // (because many need to convert old string states to foreign keys into the states table) |
|
565 | + $script_4_1_defaults->insert_default_states(); |
|
566 | + $script_4_1_defaults->insert_default_countries(); |
|
567 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
568 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
569 | + $script_4_5_defaults->insert_default_price_types(); |
|
570 | + $script_4_5_defaults->insert_default_prices(); |
|
571 | + $script_4_5_defaults->insert_default_tickets(); |
|
572 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
573 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
574 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
575 | + $script_4_6_defaults->insert_default_currencies(); |
|
576 | + return true; |
|
577 | + } |
|
578 | + |
|
579 | + |
|
580 | + /** |
|
581 | + * @return boolean |
|
582 | + */ |
|
583 | + public function schema_changes_after_migration() |
|
584 | + { |
|
585 | + return true; |
|
586 | + } |
|
587 | + |
|
588 | + |
|
589 | + public function migration_page_hooks() |
|
590 | + { |
|
591 | + } |
|
592 | 592 | } |
593 | 593 | // end of file: /core/data_migration_scripts/EE_DMS_Core_4_7_0.dms.php |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | $stages = glob(EE_CORE . 'data_migration_scripts/4_10_0_stages/*'); |
13 | 13 | $class_to_filepath = []; |
14 | 14 | foreach ($stages as $filepath) { |
15 | - $matches = []; |
|
16 | - preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
15 | + $matches = []; |
|
16 | + preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
18 | 18 | } |
19 | 19 | // give addons a chance to autoload their stages too |
20 | 20 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_10_0__autoloaded_stages', $class_to_filepath); |
@@ -31,69 +31,69 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class EE_DMS_Core_4_10_0 extends EE_Data_Migration_Script_Base |
33 | 33 | { |
34 | - /** |
|
35 | - * @param TableManager|null $table_manager |
|
36 | - * @param TableAnalysis|null $table_analysis |
|
37 | - * @param EE_DMS_Core_4_9_0 $dms_4_9 |
|
38 | - */ |
|
39 | - public function __construct( |
|
40 | - EE_DMS_Core_4_9_0 $dms_4_9, |
|
41 | - TableManager $table_manager = null, |
|
42 | - TableAnalysis $table_analysis = null |
|
43 | - ) { |
|
44 | - $this->previous_dms = $dms_4_9; |
|
45 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.10.0", "event_espresso"); |
|
46 | - $this->_priority = 10; |
|
47 | - $this->_migration_stages = array( |
|
48 | - new EE_DMS_4_10_0_Event_Question_Group(), |
|
49 | - ); |
|
50 | - parent::__construct($table_manager, $table_analysis); |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * Whether to migrate or not. |
|
57 | - * |
|
58 | - * @param array $version_array |
|
59 | - * @return bool |
|
60 | - */ |
|
61 | - public function can_migrate_from_version($version_array) |
|
62 | - { |
|
63 | - $version_string = $version_array['Core']; |
|
64 | - if (version_compare($version_string, '4.10.0.decaf', '<') && version_compare($version_string, '4.9.0.decaf', '>=')) { |
|
65 | - return true; |
|
66 | - } elseif (! $version_string) { |
|
67 | - // echo "no version string provided: $version_string"; |
|
68 | - // no version string provided... this must be pre 4.3 |
|
69 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
70 | - } |
|
71 | - return false; |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * @return bool |
|
77 | - * @throws EE_Error |
|
78 | - * @throws ReflectionException |
|
79 | - */ |
|
80 | - public function schema_changes_before_migration() |
|
81 | - { |
|
82 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
83 | - $now_in_mysql = current_time('mysql', true); |
|
84 | - |
|
85 | - $table_name = 'esp_answer'; |
|
86 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
34 | + /** |
|
35 | + * @param TableManager|null $table_manager |
|
36 | + * @param TableAnalysis|null $table_analysis |
|
37 | + * @param EE_DMS_Core_4_9_0 $dms_4_9 |
|
38 | + */ |
|
39 | + public function __construct( |
|
40 | + EE_DMS_Core_4_9_0 $dms_4_9, |
|
41 | + TableManager $table_manager = null, |
|
42 | + TableAnalysis $table_analysis = null |
|
43 | + ) { |
|
44 | + $this->previous_dms = $dms_4_9; |
|
45 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.10.0", "event_espresso"); |
|
46 | + $this->_priority = 10; |
|
47 | + $this->_migration_stages = array( |
|
48 | + new EE_DMS_4_10_0_Event_Question_Group(), |
|
49 | + ); |
|
50 | + parent::__construct($table_manager, $table_analysis); |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * Whether to migrate or not. |
|
57 | + * |
|
58 | + * @param array $version_array |
|
59 | + * @return bool |
|
60 | + */ |
|
61 | + public function can_migrate_from_version($version_array) |
|
62 | + { |
|
63 | + $version_string = $version_array['Core']; |
|
64 | + if (version_compare($version_string, '4.10.0.decaf', '<') && version_compare($version_string, '4.9.0.decaf', '>=')) { |
|
65 | + return true; |
|
66 | + } elseif (! $version_string) { |
|
67 | + // echo "no version string provided: $version_string"; |
|
68 | + // no version string provided... this must be pre 4.3 |
|
69 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
70 | + } |
|
71 | + return false; |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * @return bool |
|
77 | + * @throws EE_Error |
|
78 | + * @throws ReflectionException |
|
79 | + */ |
|
80 | + public function schema_changes_before_migration() |
|
81 | + { |
|
82 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
83 | + $now_in_mysql = current_time('mysql', true); |
|
84 | + |
|
85 | + $table_name = 'esp_answer'; |
|
86 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
87 | 87 | REG_ID int(10) unsigned NOT NULL, |
88 | 88 | QST_ID int(10) unsigned NOT NULL, |
89 | 89 | ANS_value text NOT NULL, |
90 | 90 | PRIMARY KEY (ANS_ID), |
91 | 91 | KEY REG_ID (REG_ID), |
92 | 92 | KEY QST_ID (QST_ID)"; |
93 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
93 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
94 | 94 | |
95 | - $table_name = 'esp_attendee_meta'; |
|
96 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
95 | + $table_name = 'esp_attendee_meta'; |
|
96 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
97 | 97 | ATT_ID bigint(20) unsigned NOT NULL, |
98 | 98 | ATT_fname varchar(45) NOT NULL, |
99 | 99 | ATT_lname varchar(45) NOT NULL, |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | KEY ATT_email (ATT_email(191)), |
111 | 111 | KEY ATT_lname (ATT_lname), |
112 | 112 | KEY ATT_fname (ATT_fname)"; |
113 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
113 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
114 | 114 | |
115 | - $table_name = 'esp_checkin'; |
|
116 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
115 | + $table_name = 'esp_checkin'; |
|
116 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
117 | 117 | REG_ID int(10) unsigned NOT NULL, |
118 | 118 | DTT_ID int(10) unsigned NOT NULL, |
119 | 119 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | PRIMARY KEY (CHK_ID), |
122 | 122 | KEY REG_ID (REG_ID), |
123 | 123 | KEY DTT_ID (DTT_ID)"; |
124 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
124 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
125 | 125 | |
126 | - $table_name = 'esp_country'; |
|
127 | - $sql = "CNT_ISO varchar(2) NOT NULL, |
|
126 | + $table_name = 'esp_country'; |
|
127 | + $sql = "CNT_ISO varchar(2) NOT NULL, |
|
128 | 128 | CNT_ISO3 varchar(3) NOT NULL, |
129 | 129 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
130 | 130 | CNT_name varchar(45) NOT NULL, |
@@ -140,20 +140,20 @@ discard block |
||
140 | 140 | CNT_is_EU tinyint(1) DEFAULT '0', |
141 | 141 | CNT_active tinyint(1) DEFAULT '0', |
142 | 142 | PRIMARY KEY (CNT_ISO)"; |
143 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
143 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
144 | 144 | |
145 | - $table_name = 'esp_currency'; |
|
146 | - $sql = "CUR_code varchar(6) NOT NULL, |
|
145 | + $table_name = 'esp_currency'; |
|
146 | + $sql = "CUR_code varchar(6) NOT NULL, |
|
147 | 147 | CUR_single varchar(45) DEFAULT 'dollar', |
148 | 148 | CUR_plural varchar(45) DEFAULT 'dollars', |
149 | 149 | CUR_sign varchar(45) DEFAULT '$', |
150 | 150 | CUR_dec_plc varchar(1) NOT NULL DEFAULT '2', |
151 | 151 | CUR_active tinyint(1) DEFAULT '0', |
152 | 152 | PRIMARY KEY (CUR_code)"; |
153 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
153 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
154 | 154 | |
155 | - $table_name = 'esp_datetime'; |
|
156 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
155 | + $table_name = 'esp_datetime'; |
|
156 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
157 | 157 | EVT_ID bigint(20) unsigned NOT NULL, |
158 | 158 | DTT_name varchar(255) NOT NULL DEFAULT '', |
159 | 159 | DTT_description text NOT NULL, |
@@ -170,28 +170,28 @@ discard block |
||
170 | 170 | KEY DTT_EVT_start (DTT_EVT_start), |
171 | 171 | KEY EVT_ID (EVT_ID), |
172 | 172 | KEY DTT_is_primary (DTT_is_primary)"; |
173 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
173 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
174 | 174 | |
175 | - $table_name = "esp_datetime_ticket"; |
|
176 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
175 | + $table_name = "esp_datetime_ticket"; |
|
176 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
177 | 177 | DTT_ID int(10) unsigned NOT NULL, |
178 | 178 | TKT_ID int(10) unsigned NOT NULL, |
179 | 179 | PRIMARY KEY (DTK_ID), |
180 | 180 | KEY DTT_ID (DTT_ID), |
181 | 181 | KEY TKT_ID (TKT_ID)"; |
182 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
182 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
183 | 183 | |
184 | - $table_name = 'esp_event_message_template'; |
|
185 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
184 | + $table_name = 'esp_event_message_template'; |
|
185 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
186 | 186 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
187 | 187 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
188 | 188 | PRIMARY KEY (EMT_ID), |
189 | 189 | KEY EVT_ID (EVT_ID), |
190 | 190 | KEY GRP_ID (GRP_ID)"; |
191 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
191 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
192 | 192 | |
193 | - $table_name = 'esp_event_meta'; |
|
194 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
193 | + $table_name = 'esp_event_meta'; |
|
194 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
195 | 195 | EVT_ID bigint(20) unsigned NOT NULL, |
196 | 196 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
197 | 197 | EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -206,10 +206,10 @@ discard block |
||
206 | 206 | EVT_donations tinyint(1) NULL, |
207 | 207 | PRIMARY KEY (EVTM_ID), |
208 | 208 | KEY EVT_ID (EVT_ID)"; |
209 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
209 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
210 | 210 | |
211 | - $table_name = 'esp_event_question_group'; |
|
212 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
211 | + $table_name = 'esp_event_question_group'; |
|
212 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
213 | 213 | EVT_ID bigint(20) unsigned NOT NULL, |
214 | 214 | QSG_ID int(10) unsigned NOT NULL, |
215 | 215 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
@@ -217,28 +217,28 @@ discard block |
||
217 | 217 | PRIMARY KEY (EQG_ID), |
218 | 218 | KEY EVT_ID (EVT_ID), |
219 | 219 | KEY QSG_ID (QSG_ID)"; |
220 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
220 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
221 | 221 | |
222 | - $table_name = 'esp_event_venue'; |
|
223 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
222 | + $table_name = 'esp_event_venue'; |
|
223 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
224 | 224 | EVT_ID bigint(20) unsigned NOT NULL, |
225 | 225 | VNU_ID bigint(20) unsigned NOT NULL, |
226 | 226 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
227 | 227 | PRIMARY KEY (EVV_ID)"; |
228 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
228 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
229 | 229 | |
230 | - $table_name = 'esp_extra_meta'; |
|
231 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
230 | + $table_name = 'esp_extra_meta'; |
|
231 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
232 | 232 | OBJ_ID int(11) DEFAULT NULL, |
233 | 233 | EXM_type varchar(45) DEFAULT NULL, |
234 | 234 | EXM_key varchar(45) DEFAULT NULL, |
235 | 235 | EXM_value text, |
236 | 236 | PRIMARY KEY (EXM_ID), |
237 | 237 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
238 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
238 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
239 | 239 | |
240 | - $table_name = 'esp_extra_join'; |
|
241 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
240 | + $table_name = 'esp_extra_join'; |
|
241 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
242 | 242 | EXJ_first_model_id varchar(6) NOT NULL, |
243 | 243 | EXJ_first_model_name varchar(20) NOT NULL, |
244 | 244 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -246,10 +246,10 @@ discard block |
||
246 | 246 | PRIMARY KEY (EXJ_ID), |
247 | 247 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
248 | 248 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
249 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
249 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
250 | 250 | |
251 | - $table_name = 'esp_line_item'; |
|
252 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
251 | + $table_name = 'esp_line_item'; |
|
252 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
253 | 253 | LIN_code varchar(245) NOT NULL DEFAULT '', |
254 | 254 | TXN_ID int(11) DEFAULT NULL, |
255 | 255 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -270,10 +270,10 @@ discard block |
||
270 | 270 | KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp), |
271 | 271 | KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type), |
272 | 272 | KEY obj_id_obj_type (OBJ_ID,OBJ_type)"; |
273 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
273 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
274 | 274 | |
275 | - $table_name = 'esp_log'; |
|
276 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
275 | + $table_name = 'esp_log'; |
|
276 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
277 | 277 | LOG_time datetime DEFAULT NULL, |
278 | 278 | OBJ_ID varchar(45) DEFAULT NULL, |
279 | 279 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -284,10 +284,10 @@ discard block |
||
284 | 284 | KEY LOG_time (LOG_time), |
285 | 285 | KEY OBJ (OBJ_type,OBJ_ID), |
286 | 286 | KEY LOG_type (LOG_type)"; |
287 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
287 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
288 | 288 | |
289 | - $table_name = 'esp_message'; |
|
290 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
289 | + $table_name = 'esp_message'; |
|
290 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
291 | 291 | GRP_ID int(10) unsigned NULL, |
292 | 292 | MSG_token varchar(255) NULL, |
293 | 293 | TXN_ID int(10) unsigned NULL, |
@@ -319,20 +319,20 @@ discard block |
||
319 | 319 | KEY STS_ID (STS_ID), |
320 | 320 | KEY MSG_created (MSG_created), |
321 | 321 | KEY MSG_modified (MSG_modified)"; |
322 | - $this->_table_is_new_in_this_version($table_name, $sql); |
|
322 | + $this->_table_is_new_in_this_version($table_name, $sql); |
|
323 | 323 | |
324 | - $table_name = 'esp_message_template'; |
|
325 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
324 | + $table_name = 'esp_message_template'; |
|
325 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
326 | 326 | GRP_ID int(10) unsigned NOT NULL, |
327 | 327 | MTP_context varchar(50) NOT NULL, |
328 | 328 | MTP_template_field varchar(30) NOT NULL, |
329 | 329 | MTP_content text NOT NULL, |
330 | 330 | PRIMARY KEY (MTP_ID), |
331 | 331 | KEY GRP_ID (GRP_ID)"; |
332 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
332 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
333 | 333 | |
334 | - $table_name = 'esp_message_template_group'; |
|
335 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
334 | + $table_name = 'esp_message_template_group'; |
|
335 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
336 | 336 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
337 | 337 | MTP_name varchar(245) NOT NULL DEFAULT '', |
338 | 338 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -344,10 +344,10 @@ discard block |
||
344 | 344 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
345 | 345 | PRIMARY KEY (GRP_ID), |
346 | 346 | KEY MTP_user_id (MTP_user_id)"; |
347 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
347 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
348 | 348 | |
349 | - $table_name = 'esp_payment'; |
|
350 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
349 | + $table_name = 'esp_payment'; |
|
350 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
351 | 351 | TXN_ID int(10) unsigned DEFAULT NULL, |
352 | 352 | STS_ID varchar(3) DEFAULT NULL, |
353 | 353 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -364,10 +364,10 @@ discard block |
||
364 | 364 | PRIMARY KEY (PAY_ID), |
365 | 365 | KEY PAY_timestamp (PAY_timestamp), |
366 | 366 | KEY TXN_ID (TXN_ID)"; |
367 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
367 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
368 | 368 | |
369 | - $table_name = 'esp_payment_method'; |
|
370 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
369 | + $table_name = 'esp_payment_method'; |
|
370 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
371 | 371 | PMD_type varchar(124) DEFAULT NULL, |
372 | 372 | PMD_name varchar(255) DEFAULT NULL, |
373 | 373 | PMD_desc text, |
@@ -383,27 +383,27 @@ discard block |
||
383 | 383 | PRIMARY KEY (PMD_ID), |
384 | 384 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
385 | 385 | KEY PMD_type (PMD_type)"; |
386 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
386 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
387 | 387 | |
388 | - $table_name = "esp_ticket_price"; |
|
389 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
388 | + $table_name = "esp_ticket_price"; |
|
389 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
390 | 390 | TKT_ID int(10) unsigned NOT NULL, |
391 | 391 | PRC_ID int(10) unsigned NOT NULL, |
392 | 392 | PRIMARY KEY (TKP_ID), |
393 | 393 | KEY TKT_ID (TKT_ID), |
394 | 394 | KEY PRC_ID (PRC_ID)"; |
395 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
395 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
396 | 396 | |
397 | - $table_name = "esp_ticket_template"; |
|
398 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
397 | + $table_name = "esp_ticket_template"; |
|
398 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
399 | 399 | TTM_name varchar(45) NOT NULL, |
400 | 400 | TTM_description text, |
401 | 401 | TTM_file varchar(45), |
402 | 402 | PRIMARY KEY (TTM_ID)"; |
403 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
403 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
404 | 404 | |
405 | - $table_name = 'esp_question'; |
|
406 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
405 | + $table_name = 'esp_question'; |
|
406 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
407 | 407 | QST_display_text text NOT NULL, |
408 | 408 | QST_admin_label varchar(255) NOT NULL, |
409 | 409 | QST_system varchar(25) DEFAULT NULL, |
@@ -417,20 +417,20 @@ discard block |
||
417 | 417 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
418 | 418 | PRIMARY KEY (QST_ID), |
419 | 419 | KEY QST_order (QST_order)'; |
420 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
420 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
421 | 421 | |
422 | - $table_name = 'esp_question_group_question'; |
|
423 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
422 | + $table_name = 'esp_question_group_question'; |
|
423 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
424 | 424 | QSG_ID int(10) unsigned NOT NULL, |
425 | 425 | QST_ID int(10) unsigned NOT NULL, |
426 | 426 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
427 | 427 | PRIMARY KEY (QGQ_ID), |
428 | 428 | KEY QST_ID (QST_ID), |
429 | 429 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
430 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
430 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
431 | 431 | |
432 | - $table_name = 'esp_question_option'; |
|
433 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
432 | + $table_name = 'esp_question_option'; |
|
433 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
434 | 434 | QSO_value varchar(255) NOT NULL, |
435 | 435 | QSO_desc text NOT NULL, |
436 | 436 | QST_ID int(10) unsigned NOT NULL, |
@@ -440,10 +440,10 @@ discard block |
||
440 | 440 | PRIMARY KEY (QSO_ID), |
441 | 441 | KEY QST_ID (QST_ID), |
442 | 442 | KEY QSO_order (QSO_order)"; |
443 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
443 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
444 | 444 | |
445 | - $table_name = 'esp_registration'; |
|
446 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
445 | + $table_name = 'esp_registration'; |
|
446 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
447 | 447 | EVT_ID bigint(20) unsigned NOT NULL, |
448 | 448 | ATT_ID bigint(20) unsigned NOT NULL, |
449 | 449 | TXN_ID int(10) unsigned NOT NULL, |
@@ -467,20 +467,20 @@ discard block |
||
467 | 467 | KEY TKT_ID (TKT_ID), |
468 | 468 | KEY EVT_ID (EVT_ID), |
469 | 469 | KEY STS_ID (STS_ID)"; |
470 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
470 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
471 | 471 | |
472 | - $table_name = 'esp_registration_payment'; |
|
473 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
472 | + $table_name = 'esp_registration_payment'; |
|
473 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
474 | 474 | REG_ID int(10) unsigned NOT NULL, |
475 | 475 | PAY_ID int(10) unsigned NULL, |
476 | 476 | RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
477 | 477 | PRIMARY KEY (RPY_ID), |
478 | 478 | KEY REG_ID (REG_ID), |
479 | 479 | KEY PAY_ID (PAY_ID)"; |
480 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
480 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
481 | 481 | |
482 | - $table_name = 'esp_state'; |
|
483 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
482 | + $table_name = 'esp_state'; |
|
483 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
484 | 484 | CNT_ISO varchar(2) NOT NULL, |
485 | 485 | STA_abbrev varchar(24) NOT NULL, |
486 | 486 | STA_name varchar(100) NOT NULL, |
@@ -488,10 +488,10 @@ discard block |
||
488 | 488 | PRIMARY KEY (STA_ID), |
489 | 489 | KEY STA_abbrev (STA_abbrev), |
490 | 490 | KEY CNT_ISO (CNT_ISO)"; |
491 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
491 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
492 | 492 | |
493 | - $table_name = 'esp_status'; |
|
494 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
493 | + $table_name = 'esp_status'; |
|
494 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
495 | 495 | STS_code varchar(45) NOT NULL, |
496 | 496 | STS_type varchar(45) NOT NULL, |
497 | 497 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -499,10 +499,10 @@ discard block |
||
499 | 499 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
500 | 500 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
501 | 501 | KEY STS_type (STS_type)"; |
502 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
502 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
503 | 503 | |
504 | - $table_name = 'esp_transaction'; |
|
505 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
504 | + $table_name = 'esp_transaction'; |
|
505 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
506 | 506 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
507 | 507 | TXN_total decimal(12,3) DEFAULT '0.00', |
508 | 508 | TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00', |
@@ -514,10 +514,10 @@ discard block |
||
514 | 514 | PRIMARY KEY (TXN_ID), |
515 | 515 | KEY TXN_timestamp (TXN_timestamp), |
516 | 516 | KEY STS_ID (STS_ID)"; |
517 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
517 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
518 | 518 | |
519 | - $table_name = 'esp_venue_meta'; |
|
520 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
519 | + $table_name = 'esp_venue_meta'; |
|
520 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
521 | 521 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
522 | 522 | VNU_address varchar(255) DEFAULT NULL, |
523 | 523 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -536,10 +536,10 @@ discard block |
||
536 | 536 | KEY VNU_ID (VNU_ID), |
537 | 537 | KEY STA_ID (STA_ID), |
538 | 538 | KEY CNT_ISO (CNT_ISO)"; |
539 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
540 | - // modified tables |
|
541 | - $table_name = "esp_price"; |
|
542 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
539 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
540 | + // modified tables |
|
541 | + $table_name = "esp_price"; |
|
542 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
543 | 543 | PRT_ID tinyint(3) unsigned NOT NULL, |
544 | 544 | PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
545 | 545 | PRC_name varchar(245) NOT NULL, |
@@ -552,10 +552,10 @@ discard block |
||
552 | 552 | PRC_parent int(10) unsigned DEFAULT 0, |
553 | 553 | PRIMARY KEY (PRC_ID), |
554 | 554 | KEY PRT_ID (PRT_ID)"; |
555 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
555 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
556 | 556 | |
557 | - $table_name = "esp_price_type"; |
|
558 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
557 | + $table_name = "esp_price_type"; |
|
558 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
559 | 559 | PRT_name varchar(45) NOT NULL, |
560 | 560 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
561 | 561 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -564,10 +564,10 @@ discard block |
||
564 | 564 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
565 | 565 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
566 | 566 | PRIMARY KEY (PRT_ID)"; |
567 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
567 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
568 | 568 | |
569 | - $table_name = "esp_ticket"; |
|
570 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
569 | + $table_name = "esp_ticket"; |
|
570 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
571 | 571 | TTM_ID int(10) unsigned NOT NULL, |
572 | 572 | TKT_name varchar(245) NOT NULL DEFAULT '', |
573 | 573 | TKT_description text NOT NULL, |
@@ -590,10 +590,10 @@ discard block |
||
590 | 590 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
591 | 591 | PRIMARY KEY (TKT_ID), |
592 | 592 | KEY TKT_start_date (TKT_start_date)"; |
593 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
593 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
594 | 594 | |
595 | - $table_name = 'esp_question_group'; |
|
596 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
595 | + $table_name = 'esp_question_group'; |
|
596 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
597 | 597 | QSG_name varchar(255) NOT NULL, |
598 | 598 | QSG_identifier varchar(100) NOT NULL, |
599 | 599 | QSG_desc text NULL, |
@@ -606,70 +606,70 @@ discard block |
||
606 | 606 | PRIMARY KEY (QSG_ID), |
607 | 607 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
608 | 608 | KEY QSG_order (QSG_order)'; |
609 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
610 | - $this->insert_default_data(); |
|
611 | - return true; |
|
612 | - } |
|
613 | - |
|
614 | - /** |
|
615 | - * Inserts default data on new installs |
|
616 | - * @since 4.10.0.p |
|
617 | - * @throws EE_Error |
|
618 | - * @throws InvalidArgumentException |
|
619 | - * @throws ReflectionException |
|
620 | - * @throws InvalidDataTypeException |
|
621 | - * @throws InvalidInterfaceException |
|
622 | - */ |
|
623 | - public function insert_default_data() |
|
624 | - { |
|
625 | - $this->previous_dms->insert_default_data(); |
|
626 | - $this->removeMijirehPM(); |
|
627 | - } |
|
628 | - |
|
629 | - |
|
630 | - |
|
631 | - /** |
|
632 | - * @return boolean |
|
633 | - */ |
|
634 | - public function schema_changes_after_migration() |
|
635 | - { |
|
636 | - return true; |
|
637 | - } |
|
638 | - |
|
639 | - |
|
640 | - |
|
641 | - public function migration_page_hooks() |
|
642 | - { |
|
643 | - } |
|
644 | - |
|
645 | - /** |
|
646 | - * Mijireh was removed in 4.10.3.p, but let's avoid having an error message because its files were removed, and don't |
|
647 | - * show old payments made with it as being by "Unknown". The fix is to make it an "Admin_Only" payment method |
|
648 | - * (like Invoice or Check) but don't allow it to be used in the admin either... so it's usable nowhere from now on, |
|
649 | - * but it still exists so there's no problems. |
|
650 | - * @since 4.10.3.p |
|
651 | - */ |
|
652 | - protected function removeMijirehPM() |
|
653 | - { |
|
654 | - global $wpdb; |
|
655 | - $wpdb->update( |
|
656 | - $wpdb->prefix . 'esp_payment_method', |
|
657 | - [ |
|
658 | - 'PMD_type' => 'Admin_Only', |
|
659 | - 'PMD_scope' => serialize(array()) |
|
660 | - ], |
|
661 | - [ |
|
662 | - 'PMD_type' => 'Mijireh' |
|
663 | - ], |
|
664 | - [ |
|
665 | - // update formats |
|
666 | - '%s', // PMD_type |
|
667 | - '%s', // PMD_scope |
|
668 | - ], |
|
669 | - [ |
|
670 | - // where formats |
|
671 | - '%s' |
|
672 | - ] |
|
673 | - ); |
|
674 | - } |
|
609 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
610 | + $this->insert_default_data(); |
|
611 | + return true; |
|
612 | + } |
|
613 | + |
|
614 | + /** |
|
615 | + * Inserts default data on new installs |
|
616 | + * @since 4.10.0.p |
|
617 | + * @throws EE_Error |
|
618 | + * @throws InvalidArgumentException |
|
619 | + * @throws ReflectionException |
|
620 | + * @throws InvalidDataTypeException |
|
621 | + * @throws InvalidInterfaceException |
|
622 | + */ |
|
623 | + public function insert_default_data() |
|
624 | + { |
|
625 | + $this->previous_dms->insert_default_data(); |
|
626 | + $this->removeMijirehPM(); |
|
627 | + } |
|
628 | + |
|
629 | + |
|
630 | + |
|
631 | + /** |
|
632 | + * @return boolean |
|
633 | + */ |
|
634 | + public function schema_changes_after_migration() |
|
635 | + { |
|
636 | + return true; |
|
637 | + } |
|
638 | + |
|
639 | + |
|
640 | + |
|
641 | + public function migration_page_hooks() |
|
642 | + { |
|
643 | + } |
|
644 | + |
|
645 | + /** |
|
646 | + * Mijireh was removed in 4.10.3.p, but let's avoid having an error message because its files were removed, and don't |
|
647 | + * show old payments made with it as being by "Unknown". The fix is to make it an "Admin_Only" payment method |
|
648 | + * (like Invoice or Check) but don't allow it to be used in the admin either... so it's usable nowhere from now on, |
|
649 | + * but it still exists so there's no problems. |
|
650 | + * @since 4.10.3.p |
|
651 | + */ |
|
652 | + protected function removeMijirehPM() |
|
653 | + { |
|
654 | + global $wpdb; |
|
655 | + $wpdb->update( |
|
656 | + $wpdb->prefix . 'esp_payment_method', |
|
657 | + [ |
|
658 | + 'PMD_type' => 'Admin_Only', |
|
659 | + 'PMD_scope' => serialize(array()) |
|
660 | + ], |
|
661 | + [ |
|
662 | + 'PMD_type' => 'Mijireh' |
|
663 | + ], |
|
664 | + [ |
|
665 | + // update formats |
|
666 | + '%s', // PMD_type |
|
667 | + '%s', // PMD_scope |
|
668 | + ], |
|
669 | + [ |
|
670 | + // where formats |
|
671 | + '%s' |
|
672 | + ] |
|
673 | + ); |
|
674 | + } |
|
675 | 675 | } |
@@ -15,45 +15,45 @@ |
||
15 | 15 | */ |
16 | 16 | class EE_DMS_Unknown_1_0_0 extends EE_Data_Migration_Script_Base |
17 | 17 | { |
18 | - /** |
|
19 | - * Returns whether this data migration script can operate on the given version of the database. |
|
20 | - * Eg, if this migration script can migrate from 3.1.26 or higher (but not anything after 4.0.0), and |
|
21 | - * it's passed a string like '3.1.38B', it should return true |
|
22 | - * |
|
23 | - * @param string $version_string |
|
24 | - * @return boolean |
|
25 | - */ |
|
26 | - public function can_migrate_from_version($version_string) |
|
27 | - { |
|
28 | - return false; |
|
29 | - } |
|
30 | - |
|
31 | - |
|
32 | - public function schema_changes_after_migration() |
|
33 | - { |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - public function schema_changes_before_migration() |
|
38 | - { |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * All children of this must call parent::__construct() at the end of their constructor or suffer the consequences! |
|
44 | - * |
|
45 | - * @param TableManager|null $table_manager |
|
46 | - * @param TableAnalysis|null $table_analysis |
|
47 | - */ |
|
48 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
49 | - { |
|
50 | - $this->_migration_stages = []; |
|
51 | - $this->_pretty_name = esc_html__("Fatal Uncatchable Error Occurred", "event_espresso"); |
|
52 | - parent::__construct($table_manager, $table_analysis); |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - public function migration_page_hooks() |
|
57 | - { |
|
58 | - } |
|
18 | + /** |
|
19 | + * Returns whether this data migration script can operate on the given version of the database. |
|
20 | + * Eg, if this migration script can migrate from 3.1.26 or higher (but not anything after 4.0.0), and |
|
21 | + * it's passed a string like '3.1.38B', it should return true |
|
22 | + * |
|
23 | + * @param string $version_string |
|
24 | + * @return boolean |
|
25 | + */ |
|
26 | + public function can_migrate_from_version($version_string) |
|
27 | + { |
|
28 | + return false; |
|
29 | + } |
|
30 | + |
|
31 | + |
|
32 | + public function schema_changes_after_migration() |
|
33 | + { |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + public function schema_changes_before_migration() |
|
38 | + { |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * All children of this must call parent::__construct() at the end of their constructor or suffer the consequences! |
|
44 | + * |
|
45 | + * @param TableManager|null $table_manager |
|
46 | + * @param TableAnalysis|null $table_analysis |
|
47 | + */ |
|
48 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
49 | + { |
|
50 | + $this->_migration_stages = []; |
|
51 | + $this->_pretty_name = esc_html__("Fatal Uncatchable Error Occurred", "event_espresso"); |
|
52 | + parent::__construct($table_manager, $table_analysis); |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + public function migration_page_hooks() |
|
57 | + { |
|
58 | + } |
|
59 | 59 | } |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | $stages = glob(EE_CORE . 'data_migration_scripts/4_8_0_stages/*'); |
11 | 11 | $class_to_filepath = []; |
12 | 12 | foreach ($stages as $filepath) { |
13 | - $matches = []; |
|
14 | - preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
15 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
13 | + $matches = []; |
|
14 | + preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
15 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
16 | 16 | } |
17 | 17 | // give addons a chance to autoload their stages too |
18 | 18 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_8_0__autoloaded_stages', $class_to_filepath); |
@@ -34,76 +34,76 @@ discard block |
||
34 | 34 | */ |
35 | 35 | class EE_DMS_Core_4_8_0 extends EE_Data_Migration_Script_Base |
36 | 36 | { |
37 | - /** |
|
38 | - * return EE_DMS_Core_4_8_0 |
|
39 | - * |
|
40 | - * @param TableManager|null $table_manager |
|
41 | - * @param TableAnalysis|null $table_analysis |
|
42 | - */ |
|
43 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
44 | - { |
|
45 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.8.0", "event_espresso"); |
|
46 | - $this->_priority = 10; |
|
47 | - $this->_migration_stages = [ |
|
48 | - new EE_DMS_4_8_0_pretax_totals(), |
|
49 | - new EE_DMS_4_8_0_event_subtotals(), |
|
50 | - ]; |
|
51 | - parent::__construct($table_manager, $table_analysis); |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * Because this is being done at basically the same time as the MER-ready branch |
|
57 | - * of core, it's possible people might have installed MEr-ready branch first, |
|
58 | - * and then this one, in which case we still want to perform this migration, |
|
59 | - * even though the version might not have increased |
|
60 | - * |
|
61 | - * @param array $version_array |
|
62 | - * @return bool |
|
63 | - */ |
|
64 | - public function can_migrate_from_version($version_array) |
|
65 | - { |
|
66 | - $version_string = $version_array['Core']; |
|
67 | - if ( |
|
68 | - version_compare($version_string, '4.8.0.decaf', '<') && |
|
69 | - version_compare($version_string, '4.7.0.decaf', '>=') |
|
70 | - ) { |
|
71 | - // echo "$version_string can be migrated from"; |
|
72 | - return true; |
|
73 | - } elseif (! $version_string) { |
|
74 | - // echo "no version string provided: $version_string"; |
|
75 | - // no version string provided... this must be pre 4.3 |
|
76 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
77 | - } else { |
|
78 | - // echo "$version_string doesnt apply"; |
|
79 | - return false; |
|
80 | - } |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * @return bool |
|
86 | - * @throws EE_Error |
|
87 | - * @throws ReflectionException |
|
88 | - */ |
|
89 | - public function schema_changes_before_migration() |
|
90 | - { |
|
91 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
92 | - $now_in_mysql = current_time('mysql', true); |
|
93 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
94 | - |
|
95 | - $table_name = 'esp_answer'; |
|
96 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
37 | + /** |
|
38 | + * return EE_DMS_Core_4_8_0 |
|
39 | + * |
|
40 | + * @param TableManager|null $table_manager |
|
41 | + * @param TableAnalysis|null $table_analysis |
|
42 | + */ |
|
43 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
44 | + { |
|
45 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.8.0", "event_espresso"); |
|
46 | + $this->_priority = 10; |
|
47 | + $this->_migration_stages = [ |
|
48 | + new EE_DMS_4_8_0_pretax_totals(), |
|
49 | + new EE_DMS_4_8_0_event_subtotals(), |
|
50 | + ]; |
|
51 | + parent::__construct($table_manager, $table_analysis); |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * Because this is being done at basically the same time as the MER-ready branch |
|
57 | + * of core, it's possible people might have installed MEr-ready branch first, |
|
58 | + * and then this one, in which case we still want to perform this migration, |
|
59 | + * even though the version might not have increased |
|
60 | + * |
|
61 | + * @param array $version_array |
|
62 | + * @return bool |
|
63 | + */ |
|
64 | + public function can_migrate_from_version($version_array) |
|
65 | + { |
|
66 | + $version_string = $version_array['Core']; |
|
67 | + if ( |
|
68 | + version_compare($version_string, '4.8.0.decaf', '<') && |
|
69 | + version_compare($version_string, '4.7.0.decaf', '>=') |
|
70 | + ) { |
|
71 | + // echo "$version_string can be migrated from"; |
|
72 | + return true; |
|
73 | + } elseif (! $version_string) { |
|
74 | + // echo "no version string provided: $version_string"; |
|
75 | + // no version string provided... this must be pre 4.3 |
|
76 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
77 | + } else { |
|
78 | + // echo "$version_string doesnt apply"; |
|
79 | + return false; |
|
80 | + } |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * @return bool |
|
86 | + * @throws EE_Error |
|
87 | + * @throws ReflectionException |
|
88 | + */ |
|
89 | + public function schema_changes_before_migration() |
|
90 | + { |
|
91 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
92 | + $now_in_mysql = current_time('mysql', true); |
|
93 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
94 | + |
|
95 | + $table_name = 'esp_answer'; |
|
96 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
97 | 97 | REG_ID int(10) unsigned NOT NULL, |
98 | 98 | QST_ID int(10) unsigned NOT NULL, |
99 | 99 | ANS_value text NOT NULL, |
100 | 100 | PRIMARY KEY (ANS_ID), |
101 | 101 | KEY REG_ID (REG_ID), |
102 | 102 | KEY QST_ID (QST_ID)"; |
103 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
103 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
104 | 104 | |
105 | - $table_name = 'esp_attendee_meta'; |
|
106 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
105 | + $table_name = 'esp_attendee_meta'; |
|
106 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
107 | 107 | ATT_ID bigint(20) unsigned NOT NULL, |
108 | 108 | ATT_fname varchar(45) NOT NULL, |
109 | 109 | ATT_lname varchar(45) NOT NULL, |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | PRIMARY KEY (ATTM_ID), |
119 | 119 | KEY ATT_ID (ATT_ID), |
120 | 120 | KEY ATT_email (ATT_email(191))"; |
121 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
121 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
122 | 122 | |
123 | - $table_name = 'esp_country'; |
|
124 | - $sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL, |
|
123 | + $table_name = 'esp_country'; |
|
124 | + $sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL, |
|
125 | 125 | CNT_ISO3 varchar(3) collate utf8_bin NOT NULL, |
126 | 126 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
127 | 127 | CNT_name varchar(45) collate utf8_bin NOT NULL, |
@@ -137,20 +137,20 @@ discard block |
||
137 | 137 | CNT_is_EU tinyint(1) DEFAULT '0', |
138 | 138 | CNT_active tinyint(1) DEFAULT '0', |
139 | 139 | PRIMARY KEY (CNT_ISO)"; |
140 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
140 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
141 | 141 | |
142 | - $table_name = 'esp_currency'; |
|
143 | - $sql = "CUR_code varchar(6) collate utf8_bin NOT NULL, |
|
142 | + $table_name = 'esp_currency'; |
|
143 | + $sql = "CUR_code varchar(6) collate utf8_bin NOT NULL, |
|
144 | 144 | CUR_single varchar(45) collate utf8_bin DEFAULT 'dollar', |
145 | 145 | CUR_plural varchar(45) collate utf8_bin DEFAULT 'dollars', |
146 | 146 | CUR_sign varchar(45) collate utf8_bin DEFAULT '$', |
147 | 147 | CUR_dec_plc varchar(1) collate utf8_bin NOT NULL DEFAULT '2', |
148 | 148 | CUR_active tinyint(1) DEFAULT '0', |
149 | 149 | PRIMARY KEY (CUR_code)"; |
150 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
150 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
151 | 151 | |
152 | - $table_name = 'esp_datetime'; |
|
153 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
152 | + $table_name = 'esp_datetime'; |
|
153 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
154 | 154 | EVT_ID bigint(20) unsigned NOT NULL, |
155 | 155 | DTT_name varchar(255) NOT NULL DEFAULT '', |
156 | 156 | DTT_description text NOT NULL, |
@@ -166,10 +166,10 @@ discard block |
||
166 | 166 | KEY DTT_EVT_start (DTT_EVT_start), |
167 | 167 | KEY EVT_ID (EVT_ID), |
168 | 168 | KEY DTT_is_primary (DTT_is_primary)"; |
169 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
169 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
170 | 170 | |
171 | - $table_name = 'esp_event_meta'; |
|
172 | - $sql = " |
|
171 | + $table_name = 'esp_event_meta'; |
|
172 | + $sql = " |
|
173 | 173 | EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
174 | 174 | EVT_ID bigint(20) unsigned NOT NULL, |
175 | 175 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -185,38 +185,38 @@ discard block |
||
185 | 185 | EVT_donations tinyint(1) NULL, |
186 | 186 | PRIMARY KEY (EVTM_ID), |
187 | 187 | KEY EVT_ID (EVT_ID)"; |
188 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
188 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
189 | 189 | |
190 | - $table_name = 'esp_event_question_group'; |
|
191 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
190 | + $table_name = 'esp_event_question_group'; |
|
191 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
192 | 192 | EVT_ID bigint(20) unsigned NOT NULL, |
193 | 193 | QSG_ID int(10) unsigned NOT NULL, |
194 | 194 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
195 | 195 | PRIMARY KEY (EQG_ID), |
196 | 196 | KEY EVT_ID (EVT_ID), |
197 | 197 | KEY QSG_ID (QSG_ID)"; |
198 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
198 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
199 | 199 | |
200 | - $table_name = 'esp_event_venue'; |
|
201 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
200 | + $table_name = 'esp_event_venue'; |
|
201 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
202 | 202 | EVT_ID bigint(20) unsigned NOT NULL, |
203 | 203 | VNU_ID bigint(20) unsigned NOT NULL, |
204 | 204 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
205 | 205 | PRIMARY KEY (EVV_ID)"; |
206 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
206 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
207 | 207 | |
208 | - $table_name = 'esp_extra_meta'; |
|
209 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
208 | + $table_name = 'esp_extra_meta'; |
|
209 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
210 | 210 | OBJ_ID int(11) DEFAULT NULL, |
211 | 211 | EXM_type varchar(45) DEFAULT NULL, |
212 | 212 | EXM_key varchar(45) DEFAULT NULL, |
213 | 213 | EXM_value text, |
214 | 214 | PRIMARY KEY (EXM_ID), |
215 | 215 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
216 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
216 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
217 | 217 | |
218 | - $table_name = 'esp_extra_join'; |
|
219 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
218 | + $table_name = 'esp_extra_join'; |
|
219 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
220 | 220 | EXJ_first_model_id varchar(6) NOT NULL, |
221 | 221 | EXJ_first_model_name varchar(20) NOT NULL, |
222 | 222 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -224,10 +224,10 @@ discard block |
||
224 | 224 | PRIMARY KEY (EXJ_ID), |
225 | 225 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
226 | 226 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
227 | - $this->_table_is_new_in_this_version($table_name, $sql); |
|
227 | + $this->_table_is_new_in_this_version($table_name, $sql); |
|
228 | 228 | |
229 | - $table_name = 'esp_line_item'; |
|
230 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
229 | + $table_name = 'esp_line_item'; |
|
230 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
231 | 231 | LIN_code varchar(245) NOT NULL DEFAULT '', |
232 | 232 | TXN_ID int(11) DEFAULT NULL, |
233 | 233 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -246,10 +246,10 @@ discard block |
||
246 | 246 | PRIMARY KEY (LIN_ID), |
247 | 247 | KEY LIN_code (LIN_code(191)), |
248 | 248 | KEY TXN_ID (TXN_ID)"; |
249 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
249 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
250 | 250 | |
251 | - $table_name = 'esp_log'; |
|
252 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
251 | + $table_name = 'esp_log'; |
|
252 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
253 | 253 | LOG_time datetime DEFAULT NULL, |
254 | 254 | OBJ_ID varchar(45) DEFAULT NULL, |
255 | 255 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -260,20 +260,20 @@ discard block |
||
260 | 260 | KEY LOG_time (LOG_time), |
261 | 261 | KEY OBJ (OBJ_type,OBJ_ID), |
262 | 262 | KEY LOG_type (LOG_type)"; |
263 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
263 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
264 | 264 | |
265 | - $table_name = 'esp_message_template'; |
|
266 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
265 | + $table_name = 'esp_message_template'; |
|
266 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
267 | 267 | GRP_ID int(10) unsigned NOT NULL, |
268 | 268 | MTP_context varchar(50) NOT NULL, |
269 | 269 | MTP_template_field varchar(30) NOT NULL, |
270 | 270 | MTP_content text NOT NULL, |
271 | 271 | PRIMARY KEY (MTP_ID), |
272 | 272 | KEY GRP_ID (GRP_ID)"; |
273 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
273 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
274 | 274 | |
275 | - $table_name = 'esp_message_template_group'; |
|
276 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
275 | + $table_name = 'esp_message_template_group'; |
|
276 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
277 | 277 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
278 | 278 | MTP_name varchar(245) NOT NULL DEFAULT '', |
279 | 279 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -285,19 +285,19 @@ discard block |
||
285 | 285 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
286 | 286 | PRIMARY KEY (GRP_ID), |
287 | 287 | KEY MTP_user_id (MTP_user_id)"; |
288 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
288 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
289 | 289 | |
290 | - $table_name = 'esp_event_message_template'; |
|
291 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
290 | + $table_name = 'esp_event_message_template'; |
|
291 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
292 | 292 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
293 | 293 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
294 | 294 | PRIMARY KEY (EMT_ID), |
295 | 295 | KEY EVT_ID (EVT_ID), |
296 | 296 | KEY GRP_ID (GRP_ID)"; |
297 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
297 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
298 | 298 | |
299 | - $table_name = 'esp_payment'; |
|
300 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
299 | + $table_name = 'esp_payment'; |
|
300 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
301 | 301 | TXN_ID int(10) unsigned DEFAULT NULL, |
302 | 302 | STS_ID varchar(3) collate utf8_bin DEFAULT NULL, |
303 | 303 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -314,10 +314,10 @@ discard block |
||
314 | 314 | PRIMARY KEY (PAY_ID), |
315 | 315 | KEY PAY_timestamp (PAY_timestamp), |
316 | 316 | KEY TXN_ID (TXN_ID)"; |
317 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
317 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
318 | 318 | |
319 | - $table_name = 'esp_payment_method'; |
|
320 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
319 | + $table_name = 'esp_payment_method'; |
|
320 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
321 | 321 | PMD_type varchar(124) DEFAULT NULL, |
322 | 322 | PMD_name varchar(255) DEFAULT NULL, |
323 | 323 | PMD_desc text, |
@@ -333,36 +333,36 @@ discard block |
||
333 | 333 | PRIMARY KEY (PMD_ID), |
334 | 334 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
335 | 335 | KEY PMD_type (PMD_type)"; |
336 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
336 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
337 | 337 | |
338 | - $table_name = "esp_ticket_price"; |
|
339 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
338 | + $table_name = "esp_ticket_price"; |
|
339 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
340 | 340 | TKT_ID int(10) unsigned NOT NULL, |
341 | 341 | PRC_ID int(10) unsigned NOT NULL, |
342 | 342 | PRIMARY KEY (TKP_ID), |
343 | 343 | KEY TKT_ID (TKT_ID), |
344 | 344 | KEY PRC_ID (PRC_ID)"; |
345 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
345 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
346 | 346 | |
347 | - $table_name = "esp_datetime_ticket"; |
|
348 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
347 | + $table_name = "esp_datetime_ticket"; |
|
348 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
349 | 349 | DTT_ID int(10) unsigned NOT NULL, |
350 | 350 | TKT_ID int(10) unsigned NOT NULL, |
351 | 351 | PRIMARY KEY (DTK_ID), |
352 | 352 | KEY DTT_ID (DTT_ID), |
353 | 353 | KEY TKT_ID (TKT_ID)"; |
354 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
354 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
355 | 355 | |
356 | - $table_name = "esp_ticket_template"; |
|
357 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
356 | + $table_name = "esp_ticket_template"; |
|
357 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
358 | 358 | TTM_name varchar(45) NOT NULL, |
359 | 359 | TTM_description text, |
360 | 360 | TTM_file varchar(45), |
361 | 361 | PRIMARY KEY (TTM_ID)"; |
362 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
362 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
363 | 363 | |
364 | - $table_name = 'esp_question'; |
|
365 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
364 | + $table_name = 'esp_question'; |
|
365 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
366 | 366 | QST_display_text text NOT NULL, |
367 | 367 | QST_admin_label varchar(255) NOT NULL, |
368 | 368 | QST_system varchar(25) NOT NULL DEFAULT "", |
@@ -376,20 +376,20 @@ discard block |
||
376 | 376 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
377 | 377 | PRIMARY KEY (QST_ID), |
378 | 378 | KEY QST_order (QST_order)'; |
379 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
379 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
380 | 380 | |
381 | - $table_name = 'esp_question_group_question'; |
|
382 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
381 | + $table_name = 'esp_question_group_question'; |
|
382 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
383 | 383 | QSG_ID int(10) unsigned NOT NULL, |
384 | 384 | QST_ID int(10) unsigned NOT NULL, |
385 | 385 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
386 | 386 | PRIMARY KEY (QGQ_ID), |
387 | 387 | KEY QST_ID (QST_ID), |
388 | 388 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
389 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
389 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
390 | 390 | |
391 | - $table_name = 'esp_question_option'; |
|
392 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
391 | + $table_name = 'esp_question_option'; |
|
392 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
393 | 393 | QSO_value varchar(255) NOT NULL, |
394 | 394 | QSO_desc text NOT NULL, |
395 | 395 | QST_ID int(10) unsigned NOT NULL, |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | PRIMARY KEY (QSO_ID), |
400 | 400 | KEY QST_ID (QST_ID), |
401 | 401 | KEY QSO_order (QSO_order)"; |
402 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
402 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
403 | 403 | |
404 | - $table_name = 'esp_registration'; |
|
405 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
404 | + $table_name = 'esp_registration'; |
|
405 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
406 | 406 | EVT_ID bigint(20) unsigned NOT NULL, |
407 | 407 | ATT_ID bigint(20) unsigned NOT NULL, |
408 | 408 | TXN_ID int(10) unsigned NOT NULL, |
@@ -426,20 +426,20 @@ discard block |
||
426 | 426 | KEY TKT_ID (TKT_ID), |
427 | 427 | KEY EVT_ID (EVT_ID), |
428 | 428 | KEY STS_ID (STS_ID)"; |
429 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
429 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
430 | 430 | |
431 | - $table_name = 'esp_registration_payment'; |
|
432 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
431 | + $table_name = 'esp_registration_payment'; |
|
432 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
433 | 433 | REG_ID int(10) unsigned NOT NULL, |
434 | 434 | PAY_ID int(10) unsigned NULL, |
435 | 435 | RPY_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
436 | 436 | PRIMARY KEY (RPY_ID), |
437 | 437 | KEY REG_ID (REG_ID), |
438 | 438 | KEY PAY_ID (PAY_ID)"; |
439 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
439 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
440 | 440 | |
441 | - $table_name = 'esp_checkin'; |
|
442 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
441 | + $table_name = 'esp_checkin'; |
|
442 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
443 | 443 | REG_ID int(10) unsigned NOT NULL, |
444 | 444 | DTT_ID int(10) unsigned NOT NULL, |
445 | 445 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -447,10 +447,10 @@ discard block |
||
447 | 447 | PRIMARY KEY (CHK_ID), |
448 | 448 | KEY REG_ID (REG_ID), |
449 | 449 | KEY DTT_ID (DTT_ID)"; |
450 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
450 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
451 | 451 | |
452 | - $table_name = 'esp_state'; |
|
453 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
452 | + $table_name = 'esp_state'; |
|
453 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
454 | 454 | CNT_ISO varchar(2) collate utf8_bin NOT NULL, |
455 | 455 | STA_abbrev varchar(24) collate utf8_bin NOT NULL, |
456 | 456 | STA_name varchar(100) collate utf8_bin NOT NULL, |
@@ -458,10 +458,10 @@ discard block |
||
458 | 458 | PRIMARY KEY (STA_ID), |
459 | 459 | KEY STA_abbrev (STA_abbrev), |
460 | 460 | KEY CNT_ISO (CNT_ISO)"; |
461 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
461 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
462 | 462 | |
463 | - $table_name = 'esp_status'; |
|
464 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
463 | + $table_name = 'esp_status'; |
|
464 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
465 | 465 | STS_code varchar(45) NOT NULL, |
466 | 466 | STS_type varchar(45) NOT NULL, |
467 | 467 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -469,10 +469,10 @@ discard block |
||
469 | 469 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
470 | 470 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
471 | 471 | KEY STS_type (STS_type)"; |
472 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
472 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
473 | 473 | |
474 | - $table_name = 'esp_transaction'; |
|
475 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
474 | + $table_name = 'esp_transaction'; |
|
475 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
476 | 476 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
477 | 477 | TXN_total decimal(10,3) DEFAULT '0.00', |
478 | 478 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -484,10 +484,10 @@ discard block |
||
484 | 484 | PRIMARY KEY (TXN_ID), |
485 | 485 | KEY TXN_timestamp (TXN_timestamp), |
486 | 486 | KEY STS_ID (STS_ID)"; |
487 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
487 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
488 | 488 | |
489 | - $table_name = 'esp_venue_meta'; |
|
490 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
489 | + $table_name = 'esp_venue_meta'; |
|
490 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
491 | 491 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
492 | 492 | VNU_address varchar(255) DEFAULT NULL, |
493 | 493 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -506,10 +506,10 @@ discard block |
||
506 | 506 | KEY VNU_ID (VNU_ID), |
507 | 507 | KEY STA_ID (STA_ID), |
508 | 508 | KEY CNT_ISO (CNT_ISO)"; |
509 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
510 | - // modified tables |
|
511 | - $table_name = "esp_price"; |
|
512 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
509 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
510 | + // modified tables |
|
511 | + $table_name = "esp_price"; |
|
512 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
513 | 513 | PRT_ID tinyint(3) unsigned NOT NULL, |
514 | 514 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
515 | 515 | PRC_name varchar(245) NOT NULL, |
@@ -522,10 +522,10 @@ discard block |
||
522 | 522 | PRC_parent int(10) unsigned DEFAULT 0, |
523 | 523 | PRIMARY KEY (PRC_ID), |
524 | 524 | KEY PRT_ID (PRT_ID)"; |
525 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
525 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
526 | 526 | |
527 | - $table_name = "esp_price_type"; |
|
528 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
527 | + $table_name = "esp_price_type"; |
|
528 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
529 | 529 | PRT_name varchar(45) NOT NULL, |
530 | 530 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
531 | 531 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -534,10 +534,10 @@ discard block |
||
534 | 534 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
535 | 535 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
536 | 536 | PRIMARY KEY (PRT_ID)"; |
537 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
537 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
538 | 538 | |
539 | - $table_name = "esp_ticket"; |
|
540 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
539 | + $table_name = "esp_ticket"; |
|
540 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
541 | 541 | TTM_ID int(10) unsigned NOT NULL, |
542 | 542 | TKT_name varchar(245) NOT NULL DEFAULT '', |
543 | 543 | TKT_description text NOT NULL, |
@@ -559,10 +559,10 @@ discard block |
||
559 | 559 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
560 | 560 | PRIMARY KEY (TKT_ID), |
561 | 561 | KEY TKT_start_date (TKT_start_date)"; |
562 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
562 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
563 | 563 | |
564 | - $table_name = 'esp_question_group'; |
|
565 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
564 | + $table_name = 'esp_question_group'; |
|
565 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
566 | 566 | QSG_name varchar(255) NOT NULL, |
567 | 567 | QSG_identifier varchar(100) NOT NULL, |
568 | 568 | QSG_desc text NULL, |
@@ -575,225 +575,225 @@ discard block |
||
575 | 575 | PRIMARY KEY (QSG_ID), |
576 | 576 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
577 | 577 | KEY QSG_order (QSG_order)'; |
578 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
579 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
580 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
581 | - // (because many need to convert old string states to foreign keys into the states table) |
|
582 | - $script_4_1_defaults->insert_default_states(); |
|
583 | - $script_4_1_defaults->insert_default_countries(); |
|
584 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
585 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
586 | - $script_4_5_defaults->insert_default_price_types(); |
|
587 | - $script_4_5_defaults->insert_default_prices(); |
|
588 | - $script_4_5_defaults->insert_default_tickets(); |
|
589 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
590 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
591 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
592 | - $script_4_6_defaults->insert_default_currencies(); |
|
593 | - $this->verify_new_countries(); |
|
594 | - $this->verify_new_currencies(); |
|
595 | - return true; |
|
596 | - } |
|
597 | - |
|
598 | - |
|
599 | - /** |
|
600 | - * @return boolean |
|
601 | - * @throws EE_Error |
|
602 | - * @throws ReflectionException |
|
603 | - */ |
|
604 | - public function schema_changes_after_migration() |
|
605 | - { |
|
606 | - $this->fix_non_default_taxes(); |
|
607 | - // this is actually the same as the last DMS |
|
608 | - /** @var EE_DMS_Core_4_7_0 $script_4_7_defaults */ |
|
609 | - $script_4_7_defaults = EE_Registry::instance()->load_dms('Core_4_7_0'); |
|
610 | - return $script_4_7_defaults->schema_changes_after_migration(); |
|
611 | - } |
|
612 | - |
|
613 | - |
|
614 | - public function migration_page_hooks() |
|
615 | - { |
|
616 | - } |
|
617 | - |
|
618 | - |
|
619 | - /** |
|
620 | - * verifies each of the new countries exists that somehow we missed in 4.1 |
|
621 | - * |
|
622 | - * @throws EE_Error |
|
623 | - */ |
|
624 | - public function verify_new_countries() |
|
625 | - { |
|
626 | - // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028 |
|
627 | - // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217 |
|
628 | - // currency symbols: http://www.xe.com/symbols.php |
|
629 | - // CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active |
|
630 | - // ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0), |
|
631 | - $newer_countries = [ |
|
632 | - ['AX', 'ALA', 0, 'Åland Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0], |
|
633 | - ['BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0], |
|
634 | - ['CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0], |
|
635 | - ['GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0], |
|
636 | - ['IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0], |
|
637 | - ['JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0], |
|
638 | - ['MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0], |
|
639 | - ['ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0], |
|
640 | - ['RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0], |
|
641 | - ['SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0], |
|
642 | - ['SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0], |
|
643 | - ['XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0], |
|
644 | - ['YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0], |
|
645 | - [ |
|
646 | - 'BQ', |
|
647 | - 'BES', |
|
648 | - 0, |
|
649 | - 'Bonaire, Saint Eustatius and Saba', |
|
650 | - 'USD', |
|
651 | - 'Dollar', |
|
652 | - 'Dollars', |
|
653 | - '$', |
|
654 | - 1, |
|
655 | - 2, |
|
656 | - '+599', |
|
657 | - 0, |
|
658 | - 0, |
|
659 | - ], |
|
660 | - ['BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1, 2, '+47', 0, 0], |
|
661 | - ['IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+246', 0, 0], |
|
662 | - ['CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+61', 0, 0], |
|
663 | - ['CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0], |
|
664 | - [ |
|
665 | - 'HM', |
|
666 | - 'HMD', |
|
667 | - 0, |
|
668 | - 'Heard Island and McDonald Islands', |
|
669 | - 'AUD', |
|
670 | - 'Dollar', |
|
671 | - 'Dollars', |
|
672 | - '$', |
|
673 | - 1, |
|
674 | - 2, |
|
675 | - '+891', |
|
676 | - 0, |
|
677 | - 0, |
|
678 | - ], |
|
679 | - ['PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1, 2, '+970', 0, 0], |
|
680 | - [ |
|
681 | - 'GS', |
|
682 | - 'SGS', |
|
683 | - 0, |
|
684 | - 'South Georgia and the South Sandwich Islands', |
|
685 | - 'GBP', |
|
686 | - 'Pound', |
|
687 | - 'Pounds', |
|
688 | - '£', |
|
689 | - 1, |
|
690 | - 2, |
|
691 | - '+500', |
|
692 | - 0, |
|
693 | - 0, |
|
694 | - ], |
|
695 | - ['TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+670', 0, 0], |
|
696 | - ['TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+262', 0, 0], |
|
697 | - [ |
|
698 | - 'UM', |
|
699 | - 'UMI', |
|
700 | - 0, |
|
701 | - 'United States Minor Outlying Islands', |
|
702 | - 'USD', |
|
703 | - 'Dollar', |
|
704 | - 'Dollars', |
|
705 | - '$', |
|
706 | - 1, |
|
707 | - 2, |
|
708 | - '+1', |
|
709 | - 0, |
|
710 | - 0, |
|
711 | - ], |
|
712 | - ]; |
|
713 | - global $wpdb; |
|
714 | - $country_table = $wpdb->prefix . "esp_country"; |
|
715 | - $country_format = [ |
|
716 | - "CNT_ISO" => '%s', |
|
717 | - "CNT_ISO3" => '%s', |
|
718 | - "RGN_ID" => '%d', |
|
719 | - "CNT_name" => '%s', |
|
720 | - "CNT_cur_code" => '%s', |
|
721 | - "CNT_cur_single" => '%s', |
|
722 | - "CNT_cur_plural" => '%s', |
|
723 | - "CNT_cur_sign" => '%s', |
|
724 | - "CNT_cur_sign_b4" => '%d', |
|
725 | - "CNT_cur_dec_plc" => '%d', |
|
726 | - "CNT_tel_code" => '%s', |
|
727 | - "CNT_is_EU" => '%d', |
|
728 | - "CNT_active" => '%d', |
|
729 | - ]; |
|
730 | - if ($this->_get_table_analysis()->tableExists($country_table)) { |
|
731 | - foreach ($newer_countries as $country) { |
|
732 | - $SQL = "SELECT COUNT('CNT_ISO') FROM $country_table WHERE CNT_ISO='$country[0]' LIMIT 1"; |
|
733 | - $countries = $wpdb->get_var($SQL); |
|
734 | - if (! $countries) { |
|
735 | - $wpdb->insert( |
|
736 | - $country_table, |
|
737 | - array_combine(array_keys($country_format), $country), |
|
738 | - $country_format |
|
739 | - ); |
|
740 | - } |
|
741 | - } |
|
742 | - } |
|
743 | - } |
|
744 | - |
|
745 | - |
|
746 | - /** |
|
747 | - * verifies each of the new currencies exists that somehow we missed in 4.6 |
|
748 | - * |
|
749 | - * @throws EE_Error |
|
750 | - */ |
|
751 | - public function verify_new_currencies() |
|
752 | - { |
|
753 | - // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028 |
|
754 | - // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217 |
|
755 | - // currency symbols: http://www.xe.com/symbols.php |
|
756 | - // CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active |
|
757 | - // ( 'EUR', 'Euro', 'Euros', '€', 2,1), |
|
758 | - $newer_currencies = [ |
|
759 | - ['RSD', 'Dinar', 'Dinars', '', 3, 1], |
|
760 | - ]; |
|
761 | - global $wpdb; |
|
762 | - $currency_table = $wpdb->prefix . "esp_currency"; |
|
763 | - $currency_format = [ |
|
764 | - "CUR_code" => '%s', |
|
765 | - "CUR_single" => '%s', |
|
766 | - "CUR_plural" => '%s', |
|
767 | - "CUR_sign" => '%s', |
|
768 | - "CUR_dec_plc" => '%d', |
|
769 | - "CUR_active" => '%d', |
|
770 | - ]; |
|
771 | - if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
772 | - foreach ($newer_currencies as $currency) { |
|
773 | - $SQL = "SELECT COUNT('CUR_code') FROM $currency_table WHERE CUR_code='$currency[0]' LIMIT 1"; |
|
774 | - $countries = $wpdb->get_var($SQL); |
|
775 | - if (! $countries) { |
|
776 | - $wpdb->insert( |
|
777 | - $currency_table, |
|
778 | - array_combine(array_keys($currency_format), $currency), |
|
779 | - $currency_format |
|
780 | - ); |
|
781 | - } |
|
782 | - } |
|
783 | - } |
|
784 | - } |
|
785 | - |
|
786 | - |
|
787 | - /** |
|
788 | - * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731 |
|
789 | - * which should just be a temporary issue for folks who installed 4.8.0-4.8.5; |
|
790 | - * we should be able to stop doing this in 4.9 |
|
791 | - */ |
|
792 | - public function fix_non_default_taxes() |
|
793 | - { |
|
794 | - global $wpdb; |
|
795 | - $query = $wpdb->prepare( |
|
796 | - "UPDATE |
|
578 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
579 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
580 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
581 | + // (because many need to convert old string states to foreign keys into the states table) |
|
582 | + $script_4_1_defaults->insert_default_states(); |
|
583 | + $script_4_1_defaults->insert_default_countries(); |
|
584 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
585 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
586 | + $script_4_5_defaults->insert_default_price_types(); |
|
587 | + $script_4_5_defaults->insert_default_prices(); |
|
588 | + $script_4_5_defaults->insert_default_tickets(); |
|
589 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
590 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
591 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
592 | + $script_4_6_defaults->insert_default_currencies(); |
|
593 | + $this->verify_new_countries(); |
|
594 | + $this->verify_new_currencies(); |
|
595 | + return true; |
|
596 | + } |
|
597 | + |
|
598 | + |
|
599 | + /** |
|
600 | + * @return boolean |
|
601 | + * @throws EE_Error |
|
602 | + * @throws ReflectionException |
|
603 | + */ |
|
604 | + public function schema_changes_after_migration() |
|
605 | + { |
|
606 | + $this->fix_non_default_taxes(); |
|
607 | + // this is actually the same as the last DMS |
|
608 | + /** @var EE_DMS_Core_4_7_0 $script_4_7_defaults */ |
|
609 | + $script_4_7_defaults = EE_Registry::instance()->load_dms('Core_4_7_0'); |
|
610 | + return $script_4_7_defaults->schema_changes_after_migration(); |
|
611 | + } |
|
612 | + |
|
613 | + |
|
614 | + public function migration_page_hooks() |
|
615 | + { |
|
616 | + } |
|
617 | + |
|
618 | + |
|
619 | + /** |
|
620 | + * verifies each of the new countries exists that somehow we missed in 4.1 |
|
621 | + * |
|
622 | + * @throws EE_Error |
|
623 | + */ |
|
624 | + public function verify_new_countries() |
|
625 | + { |
|
626 | + // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028 |
|
627 | + // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217 |
|
628 | + // currency symbols: http://www.xe.com/symbols.php |
|
629 | + // CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active |
|
630 | + // ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0), |
|
631 | + $newer_countries = [ |
|
632 | + ['AX', 'ALA', 0, 'Åland Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0], |
|
633 | + ['BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0], |
|
634 | + ['CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0], |
|
635 | + ['GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0], |
|
636 | + ['IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0], |
|
637 | + ['JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0], |
|
638 | + ['MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0], |
|
639 | + ['ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0], |
|
640 | + ['RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0], |
|
641 | + ['SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0], |
|
642 | + ['SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0], |
|
643 | + ['XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0], |
|
644 | + ['YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0], |
|
645 | + [ |
|
646 | + 'BQ', |
|
647 | + 'BES', |
|
648 | + 0, |
|
649 | + 'Bonaire, Saint Eustatius and Saba', |
|
650 | + 'USD', |
|
651 | + 'Dollar', |
|
652 | + 'Dollars', |
|
653 | + '$', |
|
654 | + 1, |
|
655 | + 2, |
|
656 | + '+599', |
|
657 | + 0, |
|
658 | + 0, |
|
659 | + ], |
|
660 | + ['BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1, 2, '+47', 0, 0], |
|
661 | + ['IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+246', 0, 0], |
|
662 | + ['CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+61', 0, 0], |
|
663 | + ['CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0], |
|
664 | + [ |
|
665 | + 'HM', |
|
666 | + 'HMD', |
|
667 | + 0, |
|
668 | + 'Heard Island and McDonald Islands', |
|
669 | + 'AUD', |
|
670 | + 'Dollar', |
|
671 | + 'Dollars', |
|
672 | + '$', |
|
673 | + 1, |
|
674 | + 2, |
|
675 | + '+891', |
|
676 | + 0, |
|
677 | + 0, |
|
678 | + ], |
|
679 | + ['PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1, 2, '+970', 0, 0], |
|
680 | + [ |
|
681 | + 'GS', |
|
682 | + 'SGS', |
|
683 | + 0, |
|
684 | + 'South Georgia and the South Sandwich Islands', |
|
685 | + 'GBP', |
|
686 | + 'Pound', |
|
687 | + 'Pounds', |
|
688 | + '£', |
|
689 | + 1, |
|
690 | + 2, |
|
691 | + '+500', |
|
692 | + 0, |
|
693 | + 0, |
|
694 | + ], |
|
695 | + ['TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+670', 0, 0], |
|
696 | + ['TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+262', 0, 0], |
|
697 | + [ |
|
698 | + 'UM', |
|
699 | + 'UMI', |
|
700 | + 0, |
|
701 | + 'United States Minor Outlying Islands', |
|
702 | + 'USD', |
|
703 | + 'Dollar', |
|
704 | + 'Dollars', |
|
705 | + '$', |
|
706 | + 1, |
|
707 | + 2, |
|
708 | + '+1', |
|
709 | + 0, |
|
710 | + 0, |
|
711 | + ], |
|
712 | + ]; |
|
713 | + global $wpdb; |
|
714 | + $country_table = $wpdb->prefix . "esp_country"; |
|
715 | + $country_format = [ |
|
716 | + "CNT_ISO" => '%s', |
|
717 | + "CNT_ISO3" => '%s', |
|
718 | + "RGN_ID" => '%d', |
|
719 | + "CNT_name" => '%s', |
|
720 | + "CNT_cur_code" => '%s', |
|
721 | + "CNT_cur_single" => '%s', |
|
722 | + "CNT_cur_plural" => '%s', |
|
723 | + "CNT_cur_sign" => '%s', |
|
724 | + "CNT_cur_sign_b4" => '%d', |
|
725 | + "CNT_cur_dec_plc" => '%d', |
|
726 | + "CNT_tel_code" => '%s', |
|
727 | + "CNT_is_EU" => '%d', |
|
728 | + "CNT_active" => '%d', |
|
729 | + ]; |
|
730 | + if ($this->_get_table_analysis()->tableExists($country_table)) { |
|
731 | + foreach ($newer_countries as $country) { |
|
732 | + $SQL = "SELECT COUNT('CNT_ISO') FROM $country_table WHERE CNT_ISO='$country[0]' LIMIT 1"; |
|
733 | + $countries = $wpdb->get_var($SQL); |
|
734 | + if (! $countries) { |
|
735 | + $wpdb->insert( |
|
736 | + $country_table, |
|
737 | + array_combine(array_keys($country_format), $country), |
|
738 | + $country_format |
|
739 | + ); |
|
740 | + } |
|
741 | + } |
|
742 | + } |
|
743 | + } |
|
744 | + |
|
745 | + |
|
746 | + /** |
|
747 | + * verifies each of the new currencies exists that somehow we missed in 4.6 |
|
748 | + * |
|
749 | + * @throws EE_Error |
|
750 | + */ |
|
751 | + public function verify_new_currencies() |
|
752 | + { |
|
753 | + // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028 |
|
754 | + // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217 |
|
755 | + // currency symbols: http://www.xe.com/symbols.php |
|
756 | + // CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active |
|
757 | + // ( 'EUR', 'Euro', 'Euros', '€', 2,1), |
|
758 | + $newer_currencies = [ |
|
759 | + ['RSD', 'Dinar', 'Dinars', '', 3, 1], |
|
760 | + ]; |
|
761 | + global $wpdb; |
|
762 | + $currency_table = $wpdb->prefix . "esp_currency"; |
|
763 | + $currency_format = [ |
|
764 | + "CUR_code" => '%s', |
|
765 | + "CUR_single" => '%s', |
|
766 | + "CUR_plural" => '%s', |
|
767 | + "CUR_sign" => '%s', |
|
768 | + "CUR_dec_plc" => '%d', |
|
769 | + "CUR_active" => '%d', |
|
770 | + ]; |
|
771 | + if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
772 | + foreach ($newer_currencies as $currency) { |
|
773 | + $SQL = "SELECT COUNT('CUR_code') FROM $currency_table WHERE CUR_code='$currency[0]' LIMIT 1"; |
|
774 | + $countries = $wpdb->get_var($SQL); |
|
775 | + if (! $countries) { |
|
776 | + $wpdb->insert( |
|
777 | + $currency_table, |
|
778 | + array_combine(array_keys($currency_format), $currency), |
|
779 | + $currency_format |
|
780 | + ); |
|
781 | + } |
|
782 | + } |
|
783 | + } |
|
784 | + } |
|
785 | + |
|
786 | + |
|
787 | + /** |
|
788 | + * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731 |
|
789 | + * which should just be a temporary issue for folks who installed 4.8.0-4.8.5; |
|
790 | + * we should be able to stop doing this in 4.9 |
|
791 | + */ |
|
792 | + public function fix_non_default_taxes() |
|
793 | + { |
|
794 | + global $wpdb; |
|
795 | + $query = $wpdb->prepare( |
|
796 | + "UPDATE |
|
797 | 797 | {$wpdb->prefix}esp_price p INNER JOIN |
798 | 798 | {$wpdb->prefix}esp_price_type pt ON p.PRT_ID = pt.PRT_ID |
799 | 799 | SET |
@@ -802,8 +802,8 @@ discard block |
||
802 | 802 | p.PRC_is_default = 0 AND |
803 | 803 | pt.PBT_ID = %d |
804 | 804 | ", |
805 | - EEM_Price_Type::base_type_tax |
|
806 | - ); |
|
807 | - $wpdb->query($query); |
|
808 | - } |
|
805 | + EEM_Price_Type::base_type_tax |
|
806 | + ); |
|
807 | + $wpdb->query($query); |
|
808 | + } |
|
809 | 809 | } |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | $stages = glob(EE_CORE . 'data_migration_scripts/4_6_0_stages/*'); |
11 | 11 | $class_to_filepath = []; |
12 | 12 | foreach ($stages as $filepath) { |
13 | - $matches = []; |
|
14 | - preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
15 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
13 | + $matches = []; |
|
14 | + preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
15 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
16 | 16 | } |
17 | 17 | // give addons a chance to autoload their stages too |
18 | 18 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages', $class_to_filepath); |
@@ -32,77 +32,77 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class EE_DMS_Core_4_6_0 extends EE_Data_Migration_Script_Base |
34 | 34 | { |
35 | - /** |
|
36 | - * return EE_DMS_Core_4_6_0 |
|
37 | - * |
|
38 | - * @param TableManager|null $table_manager |
|
39 | - * @param TableAnalysis|null $table_analysis |
|
40 | - */ |
|
41 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
42 | - { |
|
43 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.6.0", "event_espresso"); |
|
44 | - $this->_priority = 10; |
|
45 | - $this->_migration_stages = [ |
|
46 | - new EE_DMS_4_6_0_gateways(), |
|
47 | - new EE_DMS_4_6_0_question_types(), |
|
48 | - new EE_DMS_4_6_0_country_system_question(), |
|
49 | - new EE_DMS_4_6_0_state_system_question(), |
|
50 | - new EE_DMS_4_6_0_billing_info(), |
|
51 | - new EE_DMS_4_6_0_transactions(), |
|
52 | - new EE_DMS_4_6_0_payments(), |
|
53 | - new EE_DMS_4_6_0_invoice_settings(), |
|
54 | - ]; |
|
55 | - parent::__construct($table_manager, $table_analysis); |
|
56 | - } |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * @param array $version_array |
|
61 | - * @return bool |
|
62 | - */ |
|
63 | - public function can_migrate_from_version($version_array) |
|
64 | - { |
|
65 | - $version_string = $version_array['Core']; |
|
66 | - if ( |
|
67 | - version_compare($version_string, '4.6.0.decaf', '<') && version_compare( |
|
68 | - $version_string, |
|
69 | - '4.5.0.decaf', |
|
70 | - '>=' |
|
71 | - ) |
|
72 | - ) { |
|
73 | - // echo "$version_string can be migrated from"; |
|
74 | - return true; |
|
75 | - } elseif (! $version_string) { |
|
76 | - // echo "no version string provided: $version_string"; |
|
77 | - // no version string provided... this must be pre 4.3 |
|
78 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
79 | - } else { |
|
80 | - // echo "$version_string doesnt apply"; |
|
81 | - return false; |
|
82 | - } |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * @return bool |
|
88 | - * @throws EE_Error |
|
89 | - * @throws ReflectionException |
|
90 | - */ |
|
91 | - public function schema_changes_before_migration() |
|
92 | - { |
|
93 | - // relies on 4.1's EEH_Activation::create_table |
|
94 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
95 | - |
|
96 | - $table_name = 'esp_answer'; |
|
97 | - $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
35 | + /** |
|
36 | + * return EE_DMS_Core_4_6_0 |
|
37 | + * |
|
38 | + * @param TableManager|null $table_manager |
|
39 | + * @param TableAnalysis|null $table_analysis |
|
40 | + */ |
|
41 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
42 | + { |
|
43 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.6.0", "event_espresso"); |
|
44 | + $this->_priority = 10; |
|
45 | + $this->_migration_stages = [ |
|
46 | + new EE_DMS_4_6_0_gateways(), |
|
47 | + new EE_DMS_4_6_0_question_types(), |
|
48 | + new EE_DMS_4_6_0_country_system_question(), |
|
49 | + new EE_DMS_4_6_0_state_system_question(), |
|
50 | + new EE_DMS_4_6_0_billing_info(), |
|
51 | + new EE_DMS_4_6_0_transactions(), |
|
52 | + new EE_DMS_4_6_0_payments(), |
|
53 | + new EE_DMS_4_6_0_invoice_settings(), |
|
54 | + ]; |
|
55 | + parent::__construct($table_manager, $table_analysis); |
|
56 | + } |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * @param array $version_array |
|
61 | + * @return bool |
|
62 | + */ |
|
63 | + public function can_migrate_from_version($version_array) |
|
64 | + { |
|
65 | + $version_string = $version_array['Core']; |
|
66 | + if ( |
|
67 | + version_compare($version_string, '4.6.0.decaf', '<') && version_compare( |
|
68 | + $version_string, |
|
69 | + '4.5.0.decaf', |
|
70 | + '>=' |
|
71 | + ) |
|
72 | + ) { |
|
73 | + // echo "$version_string can be migrated from"; |
|
74 | + return true; |
|
75 | + } elseif (! $version_string) { |
|
76 | + // echo "no version string provided: $version_string"; |
|
77 | + // no version string provided... this must be pre 4.3 |
|
78 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
79 | + } else { |
|
80 | + // echo "$version_string doesnt apply"; |
|
81 | + return false; |
|
82 | + } |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * @return bool |
|
88 | + * @throws EE_Error |
|
89 | + * @throws ReflectionException |
|
90 | + */ |
|
91 | + public function schema_changes_before_migration() |
|
92 | + { |
|
93 | + // relies on 4.1's EEH_Activation::create_table |
|
94 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
95 | + |
|
96 | + $table_name = 'esp_answer'; |
|
97 | + $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
98 | 98 | REG_ID int(10) unsigned NOT NULL, |
99 | 99 | QST_ID int(10) unsigned NOT NULL, |
100 | 100 | ANS_value text NOT NULL, |
101 | 101 | PRIMARY KEY (ANS_ID)"; |
102 | - $this->_table_should_exist_previously($table_name, $sql); |
|
102 | + $this->_table_should_exist_previously($table_name, $sql); |
|
103 | 103 | |
104 | - $table_name = 'esp_attendee_meta'; |
|
105 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
104 | + $table_name = 'esp_attendee_meta'; |
|
105 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
106 | 106 | ATT_ID bigint(20) unsigned NOT NULL, |
107 | 107 | ATT_fname varchar(45) NOT NULL, |
108 | 108 | ATT_lname varchar(45) NOT NULL, |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | KEY ATT_fname (ATT_fname), |
119 | 119 | KEY ATT_lname (ATT_lname), |
120 | 120 | KEY ATT_email (ATT_email(191))"; |
121 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
121 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
122 | 122 | |
123 | - $table_name = 'esp_country'; |
|
124 | - $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
123 | + $table_name = 'esp_country'; |
|
124 | + $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
125 | 125 | CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL, |
126 | 126 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
127 | 127 | CNT_name varchar(45) COLLATE utf8_bin NOT NULL, |
@@ -137,20 +137,20 @@ discard block |
||
137 | 137 | CNT_is_EU tinyint(1) DEFAULT '0', |
138 | 138 | CNT_active tinyint(1) DEFAULT '0', |
139 | 139 | PRIMARY KEY (CNT_ISO)"; |
140 | - $this->_table_should_exist_previously($table_name, $sql); |
|
140 | + $this->_table_should_exist_previously($table_name, $sql); |
|
141 | 141 | |
142 | - $table_name = 'esp_currency'; |
|
143 | - $sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL, |
|
142 | + $table_name = 'esp_currency'; |
|
143 | + $sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL, |
|
144 | 144 | CUR_single varchar(45) COLLATE utf8_bin DEFAULT 'dollar', |
145 | 145 | CUR_plural varchar(45) COLLATE utf8_bin DEFAULT 'dollars', |
146 | 146 | CUR_sign varchar(45) COLLATE utf8_bin DEFAULT '$', |
147 | 147 | CUR_dec_plc varchar(1) COLLATE utf8_bin NOT NULL DEFAULT '2', |
148 | 148 | CUR_active tinyint(1) DEFAULT '0', |
149 | 149 | PRIMARY KEY (CUR_code)"; |
150 | - $this->_table_is_new_in_this_version($table_name, $sql); |
|
150 | + $this->_table_is_new_in_this_version($table_name, $sql); |
|
151 | 151 | |
152 | - $table_name = 'esp_datetime'; |
|
153 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
152 | + $table_name = 'esp_datetime'; |
|
153 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
154 | 154 | EVT_ID bigint(20) unsigned NOT NULL, |
155 | 155 | DTT_name varchar(255) NOT NULL DEFAULT '', |
156 | 156 | DTT_description text NOT NULL, |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | PRIMARY KEY (DTT_ID), |
166 | 166 | KEY EVT_ID (EVT_ID), |
167 | 167 | KEY DTT_is_primary (DTT_is_primary)"; |
168 | - $this->_table_should_exist_previously($table_name, $sql); |
|
168 | + $this->_table_should_exist_previously($table_name, $sql); |
|
169 | 169 | |
170 | - $table_name = 'esp_event_meta'; |
|
171 | - $sql = " |
|
170 | + $table_name = 'esp_event_meta'; |
|
171 | + $sql = " |
|
172 | 172 | EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
173 | 173 | EVT_ID bigint(20) unsigned NOT NULL, |
174 | 174 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -183,35 +183,35 @@ discard block |
||
183 | 183 | EVT_external_URL varchar(200) NULL, |
184 | 184 | EVT_donations tinyint(1) NULL, |
185 | 185 | PRIMARY KEY (EVTM_ID)"; |
186 | - $this->_table_should_exist_previously($table_name, $sql); |
|
186 | + $this->_table_should_exist_previously($table_name, $sql); |
|
187 | 187 | |
188 | - $table_name = 'esp_event_question_group'; |
|
189 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
188 | + $table_name = 'esp_event_question_group'; |
|
189 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
190 | 190 | EVT_ID bigint(20) unsigned NOT NULL, |
191 | 191 | QSG_ID int(10) unsigned NOT NULL, |
192 | 192 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
193 | 193 | PRIMARY KEY (EQG_ID)"; |
194 | - $this->_table_should_exist_previously($table_name, $sql); |
|
194 | + $this->_table_should_exist_previously($table_name, $sql); |
|
195 | 195 | |
196 | - $table_name = 'esp_event_venue'; |
|
197 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
196 | + $table_name = 'esp_event_venue'; |
|
197 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
198 | 198 | EVT_ID bigint(20) unsigned NOT NULL, |
199 | 199 | VNU_ID bigint(20) unsigned NOT NULL, |
200 | 200 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
201 | 201 | PRIMARY KEY (EVV_ID)"; |
202 | - $this->_table_should_exist_previously($table_name, $sql); |
|
202 | + $this->_table_should_exist_previously($table_name, $sql); |
|
203 | 203 | |
204 | - $table_name = 'esp_extra_meta'; |
|
205 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
204 | + $table_name = 'esp_extra_meta'; |
|
205 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
206 | 206 | OBJ_ID int(11) DEFAULT NULL, |
207 | 207 | EXM_type varchar(45) DEFAULT NULL, |
208 | 208 | EXM_key varchar(45) DEFAULT NULL, |
209 | 209 | EXM_value text, |
210 | 210 | PRIMARY KEY (EXM_ID)"; |
211 | - $this->_table_should_exist_previously($table_name, $sql); |
|
211 | + $this->_table_should_exist_previously($table_name, $sql); |
|
212 | 212 | |
213 | - $table_name = 'esp_line_item'; |
|
214 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
213 | + $table_name = 'esp_line_item'; |
|
214 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
215 | 215 | LIN_code varchar(245) NOT NULL DEFAULT '', |
216 | 216 | TXN_ID int(11) DEFAULT NULL, |
217 | 217 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -227,10 +227,10 @@ discard block |
||
227 | 227 | OBJ_ID int(11) DEFAULT NULL, |
228 | 228 | OBJ_type varchar(45)DEFAULT NULL, |
229 | 229 | PRIMARY KEY (LIN_ID)"; |
230 | - $this->_table_should_exist_previously($table_name, $sql); |
|
230 | + $this->_table_should_exist_previously($table_name, $sql); |
|
231 | 231 | |
232 | - $table_name = 'esp_log'; |
|
233 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
232 | + $table_name = 'esp_log'; |
|
233 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
234 | 234 | LOG_time datetime DEFAULT NULL, |
235 | 235 | OBJ_ID varchar(45) DEFAULT NULL, |
236 | 236 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -238,21 +238,21 @@ discard block |
||
238 | 238 | LOG_message text, |
239 | 239 | LOG_wp_user int(11) DEFAULT NULL, |
240 | 240 | PRIMARY KEY (LOG_ID)"; |
241 | - $this->_table_is_new_in_this_version($table_name, $sql); |
|
241 | + $this->_table_is_new_in_this_version($table_name, $sql); |
|
242 | 242 | |
243 | - $table_name = 'esp_message_template'; |
|
244 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
243 | + $table_name = 'esp_message_template'; |
|
244 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
245 | 245 | GRP_ID int(10) unsigned NOT NULL, |
246 | 246 | MTP_context varchar(50) NOT NULL, |
247 | 247 | MTP_template_field varchar(30) NOT NULL, |
248 | 248 | MTP_content text NOT NULL, |
249 | 249 | PRIMARY KEY (MTP_ID), |
250 | 250 | KEY GRP_ID (GRP_ID)"; |
251 | - $this->_table_should_exist_previously($table_name, $sql); |
|
252 | - $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
251 | + $this->_table_should_exist_previously($table_name, $sql); |
|
252 | + $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
253 | 253 | |
254 | - $table_name = 'esp_message_template_group'; |
|
255 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
254 | + $table_name = 'esp_message_template_group'; |
|
255 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
256 | 256 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
257 | 257 | MTP_name varchar(245) NOT NULL DEFAULT '', |
258 | 258 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -264,19 +264,19 @@ discard block |
||
264 | 264 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
265 | 265 | PRIMARY KEY (GRP_ID), |
266 | 266 | KEY MTP_user_id (MTP_user_id)"; |
267 | - $this->_table_should_exist_previously($table_name, $sql); |
|
267 | + $this->_table_should_exist_previously($table_name, $sql); |
|
268 | 268 | |
269 | - $table_name = 'esp_event_message_template'; |
|
270 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
269 | + $table_name = 'esp_event_message_template'; |
|
270 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
271 | 271 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
272 | 272 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
273 | 273 | PRIMARY KEY (EMT_ID), |
274 | 274 | KEY EVT_ID (EVT_ID), |
275 | 275 | KEY GRP_ID (GRP_ID)"; |
276 | - $this->_table_should_exist_previously($table_name, $sql); |
|
276 | + $this->_table_should_exist_previously($table_name, $sql); |
|
277 | 277 | |
278 | - $table_name = 'esp_payment'; |
|
279 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
278 | + $table_name = 'esp_payment'; |
|
279 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
280 | 280 | TXN_ID int(10) unsigned DEFAULT NULL, |
281 | 281 | STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL, |
282 | 282 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -293,10 +293,10 @@ discard block |
||
293 | 293 | PRIMARY KEY (PAY_ID), |
294 | 294 | KEY TXN_ID (TXN_ID), |
295 | 295 | KEY PAY_timestamp (PAY_timestamp)"; |
296 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
296 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
297 | 297 | |
298 | - $table_name = 'esp_payment_method'; |
|
299 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
298 | + $table_name = 'esp_payment_method'; |
|
299 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
300 | 300 | PMD_type varchar(124) DEFAULT NULL, |
301 | 301 | PMD_name varchar(255) DEFAULT NULL, |
302 | 302 | PMD_desc text, |
@@ -311,32 +311,32 @@ discard block |
||
311 | 311 | PMD_scope varchar(255) NULL DEFAULT 'frontend', |
312 | 312 | PRIMARY KEY (PMD_ID), |
313 | 313 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug)"; |
314 | - $this->_table_is_new_in_this_version($table_name, $sql); |
|
314 | + $this->_table_is_new_in_this_version($table_name, $sql); |
|
315 | 315 | |
316 | - $table_name = "esp_ticket_price"; |
|
317 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
316 | + $table_name = "esp_ticket_price"; |
|
317 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
318 | 318 | TKT_ID int(10) unsigned NOT NULL, |
319 | 319 | PRC_ID int(10) unsigned NOT NULL, |
320 | 320 | PRIMARY KEY (TKP_ID)"; |
321 | - $this->_table_should_exist_previously($table_name, $sql); |
|
321 | + $this->_table_should_exist_previously($table_name, $sql); |
|
322 | 322 | |
323 | - $table_name = "esp_datetime_ticket"; |
|
324 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
323 | + $table_name = "esp_datetime_ticket"; |
|
324 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
325 | 325 | DTT_ID int(10) unsigned NOT NULL, |
326 | 326 | TKT_ID int(10) unsigned NOT NULL, |
327 | 327 | PRIMARY KEY (DTK_ID)"; |
328 | - $this->_table_should_exist_previously($table_name, $sql); |
|
328 | + $this->_table_should_exist_previously($table_name, $sql); |
|
329 | 329 | |
330 | - $table_name = "esp_ticket_template"; |
|
331 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
330 | + $table_name = "esp_ticket_template"; |
|
331 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
332 | 332 | TTM_name varchar(45) NOT NULL, |
333 | 333 | TTM_description text, |
334 | 334 | TTM_file varchar(45), |
335 | 335 | PRIMARY KEY (TTM_ID)"; |
336 | - $this->_table_should_exist_previously($table_name, $sql); |
|
336 | + $this->_table_should_exist_previously($table_name, $sql); |
|
337 | 337 | |
338 | - $table_name = 'esp_question'; |
|
339 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
338 | + $table_name = 'esp_question'; |
|
339 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
340 | 340 | QST_display_text text NOT NULL, |
341 | 341 | QST_admin_label varchar(255) NOT NULL, |
342 | 342 | QST_system varchar(25) DEFAULT NULL, |
@@ -348,28 +348,28 @@ discard block |
||
348 | 348 | QST_wp_user bigint(20) unsigned NULL, |
349 | 349 | QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
350 | 350 | PRIMARY KEY (QST_ID)'; |
351 | - $this->_table_should_exist_previously($table_name, $sql); |
|
351 | + $this->_table_should_exist_previously($table_name, $sql); |
|
352 | 352 | |
353 | - $table_name = 'esp_question_group_question'; |
|
354 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
353 | + $table_name = 'esp_question_group_question'; |
|
354 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
355 | 355 | QSG_ID int(10) unsigned NOT NULL, |
356 | 356 | QST_ID int(10) unsigned NOT NULL, |
357 | 357 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
358 | 358 | PRIMARY KEY (QGQ_ID) "; |
359 | - $this->_table_should_exist_previously($table_name, $sql); |
|
359 | + $this->_table_should_exist_previously($table_name, $sql); |
|
360 | 360 | |
361 | - $table_name = 'esp_question_option'; |
|
362 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
361 | + $table_name = 'esp_question_option'; |
|
362 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
363 | 363 | QSO_value varchar(255) NOT NULL, |
364 | 364 | QSO_desc text NOT NULL, |
365 | 365 | QST_ID int(10) unsigned NOT NULL, |
366 | 366 | QSO_order int(10) unsigned NOT NULL DEFAULT 0, |
367 | 367 | QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
368 | 368 | PRIMARY KEY (QSO_ID)"; |
369 | - $this->_table_should_exist_previously($table_name, $sql); |
|
369 | + $this->_table_should_exist_previously($table_name, $sql); |
|
370 | 370 | |
371 | - $table_name = 'esp_registration'; |
|
372 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
371 | + $table_name = 'esp_registration'; |
|
372 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
373 | 373 | EVT_ID bigint(20) unsigned NOT NULL, |
374 | 374 | ATT_ID bigint(20) unsigned NOT NULL, |
375 | 375 | TXN_ID int(10) unsigned NOT NULL, |
@@ -392,28 +392,28 @@ discard block |
||
392 | 392 | KEY STS_ID (STS_ID), |
393 | 393 | KEY REG_url_link (REG_url_link), |
394 | 394 | KEY REG_code (REG_code)"; |
395 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
395 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
396 | 396 | |
397 | - $table_name = 'esp_checkin'; |
|
398 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
397 | + $table_name = 'esp_checkin'; |
|
398 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
399 | 399 | REG_ID int(10) unsigned NOT NULL, |
400 | 400 | DTT_ID int(10) unsigned NOT NULL, |
401 | 401 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
402 | 402 | CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
403 | 403 | PRIMARY KEY (CHK_ID)"; |
404 | - $this->_table_should_exist_previously($table_name, $sql); |
|
404 | + $this->_table_should_exist_previously($table_name, $sql); |
|
405 | 405 | |
406 | - $table_name = 'esp_state'; |
|
407 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
406 | + $table_name = 'esp_state'; |
|
407 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
408 | 408 | CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
409 | 409 | STA_abbrev varchar(24) COLLATE utf8_bin NOT NULL, |
410 | 410 | STA_name varchar(100) COLLATE utf8_bin NOT NULL, |
411 | 411 | STA_active tinyint(1) DEFAULT '1', |
412 | 412 | PRIMARY KEY (STA_ID)"; |
413 | - $this->_table_should_exist_previously($table_name, $sql); |
|
413 | + $this->_table_should_exist_previously($table_name, $sql); |
|
414 | 414 | |
415 | - $table_name = 'esp_status'; |
|
416 | - $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
415 | + $table_name = 'esp_status'; |
|
416 | + $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
417 | 417 | STS_code varchar(45) COLLATE utf8_bin NOT NULL, |
418 | 418 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
419 | 419 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -421,10 +421,10 @@ discard block |
||
421 | 421 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
422 | 422 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
423 | 423 | KEY STS_type (STS_type)"; |
424 | - $this->_table_should_exist_previously($table_name, $sql); |
|
424 | + $this->_table_should_exist_previously($table_name, $sql); |
|
425 | 425 | |
426 | - $table_name = 'esp_transaction'; |
|
427 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
426 | + $table_name = 'esp_transaction'; |
|
427 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
428 | 428 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
429 | 429 | TXN_total decimal(10,3) DEFAULT '0.00', |
430 | 430 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -436,10 +436,10 @@ discard block |
||
436 | 436 | PRIMARY KEY (TXN_ID), |
437 | 437 | KEY TXN_timestamp (TXN_timestamp), |
438 | 438 | KEY STS_ID (STS_ID)"; |
439 | - $this->_table_should_exist_previously($table_name, $sql); |
|
439 | + $this->_table_should_exist_previously($table_name, $sql); |
|
440 | 440 | |
441 | - $table_name = 'esp_venue_meta'; |
|
442 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
441 | + $table_name = 'esp_venue_meta'; |
|
442 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
443 | 443 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
444 | 444 | VNU_address varchar(255) DEFAULT NULL, |
445 | 445 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -457,10 +457,10 @@ discard block |
||
457 | 457 | PRIMARY KEY (VNUM_ID), |
458 | 458 | KEY STA_ID (STA_ID), |
459 | 459 | KEY CNT_ISO (CNT_ISO)"; |
460 | - $this->_table_should_exist_previously($table_name, $sql); |
|
461 | - // modified tables |
|
462 | - $table_name = "esp_price"; |
|
463 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
460 | + $this->_table_should_exist_previously($table_name, $sql); |
|
461 | + // modified tables |
|
462 | + $table_name = "esp_price"; |
|
463 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
464 | 464 | PRT_ID tinyint(3) unsigned NOT NULL, |
465 | 465 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
466 | 466 | PRC_name varchar(245) NOT NULL, |
@@ -472,10 +472,10 @@ discard block |
||
472 | 472 | PRC_wp_user bigint(20) unsigned NULL, |
473 | 473 | PRC_parent int(10) unsigned DEFAULT 0, |
474 | 474 | PRIMARY KEY (PRC_ID)"; |
475 | - $this->_table_should_exist_previously($table_name, $sql); |
|
475 | + $this->_table_should_exist_previously($table_name, $sql); |
|
476 | 476 | |
477 | - $table_name = "esp_price_type"; |
|
478 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
477 | + $table_name = "esp_price_type"; |
|
478 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
479 | 479 | PRT_name varchar(45) NOT NULL, |
480 | 480 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
481 | 481 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -484,10 +484,10 @@ discard block |
||
484 | 484 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
485 | 485 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
486 | 486 | PRIMARY KEY (PRT_ID)"; |
487 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
487 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
488 | 488 | |
489 | - $table_name = "esp_ticket"; |
|
490 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
489 | + $table_name = "esp_ticket"; |
|
490 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
491 | 491 | TTM_ID int(10) unsigned NOT NULL, |
492 | 492 | TKT_name varchar(245) NOT NULL DEFAULT '', |
493 | 493 | TKT_description text NOT NULL, |
@@ -508,11 +508,11 @@ discard block |
||
508 | 508 | TKT_parent int(10) unsigned DEFAULT '0', |
509 | 509 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
510 | 510 | PRIMARY KEY (TKT_ID)"; |
511 | - $this->_table_should_exist_previously($table_name, $sql); |
|
512 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
511 | + $this->_table_should_exist_previously($table_name, $sql); |
|
512 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
513 | 513 | |
514 | - $table_name = 'esp_question_group'; |
|
515 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
514 | + $table_name = 'esp_question_group'; |
|
515 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
516 | 516 | QSG_name varchar(255) NOT NULL, |
517 | 517 | QSG_identifier varchar(100) NOT NULL, |
518 | 518 | QSG_desc text NULL, |
@@ -524,145 +524,145 @@ discard block |
||
524 | 524 | QSG_wp_user bigint(20) unsigned NULL, |
525 | 525 | PRIMARY KEY (QSG_ID), |
526 | 526 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
527 | - $this->_table_should_exist_previously($table_name, $sql); |
|
528 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
529 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
530 | - // (because many need to convert old string states to foreign keys into the states table) |
|
531 | - $script_4_1_defaults->insert_default_states(); |
|
532 | - $script_4_1_defaults->insert_default_countries(); |
|
533 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
534 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
535 | - $script_4_5_defaults->insert_default_price_types(); |
|
536 | - $script_4_5_defaults->insert_default_prices(); |
|
537 | - $script_4_5_defaults->insert_default_tickets(); |
|
538 | - // setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
539 | - EE_Config::instance()->update_espresso_config(); |
|
540 | - $this->add_default_admin_only_payments(); |
|
541 | - $this->insert_default_currencies(); |
|
542 | - return true; |
|
543 | - } |
|
544 | - |
|
545 | - |
|
546 | - /** |
|
547 | - * @return boolean |
|
548 | - */ |
|
549 | - public function schema_changes_after_migration() |
|
550 | - { |
|
551 | - return true; |
|
552 | - } |
|
553 | - |
|
554 | - |
|
555 | - public function migration_page_hooks() |
|
556 | - { |
|
557 | - } |
|
558 | - |
|
559 | - |
|
560 | - /** |
|
561 | - * @throws ReflectionException |
|
562 | - * @throws EE_Error |
|
563 | - */ |
|
564 | - public function add_default_admin_only_payments() |
|
565 | - { |
|
566 | - global $wpdb; |
|
567 | - |
|
568 | - $table_name = $wpdb->prefix . "esp_payment_method"; |
|
569 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
570 | - $user_id = $user_id ?: 0; |
|
571 | - if ($this->_get_table_analysis()->tableExists($table_name)) { |
|
572 | - $default_admin_only_payment_methods = apply_filters( |
|
573 | - 'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods', |
|
574 | - [ |
|
575 | - esc_html__("Bank", 'event_espresso') => esc_html__("Bank Draft", 'event_espresso'), |
|
576 | - esc_html__("Cash", 'event_espresso') => esc_html__( |
|
577 | - "Cash Delivered Physically", |
|
578 | - 'event_espresso' |
|
579 | - ), |
|
580 | - esc_html__("Check", 'event_espresso') => esc_html__("Paper Check", 'event_espresso'), |
|
581 | - esc_html__("Credit Card", 'event_espresso') => esc_html__( |
|
582 | - "Offline Credit Card Payment", |
|
583 | - 'event_espresso' |
|
584 | - ), |
|
585 | - esc_html__("Debit Card", 'event_espresso') => esc_html__( |
|
586 | - "Offline Debit Payment", |
|
587 | - 'event_espresso' |
|
588 | - ), |
|
589 | - esc_html__("Invoice", 'event_espresso') => esc_html__( |
|
590 | - "Invoice received with monies included", |
|
591 | - 'event_espresso' |
|
592 | - ), |
|
593 | - esc_html__("Money Order", 'event_espresso') => '', |
|
594 | - esc_html__("Paypal", 'event_espresso') => esc_html__( |
|
595 | - "Paypal eCheck, Invoice, etc", |
|
596 | - 'event_espresso' |
|
597 | - ), |
|
598 | - esc_html__('Other', 'event_espresso') => esc_html__( |
|
599 | - 'Other method of payment', |
|
600 | - 'event_espresso' |
|
601 | - ), |
|
602 | - ] |
|
603 | - ); |
|
604 | - // make sure we hae payment method records for the following |
|
605 | - // so admins can record payments for them from the admin page |
|
606 | - foreach ($default_admin_only_payment_methods as $nicename => $description) { |
|
607 | - $slug = sanitize_key($nicename); |
|
608 | - // check that such a payment method exists |
|
609 | - $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug)); |
|
610 | - if (! $exists) { |
|
611 | - $values = [ |
|
612 | - 'PMD_type' => 'Admin_Only', |
|
613 | - 'PMD_name' => $nicename, |
|
614 | - 'PMD_admin_name' => $nicename, |
|
615 | - 'PMD_admin_desc' => $description, |
|
616 | - 'PMD_slug' => $slug, |
|
617 | - 'PMD_wp_user' => $user_id, |
|
618 | - 'PMD_scope' => serialize(['ADMIN']), |
|
619 | - ]; |
|
620 | - $success = $wpdb->insert( |
|
621 | - $table_name, |
|
622 | - $values, |
|
623 | - [ |
|
624 | - '%s',// PMD_type |
|
625 | - '%s',// PMD_name |
|
626 | - '%s',// PMD_admin_name |
|
627 | - '%s',// PMD_admin_desc |
|
628 | - '%s',// PMD_slug |
|
629 | - '%d',// PMD_wp_user |
|
630 | - '%s',// PMD_scope |
|
631 | - ] |
|
632 | - ); |
|
633 | - if (! $success) { |
|
634 | - $this->add_error( |
|
635 | - sprintf( |
|
636 | - esc_html__( |
|
637 | - "Could not insert new admin-only payment method with values %s during migration", |
|
638 | - "event_espresso" |
|
639 | - ), |
|
640 | - $this->_json_encode($values) |
|
641 | - ) |
|
642 | - ); |
|
643 | - } |
|
644 | - } |
|
645 | - } |
|
646 | - } |
|
647 | - } |
|
648 | - |
|
649 | - |
|
650 | - /** |
|
651 | - * insert_default_countries |
|
652 | - * |
|
653 | - * @static |
|
654 | - * @return void |
|
655 | - * @throws EE_Error |
|
656 | - */ |
|
657 | - public function insert_default_currencies() |
|
658 | - { |
|
659 | - global $wpdb; |
|
660 | - $currency_table = $wpdb->prefix . "esp_currency"; |
|
661 | - if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
662 | - $SQL = "SELECT COUNT('CUR_code') FROM $currency_table"; |
|
663 | - $countries = $wpdb->get_var($SQL); |
|
664 | - if (! $countries) { |
|
665 | - $SQL = "INSERT INTO $currency_table |
|
527 | + $this->_table_should_exist_previously($table_name, $sql); |
|
528 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
529 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
530 | + // (because many need to convert old string states to foreign keys into the states table) |
|
531 | + $script_4_1_defaults->insert_default_states(); |
|
532 | + $script_4_1_defaults->insert_default_countries(); |
|
533 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
534 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
535 | + $script_4_5_defaults->insert_default_price_types(); |
|
536 | + $script_4_5_defaults->insert_default_prices(); |
|
537 | + $script_4_5_defaults->insert_default_tickets(); |
|
538 | + // setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
539 | + EE_Config::instance()->update_espresso_config(); |
|
540 | + $this->add_default_admin_only_payments(); |
|
541 | + $this->insert_default_currencies(); |
|
542 | + return true; |
|
543 | + } |
|
544 | + |
|
545 | + |
|
546 | + /** |
|
547 | + * @return boolean |
|
548 | + */ |
|
549 | + public function schema_changes_after_migration() |
|
550 | + { |
|
551 | + return true; |
|
552 | + } |
|
553 | + |
|
554 | + |
|
555 | + public function migration_page_hooks() |
|
556 | + { |
|
557 | + } |
|
558 | + |
|
559 | + |
|
560 | + /** |
|
561 | + * @throws ReflectionException |
|
562 | + * @throws EE_Error |
|
563 | + */ |
|
564 | + public function add_default_admin_only_payments() |
|
565 | + { |
|
566 | + global $wpdb; |
|
567 | + |
|
568 | + $table_name = $wpdb->prefix . "esp_payment_method"; |
|
569 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
570 | + $user_id = $user_id ?: 0; |
|
571 | + if ($this->_get_table_analysis()->tableExists($table_name)) { |
|
572 | + $default_admin_only_payment_methods = apply_filters( |
|
573 | + 'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods', |
|
574 | + [ |
|
575 | + esc_html__("Bank", 'event_espresso') => esc_html__("Bank Draft", 'event_espresso'), |
|
576 | + esc_html__("Cash", 'event_espresso') => esc_html__( |
|
577 | + "Cash Delivered Physically", |
|
578 | + 'event_espresso' |
|
579 | + ), |
|
580 | + esc_html__("Check", 'event_espresso') => esc_html__("Paper Check", 'event_espresso'), |
|
581 | + esc_html__("Credit Card", 'event_espresso') => esc_html__( |
|
582 | + "Offline Credit Card Payment", |
|
583 | + 'event_espresso' |
|
584 | + ), |
|
585 | + esc_html__("Debit Card", 'event_espresso') => esc_html__( |
|
586 | + "Offline Debit Payment", |
|
587 | + 'event_espresso' |
|
588 | + ), |
|
589 | + esc_html__("Invoice", 'event_espresso') => esc_html__( |
|
590 | + "Invoice received with monies included", |
|
591 | + 'event_espresso' |
|
592 | + ), |
|
593 | + esc_html__("Money Order", 'event_espresso') => '', |
|
594 | + esc_html__("Paypal", 'event_espresso') => esc_html__( |
|
595 | + "Paypal eCheck, Invoice, etc", |
|
596 | + 'event_espresso' |
|
597 | + ), |
|
598 | + esc_html__('Other', 'event_espresso') => esc_html__( |
|
599 | + 'Other method of payment', |
|
600 | + 'event_espresso' |
|
601 | + ), |
|
602 | + ] |
|
603 | + ); |
|
604 | + // make sure we hae payment method records for the following |
|
605 | + // so admins can record payments for them from the admin page |
|
606 | + foreach ($default_admin_only_payment_methods as $nicename => $description) { |
|
607 | + $slug = sanitize_key($nicename); |
|
608 | + // check that such a payment method exists |
|
609 | + $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug)); |
|
610 | + if (! $exists) { |
|
611 | + $values = [ |
|
612 | + 'PMD_type' => 'Admin_Only', |
|
613 | + 'PMD_name' => $nicename, |
|
614 | + 'PMD_admin_name' => $nicename, |
|
615 | + 'PMD_admin_desc' => $description, |
|
616 | + 'PMD_slug' => $slug, |
|
617 | + 'PMD_wp_user' => $user_id, |
|
618 | + 'PMD_scope' => serialize(['ADMIN']), |
|
619 | + ]; |
|
620 | + $success = $wpdb->insert( |
|
621 | + $table_name, |
|
622 | + $values, |
|
623 | + [ |
|
624 | + '%s',// PMD_type |
|
625 | + '%s',// PMD_name |
|
626 | + '%s',// PMD_admin_name |
|
627 | + '%s',// PMD_admin_desc |
|
628 | + '%s',// PMD_slug |
|
629 | + '%d',// PMD_wp_user |
|
630 | + '%s',// PMD_scope |
|
631 | + ] |
|
632 | + ); |
|
633 | + if (! $success) { |
|
634 | + $this->add_error( |
|
635 | + sprintf( |
|
636 | + esc_html__( |
|
637 | + "Could not insert new admin-only payment method with values %s during migration", |
|
638 | + "event_espresso" |
|
639 | + ), |
|
640 | + $this->_json_encode($values) |
|
641 | + ) |
|
642 | + ); |
|
643 | + } |
|
644 | + } |
|
645 | + } |
|
646 | + } |
|
647 | + } |
|
648 | + |
|
649 | + |
|
650 | + /** |
|
651 | + * insert_default_countries |
|
652 | + * |
|
653 | + * @static |
|
654 | + * @return void |
|
655 | + * @throws EE_Error |
|
656 | + */ |
|
657 | + public function insert_default_currencies() |
|
658 | + { |
|
659 | + global $wpdb; |
|
660 | + $currency_table = $wpdb->prefix . "esp_currency"; |
|
661 | + if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
662 | + $SQL = "SELECT COUNT('CUR_code') FROM $currency_table"; |
|
663 | + $countries = $wpdb->get_var($SQL); |
|
664 | + if (! $countries) { |
|
665 | + $SQL = "INSERT INTO $currency_table |
|
666 | 666 | ( CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active) VALUES |
667 | 667 | ( 'EUR', 'Euro', 'Euros', '€', 2,1), |
668 | 668 | ( 'AED', 'Dirham', 'Dirhams', 'د.إ',2,1), |
@@ -816,8 +816,8 @@ discard block |
||
816 | 816 | ( 'ZAR', 'Rand', 'Rands', 'R', 2,1), |
817 | 817 | ( 'ZMK', 'Kwacha', 'Kwachas', '', 2,1), |
818 | 818 | ( 'ZWD', 'Dollar', 'Dollars', 'Z$', 2,1);"; |
819 | - $wpdb->query($SQL); |
|
820 | - } |
|
821 | - } |
|
822 | - } |
|
819 | + $wpdb->query($SQL); |
|
820 | + } |
|
821 | + } |
|
822 | + } |
|
823 | 823 | } |
@@ -9,218 +9,218 @@ |
||
9 | 9 | */ |
10 | 10 | class EE_DMS_4_7_0_Registration_Payments extends EE_Data_Migration_Script_Stage_Table |
11 | 11 | { |
12 | - protected string $_payment_table; |
|
13 | - |
|
14 | - protected string $_registration_table; |
|
15 | - |
|
16 | - protected string $_registration_payment_table; |
|
17 | - |
|
18 | - |
|
19 | - public function __construct() |
|
20 | - { |
|
21 | - /** @type WPDB $wpdb */ global $wpdb; |
|
22 | - $this->_pretty_name = esc_html__('Registration Payment Record Generation', 'event_espresso'); |
|
23 | - // define tables |
|
24 | - $this->_old_table = $wpdb->prefix . 'esp_transaction'; |
|
25 | - $this->_payment_table = $wpdb->prefix . 'esp_payment'; |
|
26 | - $this->_registration_table = $wpdb->prefix . 'esp_registration'; |
|
27 | - $this->_registration_payment_table = $wpdb->prefix . 'esp_registration_payment'; |
|
28 | - // build SQL WHERE clauses |
|
29 | - $this->_extra_where_sql = "WHERE STS_ID IN ( 'TIN', 'TCM' ) AND TXN_Total != '0.000'"; |
|
30 | - parent::__construct(); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @param array $old_row |
|
36 | - * @return void |
|
37 | - */ |
|
38 | - protected function _migrate_old_row($old_row) |
|
39 | - { |
|
40 | - /** @type WPDB $wpdb */ global $wpdb; |
|
41 | - $TXN_ID = absint($old_row['TXN_ID']); |
|
42 | - if (! $TXN_ID) { |
|
43 | - $this->add_error( |
|
44 | - sprintf( |
|
45 | - esc_html__('Invalid transaction with ID=%1$d. Error: "%2$s"', 'event_espresso'), |
|
46 | - $TXN_ID, |
|
47 | - $wpdb->last_error |
|
48 | - ) |
|
49 | - ); |
|
50 | - return; |
|
51 | - } |
|
52 | - // get all payments for the TXN |
|
53 | - $payments = $this->_get_payments($TXN_ID); |
|
54 | - if (empty($payments)) { |
|
55 | - return; |
|
56 | - } |
|
57 | - // then the registrants |
|
58 | - $registrations = $this->_get_registrations($TXN_ID); |
|
59 | - if (empty($registrations)) { |
|
60 | - return; |
|
61 | - } |
|
62 | - // now loop thru each payment and apply it to each of the registrations |
|
63 | - foreach ($payments as $payment) { |
|
64 | - if ($payment->STS_ID === 'PAP' && $payment->PAY_amount > 0) { |
|
65 | - $this->_process_registration_payments($payment, $registrations); |
|
66 | - } |
|
67 | - } |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * _get_registrations |
|
73 | - * |
|
74 | - * @param int $TXN_ID |
|
75 | - * @return array |
|
76 | - */ |
|
77 | - protected function _get_registrations(int $TXN_ID): array |
|
78 | - { |
|
79 | - /** @type WPDB $wpdb */ global $wpdb; |
|
80 | - $SQL = "SELECT * FROM $this->_registration_table WHERE TXN_ID = %d AND STS_ID IN ( 'RPP', 'RAP' )"; |
|
81 | - return $wpdb->get_results($wpdb->prepare($SQL, $TXN_ID), OBJECT_K); |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * _get_payments |
|
87 | - * |
|
88 | - * @param int $TXN_ID |
|
89 | - * @return array |
|
90 | - */ |
|
91 | - protected function _get_payments(int $TXN_ID): array |
|
92 | - { |
|
93 | - /** @type WPDB $wpdb */ global $wpdb; |
|
94 | - return $wpdb->get_results( |
|
95 | - $wpdb->prepare("SELECT * FROM $this->_payment_table WHERE TXN_ID = %d", $TXN_ID), |
|
96 | - OBJECT_K |
|
97 | - ); |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * _get_possibly_updated_REG_paid |
|
103 | - * |
|
104 | - * @param int $REG_ID |
|
105 | - * @return float |
|
106 | - */ |
|
107 | - protected function _get_possibly_updated_REG_paid(int $REG_ID): float |
|
108 | - { |
|
109 | - /** @type WPDB $wpdb */ global $wpdb; |
|
110 | - return (float) $wpdb->get_var( |
|
111 | - $wpdb->prepare("SELECT REG_paid FROM $this->_registration_table WHERE REG_ID = %d", $REG_ID) |
|
112 | - ); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * _process_registration_payments |
|
118 | - * basically a copy of the "Sequential Registration Payment Application Strategy" logic |
|
119 | - * currently in EventEspresso\core\services\payments\RegistrationPayments::processRegistrationPayments() |
|
120 | - * |
|
121 | - * @param stdClass $payment |
|
122 | - * @param array $registrations |
|
123 | - * @return void |
|
124 | - */ |
|
125 | - protected function _process_registration_payments(stdClass $payment, array $registrations = []) |
|
126 | - { |
|
127 | - // how much is available to apply to registrations? |
|
128 | - $available_payment_amount = $payment->PAY_amount; |
|
129 | - foreach ($registrations as $REG_ID => $registration) { |
|
130 | - // nothing left, then we are done here? |
|
131 | - if (! $available_payment_amount > 0) { |
|
132 | - break; |
|
133 | - } |
|
134 | - // ensure REG_final_price has a valid value, and skip if it turns out to be zero |
|
135 | - $registration->REG_final_price = |
|
136 | - ! empty($registration->REG_final_price) ? (float) $registration->REG_final_price : 0.00; |
|
137 | - if (! $registration->REG_final_price > 0) { |
|
138 | - continue; |
|
139 | - } |
|
140 | - // because REG_paid may have been updated by a previous payment, we need to retrieve the value from the db |
|
141 | - $registration->REG_paid = $this->_get_possibly_updated_REG_paid($REG_ID); |
|
142 | - // calculate amount owing, and skip if it turns out to be zero |
|
143 | - $owing = $registration->REG_final_price - $registration->REG_paid; |
|
144 | - if (! $owing > 0) { |
|
145 | - continue; |
|
146 | - } |
|
147 | - // don't allow payment amount to exceed the available payment amount, OR the amount owing |
|
148 | - $payment_amount = min($available_payment_amount, $owing); |
|
149 | - // update $available_payment_amount |
|
150 | - $available_payment_amount = $available_payment_amount - $payment_amount; |
|
151 | - // add relation between registration and payment and set amount |
|
152 | - if ($this->_insert_registration_payment($registration->REG_ID, $payment->PAY_ID, (float) $payment_amount)) { |
|
153 | - // calculate and set new REG_paid |
|
154 | - $registration->REG_paid = $registration->REG_paid + $payment_amount; |
|
155 | - $this->_update_registration_paid($registration->REG_ID, (float) $registration->REG_paid); |
|
156 | - } |
|
157 | - } |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * _insert_registration_payment |
|
163 | - * |
|
164 | - * @param int $REG_ID |
|
165 | - * @param int $PAY_ID |
|
166 | - * @param float $PAY_amount |
|
167 | - * @return bool |
|
168 | - */ |
|
169 | - protected function _insert_registration_payment(int $REG_ID = 0, int $PAY_ID = 0, float $PAY_amount = 0.00): bool |
|
170 | - { |
|
171 | - global $wpdb; |
|
172 | - $success = $wpdb->insert( |
|
173 | - $this->_registration_payment_table, |
|
174 | - ['REG_ID' => $REG_ID, 'PAY_ID' => $PAY_ID, 'RPY_amount' => $PAY_amount,], // data |
|
175 | - ['%f'] // data format |
|
176 | - ); |
|
177 | - if ($success === false) { |
|
178 | - $this->add_error( |
|
179 | - sprintf( |
|
180 | - esc_html__( |
|
181 | - 'Could not update registration paid value for registration ID=%1$d because "%2$s"', |
|
182 | - 'event_espresso' |
|
183 | - ), |
|
184 | - $REG_ID, |
|
185 | - $wpdb->last_error |
|
186 | - ) |
|
187 | - ); |
|
188 | - return false; |
|
189 | - } |
|
190 | - return true; |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - /** |
|
195 | - * _update_registration_paid |
|
196 | - * |
|
197 | - * @param int $REG_ID |
|
198 | - * @param float $REG_paid |
|
199 | - * @return bool |
|
200 | - */ |
|
201 | - protected function _update_registration_paid(int $REG_ID = 0, float $REG_paid = 0.00): bool |
|
202 | - { |
|
203 | - /** @type WPDB $wpdb */ global $wpdb; |
|
204 | - $success = $wpdb->update( |
|
205 | - $this->_registration_table, |
|
206 | - ['REG_paid' => $REG_paid], // data |
|
207 | - ['REG_ID' => $REG_ID], // where |
|
208 | - ['%f'], // data format |
|
209 | - ['%d'] // where format |
|
210 | - ); |
|
211 | - if ($success === false) { |
|
212 | - $this->add_error( |
|
213 | - sprintf( |
|
214 | - esc_html__( |
|
215 | - 'Could not update registration paid value for registration ID=%1$d because "%2$s"', |
|
216 | - 'event_espresso' |
|
217 | - ), |
|
218 | - $REG_ID, |
|
219 | - $wpdb->last_error |
|
220 | - ) |
|
221 | - ); |
|
222 | - return false; |
|
223 | - } |
|
224 | - return true; |
|
225 | - } |
|
12 | + protected string $_payment_table; |
|
13 | + |
|
14 | + protected string $_registration_table; |
|
15 | + |
|
16 | + protected string $_registration_payment_table; |
|
17 | + |
|
18 | + |
|
19 | + public function __construct() |
|
20 | + { |
|
21 | + /** @type WPDB $wpdb */ global $wpdb; |
|
22 | + $this->_pretty_name = esc_html__('Registration Payment Record Generation', 'event_espresso'); |
|
23 | + // define tables |
|
24 | + $this->_old_table = $wpdb->prefix . 'esp_transaction'; |
|
25 | + $this->_payment_table = $wpdb->prefix . 'esp_payment'; |
|
26 | + $this->_registration_table = $wpdb->prefix . 'esp_registration'; |
|
27 | + $this->_registration_payment_table = $wpdb->prefix . 'esp_registration_payment'; |
|
28 | + // build SQL WHERE clauses |
|
29 | + $this->_extra_where_sql = "WHERE STS_ID IN ( 'TIN', 'TCM' ) AND TXN_Total != '0.000'"; |
|
30 | + parent::__construct(); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @param array $old_row |
|
36 | + * @return void |
|
37 | + */ |
|
38 | + protected function _migrate_old_row($old_row) |
|
39 | + { |
|
40 | + /** @type WPDB $wpdb */ global $wpdb; |
|
41 | + $TXN_ID = absint($old_row['TXN_ID']); |
|
42 | + if (! $TXN_ID) { |
|
43 | + $this->add_error( |
|
44 | + sprintf( |
|
45 | + esc_html__('Invalid transaction with ID=%1$d. Error: "%2$s"', 'event_espresso'), |
|
46 | + $TXN_ID, |
|
47 | + $wpdb->last_error |
|
48 | + ) |
|
49 | + ); |
|
50 | + return; |
|
51 | + } |
|
52 | + // get all payments for the TXN |
|
53 | + $payments = $this->_get_payments($TXN_ID); |
|
54 | + if (empty($payments)) { |
|
55 | + return; |
|
56 | + } |
|
57 | + // then the registrants |
|
58 | + $registrations = $this->_get_registrations($TXN_ID); |
|
59 | + if (empty($registrations)) { |
|
60 | + return; |
|
61 | + } |
|
62 | + // now loop thru each payment and apply it to each of the registrations |
|
63 | + foreach ($payments as $payment) { |
|
64 | + if ($payment->STS_ID === 'PAP' && $payment->PAY_amount > 0) { |
|
65 | + $this->_process_registration_payments($payment, $registrations); |
|
66 | + } |
|
67 | + } |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * _get_registrations |
|
73 | + * |
|
74 | + * @param int $TXN_ID |
|
75 | + * @return array |
|
76 | + */ |
|
77 | + protected function _get_registrations(int $TXN_ID): array |
|
78 | + { |
|
79 | + /** @type WPDB $wpdb */ global $wpdb; |
|
80 | + $SQL = "SELECT * FROM $this->_registration_table WHERE TXN_ID = %d AND STS_ID IN ( 'RPP', 'RAP' )"; |
|
81 | + return $wpdb->get_results($wpdb->prepare($SQL, $TXN_ID), OBJECT_K); |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * _get_payments |
|
87 | + * |
|
88 | + * @param int $TXN_ID |
|
89 | + * @return array |
|
90 | + */ |
|
91 | + protected function _get_payments(int $TXN_ID): array |
|
92 | + { |
|
93 | + /** @type WPDB $wpdb */ global $wpdb; |
|
94 | + return $wpdb->get_results( |
|
95 | + $wpdb->prepare("SELECT * FROM $this->_payment_table WHERE TXN_ID = %d", $TXN_ID), |
|
96 | + OBJECT_K |
|
97 | + ); |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * _get_possibly_updated_REG_paid |
|
103 | + * |
|
104 | + * @param int $REG_ID |
|
105 | + * @return float |
|
106 | + */ |
|
107 | + protected function _get_possibly_updated_REG_paid(int $REG_ID): float |
|
108 | + { |
|
109 | + /** @type WPDB $wpdb */ global $wpdb; |
|
110 | + return (float) $wpdb->get_var( |
|
111 | + $wpdb->prepare("SELECT REG_paid FROM $this->_registration_table WHERE REG_ID = %d", $REG_ID) |
|
112 | + ); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * _process_registration_payments |
|
118 | + * basically a copy of the "Sequential Registration Payment Application Strategy" logic |
|
119 | + * currently in EventEspresso\core\services\payments\RegistrationPayments::processRegistrationPayments() |
|
120 | + * |
|
121 | + * @param stdClass $payment |
|
122 | + * @param array $registrations |
|
123 | + * @return void |
|
124 | + */ |
|
125 | + protected function _process_registration_payments(stdClass $payment, array $registrations = []) |
|
126 | + { |
|
127 | + // how much is available to apply to registrations? |
|
128 | + $available_payment_amount = $payment->PAY_amount; |
|
129 | + foreach ($registrations as $REG_ID => $registration) { |
|
130 | + // nothing left, then we are done here? |
|
131 | + if (! $available_payment_amount > 0) { |
|
132 | + break; |
|
133 | + } |
|
134 | + // ensure REG_final_price has a valid value, and skip if it turns out to be zero |
|
135 | + $registration->REG_final_price = |
|
136 | + ! empty($registration->REG_final_price) ? (float) $registration->REG_final_price : 0.00; |
|
137 | + if (! $registration->REG_final_price > 0) { |
|
138 | + continue; |
|
139 | + } |
|
140 | + // because REG_paid may have been updated by a previous payment, we need to retrieve the value from the db |
|
141 | + $registration->REG_paid = $this->_get_possibly_updated_REG_paid($REG_ID); |
|
142 | + // calculate amount owing, and skip if it turns out to be zero |
|
143 | + $owing = $registration->REG_final_price - $registration->REG_paid; |
|
144 | + if (! $owing > 0) { |
|
145 | + continue; |
|
146 | + } |
|
147 | + // don't allow payment amount to exceed the available payment amount, OR the amount owing |
|
148 | + $payment_amount = min($available_payment_amount, $owing); |
|
149 | + // update $available_payment_amount |
|
150 | + $available_payment_amount = $available_payment_amount - $payment_amount; |
|
151 | + // add relation between registration and payment and set amount |
|
152 | + if ($this->_insert_registration_payment($registration->REG_ID, $payment->PAY_ID, (float) $payment_amount)) { |
|
153 | + // calculate and set new REG_paid |
|
154 | + $registration->REG_paid = $registration->REG_paid + $payment_amount; |
|
155 | + $this->_update_registration_paid($registration->REG_ID, (float) $registration->REG_paid); |
|
156 | + } |
|
157 | + } |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * _insert_registration_payment |
|
163 | + * |
|
164 | + * @param int $REG_ID |
|
165 | + * @param int $PAY_ID |
|
166 | + * @param float $PAY_amount |
|
167 | + * @return bool |
|
168 | + */ |
|
169 | + protected function _insert_registration_payment(int $REG_ID = 0, int $PAY_ID = 0, float $PAY_amount = 0.00): bool |
|
170 | + { |
|
171 | + global $wpdb; |
|
172 | + $success = $wpdb->insert( |
|
173 | + $this->_registration_payment_table, |
|
174 | + ['REG_ID' => $REG_ID, 'PAY_ID' => $PAY_ID, 'RPY_amount' => $PAY_amount,], // data |
|
175 | + ['%f'] // data format |
|
176 | + ); |
|
177 | + if ($success === false) { |
|
178 | + $this->add_error( |
|
179 | + sprintf( |
|
180 | + esc_html__( |
|
181 | + 'Could not update registration paid value for registration ID=%1$d because "%2$s"', |
|
182 | + 'event_espresso' |
|
183 | + ), |
|
184 | + $REG_ID, |
|
185 | + $wpdb->last_error |
|
186 | + ) |
|
187 | + ); |
|
188 | + return false; |
|
189 | + } |
|
190 | + return true; |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + /** |
|
195 | + * _update_registration_paid |
|
196 | + * |
|
197 | + * @param int $REG_ID |
|
198 | + * @param float $REG_paid |
|
199 | + * @return bool |
|
200 | + */ |
|
201 | + protected function _update_registration_paid(int $REG_ID = 0, float $REG_paid = 0.00): bool |
|
202 | + { |
|
203 | + /** @type WPDB $wpdb */ global $wpdb; |
|
204 | + $success = $wpdb->update( |
|
205 | + $this->_registration_table, |
|
206 | + ['REG_paid' => $REG_paid], // data |
|
207 | + ['REG_ID' => $REG_ID], // where |
|
208 | + ['%f'], // data format |
|
209 | + ['%d'] // where format |
|
210 | + ); |
|
211 | + if ($success === false) { |
|
212 | + $this->add_error( |
|
213 | + sprintf( |
|
214 | + esc_html__( |
|
215 | + 'Could not update registration paid value for registration ID=%1$d because "%2$s"', |
|
216 | + 'event_espresso' |
|
217 | + ), |
|
218 | + $REG_ID, |
|
219 | + $wpdb->last_error |
|
220 | + ) |
|
221 | + ); |
|
222 | + return false; |
|
223 | + } |
|
224 | + return true; |
|
225 | + } |
|
226 | 226 | } |
@@ -9,69 +9,69 @@ discard block |
||
9 | 9 | */ |
10 | 10 | class EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price extends EE_Data_Migration_Script_Stage_Table |
11 | 11 | { |
12 | - protected string $_ticket_table; |
|
13 | - |
|
14 | - protected string $_line_item_table; |
|
15 | - |
|
16 | - |
|
17 | - public function __construct() |
|
18 | - { |
|
19 | - /** @type WPDB $wpdb */ global $wpdb; |
|
20 | - $this->_pretty_name = esc_html__('Registration Final Price Tax Calculations', 'event_espresso'); |
|
21 | - // define tables |
|
22 | - $this->_old_table = $wpdb->prefix . 'esp_registration'; |
|
23 | - $this->_ticket_table = $wpdb->prefix . 'esp_ticket'; |
|
24 | - $this->_line_item_table = $wpdb->prefix . 'esp_line_item'; |
|
25 | - parent::__construct(); |
|
26 | - } |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - protected function _get_rest_of_sql_for_query(): string |
|
33 | - { |
|
34 | - $SQL = "FROM $this->_old_table AS reg "; |
|
35 | - $SQL .= "JOIN $this->_ticket_table as tkt ON reg.TKT_ID = tkt.TKT_ID "; |
|
36 | - $SQL .= "JOIN $this->_line_item_table as line ON reg.TXN_ID = line.TXN_ID "; |
|
37 | - $SQL .= "WHERE tkt.TKT_taxable = 1 "; |
|
38 | - $SQL .= "AND line.LIN_code = 'total' "; |
|
39 | - $SQL .= "AND reg.REG_final_price > 0 "; |
|
40 | - return $SQL; |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * Counts the records to migrate; the public version may cache it |
|
46 | - * |
|
47 | - * @return int |
|
48 | - */ |
|
49 | - public function _count_records_to_migrate(): int |
|
50 | - { |
|
51 | - /** @type WPDB $wpdb */ global $wpdb; |
|
52 | - $SQL = "SELECT count( reg.REG_ID ) "; |
|
53 | - $SQL .= $this->_get_rest_of_sql_for_query(); |
|
54 | - return (int) $wpdb->get_var($SQL); |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * Gets data for all registrations with taxable tickets in the esp_line_item table |
|
60 | - * |
|
61 | - * @param int $limit |
|
62 | - * @return array of arrays like $wpdb->get_results($sql, ARRAY_A) |
|
63 | - * @global wpdb $wpdb |
|
64 | - */ |
|
65 | - protected function _get_rows($limit): array |
|
66 | - { |
|
67 | - /** @type WPDB $wpdb */ global $wpdb; |
|
68 | - $start_at_record = $this->count_records_migrated(); |
|
69 | - $SQL = "SELECT reg.REG_ID, reg.REG_final_price, line.LIN_ID "; |
|
70 | - $SQL .= $this->_get_rest_of_sql_for_query(); |
|
71 | - $SQL .= $wpdb->prepare("LIMIT %d, %d", $start_at_record, $limit); |
|
72 | - |
|
73 | - // produces something like: |
|
74 | - /* |
|
12 | + protected string $_ticket_table; |
|
13 | + |
|
14 | + protected string $_line_item_table; |
|
15 | + |
|
16 | + |
|
17 | + public function __construct() |
|
18 | + { |
|
19 | + /** @type WPDB $wpdb */ global $wpdb; |
|
20 | + $this->_pretty_name = esc_html__('Registration Final Price Tax Calculations', 'event_espresso'); |
|
21 | + // define tables |
|
22 | + $this->_old_table = $wpdb->prefix . 'esp_registration'; |
|
23 | + $this->_ticket_table = $wpdb->prefix . 'esp_ticket'; |
|
24 | + $this->_line_item_table = $wpdb->prefix . 'esp_line_item'; |
|
25 | + parent::__construct(); |
|
26 | + } |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + protected function _get_rest_of_sql_for_query(): string |
|
33 | + { |
|
34 | + $SQL = "FROM $this->_old_table AS reg "; |
|
35 | + $SQL .= "JOIN $this->_ticket_table as tkt ON reg.TKT_ID = tkt.TKT_ID "; |
|
36 | + $SQL .= "JOIN $this->_line_item_table as line ON reg.TXN_ID = line.TXN_ID "; |
|
37 | + $SQL .= "WHERE tkt.TKT_taxable = 1 "; |
|
38 | + $SQL .= "AND line.LIN_code = 'total' "; |
|
39 | + $SQL .= "AND reg.REG_final_price > 0 "; |
|
40 | + return $SQL; |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * Counts the records to migrate; the public version may cache it |
|
46 | + * |
|
47 | + * @return int |
|
48 | + */ |
|
49 | + public function _count_records_to_migrate(): int |
|
50 | + { |
|
51 | + /** @type WPDB $wpdb */ global $wpdb; |
|
52 | + $SQL = "SELECT count( reg.REG_ID ) "; |
|
53 | + $SQL .= $this->_get_rest_of_sql_for_query(); |
|
54 | + return (int) $wpdb->get_var($SQL); |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * Gets data for all registrations with taxable tickets in the esp_line_item table |
|
60 | + * |
|
61 | + * @param int $limit |
|
62 | + * @return array of arrays like $wpdb->get_results($sql, ARRAY_A) |
|
63 | + * @global wpdb $wpdb |
|
64 | + */ |
|
65 | + protected function _get_rows($limit): array |
|
66 | + { |
|
67 | + /** @type WPDB $wpdb */ global $wpdb; |
|
68 | + $start_at_record = $this->count_records_migrated(); |
|
69 | + $SQL = "SELECT reg.REG_ID, reg.REG_final_price, line.LIN_ID "; |
|
70 | + $SQL .= $this->_get_rest_of_sql_for_query(); |
|
71 | + $SQL .= $wpdb->prepare("LIMIT %d, %d", $start_at_record, $limit); |
|
72 | + |
|
73 | + // produces something like: |
|
74 | + /* |
|
75 | 75 | SELECT |
76 | 76 | reg.REG_ID, |
77 | 77 | reg.REG_final_price, |
@@ -88,134 +88,134 @@ discard block |
||
88 | 88 | LIMIT 1, 50 |
89 | 89 | */ |
90 | 90 | |
91 | - return $wpdb->get_results($SQL, ARRAY_A); |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * @param array $old_row |
|
97 | - * @return void |
|
98 | - */ |
|
99 | - protected function _migrate_old_row($old_row) |
|
100 | - { |
|
101 | - /** @type WPDB $wpdb */ global $wpdb; |
|
102 | - // ensure all required values are present |
|
103 | - if (! isset($old_row['REG_ID'], $old_row['REG_final_price'], $old_row['LIN_ID'])) { |
|
104 | - $this->add_error( |
|
105 | - sprintf( |
|
106 | - esc_html__( |
|
107 | - 'Invalid query results returned with the following data:%1$s REG_ID=%2$d, REG_final_price=%3$d, LIN_ID=%4$f. Error: "%5$s"', |
|
108 | - 'event_espresso' |
|
109 | - ), |
|
110 | - '<br />', |
|
111 | - $old_row['REG_ID'] ?? '', |
|
112 | - $old_row['REG_final_price'] ?? '', |
|
113 | - $old_row['LIN_ID'] ?? '', |
|
114 | - $wpdb->last_error |
|
115 | - ) |
|
116 | - ); |
|
117 | - return; |
|
118 | - } |
|
119 | - // get tax subtotal |
|
120 | - $tax_subtotal_line_item_ID = $this->_get_line_item_ID_for_tax_subtotal($old_row['LIN_ID']); |
|
121 | - if (! $tax_subtotal_line_item_ID) { |
|
122 | - $this->add_error( |
|
123 | - sprintf( |
|
124 | - esc_html__('Invalid line item ID returned. Error: "%1$s"', 'event_espresso'), |
|
125 | - $wpdb->last_error |
|
126 | - ) |
|
127 | - ); |
|
128 | - return; |
|
129 | - } |
|
130 | - // now get taxes |
|
131 | - $taxes = $this->_get_tax_amounts($tax_subtotal_line_item_ID); |
|
132 | - // apply taxes to registration final price |
|
133 | - $this->_apply_taxes($old_row['REG_ID'], (float) $old_row['REG_final_price'], $taxes); |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * _get_tax_subtotal |
|
139 | - * |
|
140 | - * @param int $LIN_ID |
|
141 | - * @return int |
|
142 | - */ |
|
143 | - protected function _get_line_item_ID_for_tax_subtotal(int $LIN_ID): int |
|
144 | - { |
|
145 | - /** @type WPDB $wpdb */ global $wpdb; |
|
146 | - $SQL = "SELECT LIN_ID "; |
|
147 | - $SQL .= "FROM $this->_line_item_table "; |
|
148 | - $SQL .= "WHERE LIN_parent = %d "; |
|
149 | - $SQL .= "AND LIN_code = 'taxes'"; |
|
150 | - return (int) $wpdb->get_var($wpdb->prepare($SQL, $LIN_ID)); |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * _get_tax_subtotal |
|
156 | - * |
|
157 | - * @param int $LIN_ID |
|
158 | - * @return array |
|
159 | - */ |
|
160 | - protected function _get_tax_amounts(int $LIN_ID): array |
|
161 | - { |
|
162 | - /** @type WPDB $wpdb */ global $wpdb; |
|
163 | - $SQL = "SELECT LIN_percent "; |
|
164 | - $SQL .= "FROM $this->_line_item_table "; |
|
165 | - $SQL .= "WHERE LIN_parent = %d"; |
|
166 | - return $wpdb->get_results($wpdb->prepare($SQL, $LIN_ID), OBJECT_K); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * _apply_taxes |
|
172 | - * |
|
173 | - * @param int $REG_ID |
|
174 | - * @param float $final_price |
|
175 | - * @param array $taxes |
|
176 | - * @return void |
|
177 | - */ |
|
178 | - protected function _apply_taxes(int $REG_ID = 0, float $final_price = 0.00, array $taxes = []) |
|
179 | - { |
|
180 | - if (is_array($taxes) && ! empty($taxes)) { |
|
181 | - $total_taxes = 0; |
|
182 | - foreach ($taxes as $tax) { |
|
183 | - $total_taxes += $final_price * ($tax->LIN_percent / 100); |
|
184 | - } |
|
185 | - $final_price += $total_taxes; |
|
186 | - $this->_update_registration_final_price($REG_ID, (float) $final_price); |
|
187 | - } |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * _update_registration_final_price |
|
193 | - * |
|
194 | - * @param int $REG_ID |
|
195 | - * @param float $REG_final_price |
|
196 | - * @return void |
|
197 | - */ |
|
198 | - protected function _update_registration_final_price(int $REG_ID = 0, float $REG_final_price = 0.00) |
|
199 | - { |
|
200 | - /** @type WPDB $wpdb */ global $wpdb; |
|
201 | - $success = $wpdb->update( |
|
202 | - $this->_old_table, |
|
203 | - ['REG_final_price' => $REG_final_price], // data |
|
204 | - ['REG_ID' => $REG_ID], // where |
|
205 | - ['%f'], // data format |
|
206 | - ['%d'] // where format |
|
207 | - ); |
|
208 | - if ($success === false) { |
|
209 | - $this->add_error( |
|
210 | - sprintf( |
|
211 | - esc_html__( |
|
212 | - 'Could not update registration final price value for registration ID=%1$d because "%2$s"', |
|
213 | - 'event_espresso' |
|
214 | - ), |
|
215 | - $REG_ID, |
|
216 | - $wpdb->last_error |
|
217 | - ) |
|
218 | - ); |
|
219 | - } |
|
220 | - } |
|
91 | + return $wpdb->get_results($SQL, ARRAY_A); |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * @param array $old_row |
|
97 | + * @return void |
|
98 | + */ |
|
99 | + protected function _migrate_old_row($old_row) |
|
100 | + { |
|
101 | + /** @type WPDB $wpdb */ global $wpdb; |
|
102 | + // ensure all required values are present |
|
103 | + if (! isset($old_row['REG_ID'], $old_row['REG_final_price'], $old_row['LIN_ID'])) { |
|
104 | + $this->add_error( |
|
105 | + sprintf( |
|
106 | + esc_html__( |
|
107 | + 'Invalid query results returned with the following data:%1$s REG_ID=%2$d, REG_final_price=%3$d, LIN_ID=%4$f. Error: "%5$s"', |
|
108 | + 'event_espresso' |
|
109 | + ), |
|
110 | + '<br />', |
|
111 | + $old_row['REG_ID'] ?? '', |
|
112 | + $old_row['REG_final_price'] ?? '', |
|
113 | + $old_row['LIN_ID'] ?? '', |
|
114 | + $wpdb->last_error |
|
115 | + ) |
|
116 | + ); |
|
117 | + return; |
|
118 | + } |
|
119 | + // get tax subtotal |
|
120 | + $tax_subtotal_line_item_ID = $this->_get_line_item_ID_for_tax_subtotal($old_row['LIN_ID']); |
|
121 | + if (! $tax_subtotal_line_item_ID) { |
|
122 | + $this->add_error( |
|
123 | + sprintf( |
|
124 | + esc_html__('Invalid line item ID returned. Error: "%1$s"', 'event_espresso'), |
|
125 | + $wpdb->last_error |
|
126 | + ) |
|
127 | + ); |
|
128 | + return; |
|
129 | + } |
|
130 | + // now get taxes |
|
131 | + $taxes = $this->_get_tax_amounts($tax_subtotal_line_item_ID); |
|
132 | + // apply taxes to registration final price |
|
133 | + $this->_apply_taxes($old_row['REG_ID'], (float) $old_row['REG_final_price'], $taxes); |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * _get_tax_subtotal |
|
139 | + * |
|
140 | + * @param int $LIN_ID |
|
141 | + * @return int |
|
142 | + */ |
|
143 | + protected function _get_line_item_ID_for_tax_subtotal(int $LIN_ID): int |
|
144 | + { |
|
145 | + /** @type WPDB $wpdb */ global $wpdb; |
|
146 | + $SQL = "SELECT LIN_ID "; |
|
147 | + $SQL .= "FROM $this->_line_item_table "; |
|
148 | + $SQL .= "WHERE LIN_parent = %d "; |
|
149 | + $SQL .= "AND LIN_code = 'taxes'"; |
|
150 | + return (int) $wpdb->get_var($wpdb->prepare($SQL, $LIN_ID)); |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * _get_tax_subtotal |
|
156 | + * |
|
157 | + * @param int $LIN_ID |
|
158 | + * @return array |
|
159 | + */ |
|
160 | + protected function _get_tax_amounts(int $LIN_ID): array |
|
161 | + { |
|
162 | + /** @type WPDB $wpdb */ global $wpdb; |
|
163 | + $SQL = "SELECT LIN_percent "; |
|
164 | + $SQL .= "FROM $this->_line_item_table "; |
|
165 | + $SQL .= "WHERE LIN_parent = %d"; |
|
166 | + return $wpdb->get_results($wpdb->prepare($SQL, $LIN_ID), OBJECT_K); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * _apply_taxes |
|
172 | + * |
|
173 | + * @param int $REG_ID |
|
174 | + * @param float $final_price |
|
175 | + * @param array $taxes |
|
176 | + * @return void |
|
177 | + */ |
|
178 | + protected function _apply_taxes(int $REG_ID = 0, float $final_price = 0.00, array $taxes = []) |
|
179 | + { |
|
180 | + if (is_array($taxes) && ! empty($taxes)) { |
|
181 | + $total_taxes = 0; |
|
182 | + foreach ($taxes as $tax) { |
|
183 | + $total_taxes += $final_price * ($tax->LIN_percent / 100); |
|
184 | + } |
|
185 | + $final_price += $total_taxes; |
|
186 | + $this->_update_registration_final_price($REG_ID, (float) $final_price); |
|
187 | + } |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * _update_registration_final_price |
|
193 | + * |
|
194 | + * @param int $REG_ID |
|
195 | + * @param float $REG_final_price |
|
196 | + * @return void |
|
197 | + */ |
|
198 | + protected function _update_registration_final_price(int $REG_ID = 0, float $REG_final_price = 0.00) |
|
199 | + { |
|
200 | + /** @type WPDB $wpdb */ global $wpdb; |
|
201 | + $success = $wpdb->update( |
|
202 | + $this->_old_table, |
|
203 | + ['REG_final_price' => $REG_final_price], // data |
|
204 | + ['REG_ID' => $REG_ID], // where |
|
205 | + ['%f'], // data format |
|
206 | + ['%d'] // where format |
|
207 | + ); |
|
208 | + if ($success === false) { |
|
209 | + $this->add_error( |
|
210 | + sprintf( |
|
211 | + esc_html__( |
|
212 | + 'Could not update registration final price value for registration ID=%1$d because "%2$s"', |
|
213 | + 'event_espresso' |
|
214 | + ), |
|
215 | + $REG_ID, |
|
216 | + $wpdb->last_error |
|
217 | + ) |
|
218 | + ); |
|
219 | + } |
|
220 | + } |
|
221 | 221 | } |