suppress_errors(true); try { foreach (Schema::creditPayments($wpdb) as $table => $sql) { $exists = $wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s', $wpdb->esc_like($table))); if ($wpdb->last_error) $this->fail(); if (!$exists) { dbDelta($sql); if ($wpdb->last_error) $this->fail(); } $columns=$wpdb->get_col($wpdb->prepare('SHOW COLUMNS FROM %i',$table)); $indexes=$wpdb->get_col($wpdb->prepare('SHOW INDEX FROM %i',$table),2); Schema::verify( $wpdb, $table, Schema::adoptedPaymentShape($wpdb,$table) ?? ((in_array('business_reference',$columns,true)||in_array('uq_asb_payment_business_reference',$indexes,true))?Schema::cancellation($wpdb)[$table]:$sql) ); } } finally { $wpdb->suppress_errors($previous); } } private function fail(): never { throw new RuntimeException(__('ABeCe Booking database migration failed. Existing data has been retained.', 'abece-booking')); } }