Rather than directly executing an SQL query to update our custom table’s schema, we utilize dbDelta(), which examines the current table structure, compares it to the desired table structure, and either adds or modifies the table as necessary.
There are some flaws in our current implementation.
Rather than directly executing an SQL query to update our custom table’s schema, we utilize
dbDelta()
, which examines the current table structure, compares it to the desired table structure, and either adds or modifies the table as necessary.There are some flaws in our current implementation.
According to the Codex,
dbDelta()
is rather picky:So, we have to be mindful of those caveats.
Our database abstraction layer currently generates this SQL:
We need to adjust it to generate SQL that looks like this: