| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\App\Modules\Payments\Migrations; |
| 4 |
|
| 5 |
if (!defined('ABSPATH')) { |
| 6 |
exit; // Exit if accessed directly. |
| 7 |
} |
| 8 |
|
| 9 |
class OrderSubscriptions |
| 10 |
{ |
| 11 |
/** |
| 12 |
* Migrate the table. |
| 13 |
* |
| 14 |
* @return void |
| 15 |
*/ |
| 16 |
public static function migrate() |
| 17 |
{ |
| 18 |
global $wpdb; |
| 19 |
|
| 20 |
$charsetCollate = $wpdb->get_charset_collate(); |
| 21 |
|
| 22 |
$table = $wpdb->prefix . 'fluentform_subscriptions'; |
| 23 |
|
| 24 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Migration file, direct query needed |
| 25 |
if ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $table)) != $table) { |
| 26 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange -- Migration file, schema change is the purpose |
| 27 |
$sql = "CREATE TABLE $table ( |
| 28 |
id int(20) NOT NULL AUTO_INCREMENT, |
| 29 |
submission_id int(11), |
| 30 |
form_id int(11), |
| 31 |
payment_total int(11) DEFAULT 0, |
| 32 |
item_name varchar(255), |
| 33 |
plan_name varchar(255), |
| 34 |
parent_transaction_id int(11), |
| 35 |
billing_interval varchar (50), |
| 36 |
trial_days int(11), |
| 37 |
initial_amount int(11), |
| 38 |
quantity int(11) DEFAULT 1, |
| 39 |
recurring_amount int(11), |
| 40 |
bill_times int(11), |
| 41 |
bill_count int(11) DEFAULT 0, |
| 42 |
vendor_customer_id varchar(255), |
| 43 |
vendor_subscription_id varchar(255), |
| 44 |
vendor_plan_id varchar(255), |
| 45 |
status varchar(255) DEFAULT 'pending', |
| 46 |
initial_tax_label varchar(255), |
| 47 |
initial_tax int(11), |
| 48 |
recurring_tax_label varchar(255), |
| 49 |
recurring_tax int(11), |
| 50 |
element_id varchar(255), |
| 51 |
note text, |
| 52 |
original_plan text, |
| 53 |
vendor_response longtext, |
| 54 |
expiration_at timestamp NULL, |
| 55 |
created_at timestamp NULL, |
| 56 |
updated_at timestamp NULL, |
| 57 |
PRIMARY KEY (id) |
| 58 |
) $charsetCollate;"; |
| 59 |
|
| 60 |
require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
| 61 |
|
| 62 |
dbDelta($sql); |
| 63 |
} |
| 64 |
} |
| 65 |
} |
| 66 |
|