[wp-trac] [WordPress Trac] #10404: dbDelta creates duplicate indexes when index definition contains spaces
WordPress Trac
noreply at wordpress.org
Sat Jan 21 15:24:36 UTC 2023
#10404: dbDelta creates duplicate indexes when index definition contains spaces
-------------------------------+-----------------------
Reporter: Denis-de-Bernardy | Owner: (none)
Type: enhancement | Status: reopened
Priority: normal | Milestone:
Component: Database | Version: 2.8.1
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
-------------------------------+-----------------------
Comment (by andrija):
Notorious dbDelta - I've got an issue with it as well.
Here's my SQL query that gets triggered whenever I deactivate/activate the
plugin:
{{{
CREATE TABLE $table_name (
id mediumint(9) UNSIGNED NOT NULL AUTO_INCREMENT,
page_id bigint(20) UNSIGNED NOT NULL UNIQUE,
PRIMARY KEY (id)
) $charset_collate;
}}}
There are other rows, but the issue happens even with this reduced version
- every time I reactivate the plugin, a new index appears.
So currently I have:
PRIMARY
page_id
page_id_2
page_id_3
That happens only when page_id is UNIQUE, of course - if it's not UNIQUE,
not indexes are created.
But, if there was an index created and I remove the word UNIQUE from my
SQL query, then reactivate the plugin - the index is not removed from the
table.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/10404#comment:22>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list