File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -491,17 +491,10 @@ private function upgrade_20241011() {
491491
492492 $ table_name = $ wpdb ->prefix . static ::TABLE_NAME ;
493493
494- if ( \str_contains ( \strtolower ( $ wpdb ->get_row ( "DESCRIBE $ table_name data_id " )->Type ), 'int ' ) ) {
495- // Create a new column with the data-type VARCHAR(255).
496- $ wpdb ->query ( "ALTER TABLE $ table_name ADD COLUMN data_id_new VARCHAR(255) " );
497- // Loop through all rows and update the new column with the data from the old column.
498- foreach ( $ wpdb ->get_results ( "SELECT * FROM $ table_name " ) as $ row ) {
499- $ wpdb ->update ( $ table_name , [ 'data_id_new ' => $ row ->data_id ], [ 'id ' => $ row ->id ] );
494+ foreach ( $ wpdb ->get_results ( "DESCRIBE $ table_name " ) as $ column ) {
495+ if ( 'data_id ' === $ column ->Field && \str_contains ( \strtolower ( $ column ->Type ), 'int ' ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
496+ $ wpdb ->query ( "ALTER TABLE $ table_name CHANGE COLUMN data_id data_id VARCHAR(255) " );
500497 }
501- // Drop the old column.
502- $ wpdb ->query ( "ALTER TABLE $ table_name DROP COLUMN data_id " );
503- // Rename the new column to the old column name.
504- $ wpdb ->query ( "ALTER TABLE $ table_name CHANGE data_id_new data_id VARCHAR(255) " );
505498 }
506499 }
507500}
You can’t perform that action at this time.
0 commit comments