suppress_errors( true ); try { foreach ( Schema::initial( $wpdb ) as $table => $sql ) { if($wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s',$wpdb->esc_like($table)))){$columns=$wpdb->get_col($wpdb->prepare('SHOW COLUMNS FROM %i',$table));if(in_array('group_uuid',$columns,true)){Schema::verify($wpdb,$table,Schema::pilotOperations($wpdb)[$table]);continue;}} // Adoption after a lost version option must not recreate legacy ownership columns. if ( $table === \ABeCe\Booking\Infrastructure\Database\Tables::name( $wpdb, 'bookings' ) && $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table ) ) ) ) { $columns = $wpdb->get_col( $wpdb->prepare( 'SHOW COLUMNS FROM %i', $table ) ); if ( in_array( 'customer_user_id', $columns, true ) ) { Schema::verify( $wpdb, $table, Schema::adoptedPaymentShape($wpdb,$table) ?? (( in_array( 'external_contact_snapshot', $columns, true ) ? Schema::externalContacts( $wpdb ) : ( in_array( 'cancellation_policy_snapshot', $columns, true ) ? Schema::cancellation( $wpdb ) : ( in_array( 'pricing_snapshot', $columns, true ) ? Schema::pricing( $wpdb ) : Schema::bookingModel( $wpdb ) ) ) )[ $table ]) ); continue; } } if ( $table === \ABeCe\Booking\Infrastructure\Database\Tables::name( $wpdb, 'resources' ) && $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table ) ) ) ) { $columns = $wpdb->get_col( $wpdb->prepare( 'SHOW COLUMNS FROM %i', $table ) ); if ( in_array( 'surface', $columns, true ) ) { Schema::verify( $wpdb, $table, Schema::adoptedPaymentShape($wpdb,$table) ?? (Schema::resourceSurface( $wpdb )[ $table ]) ); continue; } } dbDelta( $sql ); if ( $wpdb->last_error ) { throw new RuntimeException( __( 'ABeCe Booking database migration failed. Existing data has been retained.', 'abece-booking' ) ); } Schema::verify( $wpdb, $table, Schema::adoptedPaymentShape($wpdb,$table) ?? ($sql) ); } } finally { $wpdb->suppress_errors( $previous ); } } }