[wp-hackers] Help with dbDelta

Michael D Adams mda at blogwaffe.com
Wed Jan 26 20:05:07 UTC 2011


On Wed, Jan 26, 2011 at 7:34 AM, Mike Walsh <mike_walsh at mindspring.com> wrote:
> I have a plugin that manages a swim team that I've developed over the last
> couple years.  It uses some custom tables to store all of the swim team
> information.  I've used dbDelta() to create the tables in the past (based on
> recommendations from the CodeEx and this list) and it has worked fine for
> new tables or new columns in existing tables.  Yesterday I realized that one
> of the tables had a mistake in it due to a typo.  I fixed it and changed the
> database version number of use for checking and dbDelta() did not update the
> table as I expected.  My question is this:
>
> Is dbDelta() still the suggested method for creating and updating custom
> tables?
> What is the best way to check for and handle problems when dbDelta() does
> not update a table?

dbDelta() is very particular about whitespace and other formatting, as
I recall.  You could try using BackPress' equivalent and seeing if
that gives you better results.

http://backpress.automattic.com/browser/trunk/includes/class.bp-sql-schema-parser.php


More information about the wp-hackers mailing list