Skip to content

Commit 8a64937

Browse files
committed
Remove unneeded id column checks
These are no longer needed. The id column should be created as long as exactly two spaces are used between PRIMARY KEY and (id).
1 parent 419c392 commit 8a64937

2 files changed

Lines changed: 0 additions & 44 deletions

File tree

src/CrawledFiles.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,6 @@ public static function createTable(): void {
1111

1212
$charset_collate = $wpdb->get_charset_collate();
1313

14-
$check_table_query =
15-
$wpdb->prepare(
16-
'SHOW TABLES LIKE %s',
17-
$wpdb->esc_like( $table_name )
18-
);
19-
20-
// if table exists, check structure
21-
if ( $wpdb->get_var( $check_table_query ) === $table_name ) {
22-
// @todo We can remove this eventually
23-
// If the ID column is missing, just remove the table and start
24-
// again because dbDelta isn't adding it correctly
25-
$id_row = $wpdb->get_row(
26-
"SHOW COLUMNS FROM $table_name WHERE Field = 'id'"
27-
);
28-
29-
if ( ! $id_row ) {
30-
$wpdb->query(
31-
"DROP TABLE IF EXISTS $table_name;"
32-
);
33-
}
34-
}
35-
3614
$sql = "CREATE TABLE $table_name (
3715
id mediumint(9) NOT NULL AUTO_INCREMENT,
3816
path VARCHAR(2083) NOT NULL,

src/DeployCache.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,6 @@ public static function createTable(): void {
1818

1919
$charset_collate = $wpdb->get_charset_collate();
2020

21-
$check_table_query =
22-
$wpdb->prepare(
23-
'SHOW TABLES LIKE %s',
24-
$wpdb->esc_like( $table_name )
25-
);
26-
27-
// if table exists, check structure
28-
if ( $wpdb->get_var( $check_table_query ) === $table_name ) {
29-
// @todo We can remove this eventually
30-
// If the ID column is missing, just remove the table and start
31-
// again because dbDelta isn't adding it correctly
32-
$id_row = $wpdb->get_row(
33-
"SHOW COLUMNS FROM $table_name WHERE Field = 'id'"
34-
);
35-
36-
if ( ! $id_row ) {
37-
$wpdb->query(
38-
"DROP TABLE IF EXISTS $table_name;"
39-
);
40-
}
41-
}
42-
4321
$sql = "CREATE TABLE $table_name (
4422
id mediumint(9) NOT NULL AUTO_INCREMENT,
4523
path_hash CHAR(32) NOT NULL,

0 commit comments

Comments
 (0)