suppress_errors( true ); try { foreach ( Schema::resourceSurface( $wpdb ) as $table => $sql ) { $columns = $wpdb->get_col( $wpdb->prepare( 'SHOW COLUMNS FROM %i', $table ) ); $this->check( $wpdb ); if ( ! in_array( 'surface', $columns, true ) ) { $wpdb->query( $wpdb->prepare( 'ALTER TABLE %i ADD surface varchar(150) DEFAULT NULL AFTER resource_type', $table ) ); $this->check( $wpdb ); } Schema::verify( $wpdb, $table, Schema::adoptedPaymentShape($wpdb,$table) ?? ($sql) ); } } finally { $wpdb->suppress_errors( $previous ); } } private function check( \wpdb $wpdb ): void { if ( $wpdb->last_error ) { throw new RuntimeException( __( 'ABeCe Booking database migration failed. Existing data has been retained.', 'abece-booking' ) ); } } }