Skip to content

Commit 05e0b72

Browse files
authored
Merge pull request #387 from ProgressPlanner/filip/test-sqlite
2 parents 40f18cc + ea62469 commit 05e0b72

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

classes/class-query.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)