← Back to team overview

gourmet team mailing list archive

Re: Database changed without update code???

 

Tom,

Am 2013-06-28 15:07, schrieb Thomas Mills Hinkle:
Bernhard et al,
I'm the one to blame...
I've been a bit busy and haven't followed all the development leading up to the 0.16 release, but it looks like 0.16.0 went out with changes to the database model but *without* code to update existing databases.
Actually, I tried to make sure existing databases *are* updated, see https://github.com/thinkle/gourmet/blob/master/gourmet/backends/db.py#L510 through line 554. I thought I tested this stuff -- does it break your DB? <https://github.com/thinkle/gourmet/blob/master/gourmet/backends/db.py#L510>
Specifically, it seems like primary keys have been changed in the pantry and other columns.

This is pretty bad -- I've always tried to ensure that existing users get treated well. I'm wondering, have bug reports been flowing in about this? Is 0.16 not out generally?
Yes it is, and the Ubuntu package has even been part of 13.04 already. (Other distributions lag behind a bit, though, and I still haven't managed to roll out a Windows release.) I really tried to make sure not to break anything -- please describe what specifically is broken (any errors, or messed up DB layouts?) Anyway, there have been no bug reports yet that I was able to attribute to this change. Actually, not that many new bug reports after 0.16 at all...
For the future, changes to the DB structure are a pain in the ass and shouldn't be made for simple "code cleanup" reasons -- I doubt there is any functional benefit to introducing new primary key columns named 'id' in place of or in addition to the old ones?
Yes there is -- it wasn't possible to connect gourmet to a MySQL database before that change, see https://github.com/thinkle/gourmet/issues/681 and the blog article linked therein that made me aware of the issue, http://blog.henrygis.com/2011/02/setting-up-gourmet-recipe-manager-part.html

In a nutshell, MySQL requires length parameters to VARCHARs if they're supposed to serve as primary keys. So I had the choice between adding such parameters (with some arbitrarily chosen value for their maximum lengths, thus possibly breaking longer values in the affected columns), or introduce new auto-incremented integer primary keys -- I went for the latter. (This is also described in the comment at https://github.com/thinkle/gourmet/blob/master/gourmet/backends/db.py#L535 ) <https://github.com/thinkle/gourmet/blob/master/gourmet/backends/db.py#L535>
I would tend to be inclined to just roll back the changes (that's what I'll do locally),
Please don't (at least not in the public git repo) -- as described above, this wasn't just for cleanup's sake. If it's really broken, we'd better provide an actual fix with 0.16.1.
but since the code is now in the wild and new users will get the new columns, I think we have to write the update code anyway.
Ironically, the one bug report I know of related to this is https://github.com/thinkle/gourmet/issues/711 -- seems like it still doesn't work with MySQL, but I haven't had the time yet to look into it.
<https://github.com/thinkle/gourmet/issues/711>
Tom
Bernhard


References