prefix . 'pokit_preorders'; $collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE {$table} ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, order_id bigint(20) unsigned NOT NULL, order_item_id bigint(20) unsigned NOT NULL, product_id bigint(20) unsigned NOT NULL, variation_id bigint(20) unsigned NOT NULL DEFAULT 0, target_id bigint(20) unsigned NOT NULL, customer_id bigint(20) unsigned NOT NULL DEFAULT 0, email varchar(200) NOT NULL DEFAULT '', qty int(11) NOT NULL DEFAULT 1, mode varchar(20) NOT NULL DEFAULT 'upfront', status varchar(30) NOT NULL DEFAULT 'active', release_ts bigint(20) unsigned NOT NULL DEFAULT 0, amount_paid decimal(19,4) NOT NULL DEFAULT 0, balance_due decimal(19,4) NOT NULL DEFAULT 0, balance_order_id bigint(20) unsigned NOT NULL DEFAULT 0, created_at datetime NOT NULL, updated_at datetime NOT NULL, released_at datetime NULL DEFAULT NULL, PRIMARY KEY (id), UNIQUE KEY order_item_unique (order_item_id), KEY order_id (order_id), KEY target_status (target_id,status), KEY product_id (product_id), KEY customer_id (customer_id), KEY status (status), KEY balance_order_id (balance_order_id) ) {$collate};"; dbDelta( $sql ); } }