Documentation needed: new format for update_N hooks
Post-schema API, I assume we no longer do crappy stuff like this in our update_N hooks: switch ($_GLOBALS['db_type']) { case 'mysql': // blah... case 'pgsql': // blah.. } and probably are now supposed to use db_$FOO functions...but we really need some kind of instructions at the module update page (http://drupal.org/node/114774). I'll volunteer to write this, but I need to know: a) Is system_update_6022 a good example on how to perform database updates post-schema patch? b) If so, would a reasonable way to document this be to take the update code from http://drupal.org/node/115267#comment-249052 and compare it with this? Thanks... -Angie
Angie, I started writing Schema API docs; the work in progress is at http://drupal.org/node/146843. (Before the 4-week extension, ) I decided to delay finishing the docs until after code freeze so I could work on other patches, but I'll get back to it eventually. If you want to help, by all means do so. :-) system_update_6022() looks pretty good to me. The API functions should be pretty self-explanatory. The tricky part will be explaining why you can't use your own hook_schema in an update function. See http://drupal.org/node/144765#comment-245805. Also, system_update_6020() (note: not 6022) reveals that the db_create_table() API function needs to change. It needs a $table_name argument, or else you have to do all that ugly stuff with drupal_get_schema_unprocessed() and _drupal_initialize_schema(). I'll submit an issue for this Real Soon Now. Also also, I think hook_schema() should be moved into .install files; we do not need .schema files. Dries independently commented on my blog that he thinks so, too. So, I'll be submitting a patch for that, too. Thanks, Barry
Barry, is it really a good idea to put hook_schema in .install? I'd almost rather see it in .module if we anticipate common future the schema data in load/save/etc. operations. -Peter On 04 Jun 2007 09:01:33 -0400, Barry Jaspan <barry@jaspan.org> wrote:
Angie,
I started writing Schema API docs; the work in progress is at http://drupal.org/node/146843. (Before the 4-week extension, ) I decided to delay finishing the docs until after code freeze so I could work on other patches, but I'll get back to it eventually. If you want to help, by all means do so. :-)
system_update_6022() looks pretty good to me. The API functions should be pretty self-explanatory.
The tricky part will be explaining why you can't use your own hook_schema in an update function. See http://drupal.org/node/144765#comment-245805.
Also, system_update_6020() (note: not 6022) reveals that the db_create_table() API function needs to change. It needs a $table_name argument, or else you have to do all that ugly stuff with drupal_get_schema_unprocessed() and _drupal_initialize_schema(). I'll submit an issue for this Real Soon Now.
Also also, I think hook_schema() should be moved into .install files; we do not need .schema files. Dries independently commented on my blog that he thinks so, too. So, I'll be submitting a patch for that, too.
Thanks,
Barry
On 4-Jun-07, at 9:01 AM, Barry Jaspan wrote:
I started writing Schema API docs; the work in progress is at http://drupal.org/node/146843. (Before the 4-week extension, ) I decided to delay finishing the docs until after code freeze so I could work on other patches, but I'll get back to it eventually.
Sure, I understand. It's just that the lack of these documents is now actively hampering core development, as people are either totally confused on what update paths need to look like now, or aren't aware that anything changes and are doing them the old crappy way still. The schema API isn't mentioned at all in the update docs currently, and not everyone is subscribed to the commit messages. So I made the following changes to the module update page: http:// drupal.org/node/114774#schema-api a) I added a note about the schema API addition, pointing off to the schema API docs. b) I added a before/after comparison of hook_install() c) I added a before/after comparison of hook_uninstall() d) I added a before/after comparison of hook_update_N() Please review and make sure I'm not talking out of my behind. ;) Also, please note that it really is _critical_ to have API changes mentioned here ASAP after a patch is committed. It's fine if more extensive documentation comes later, but this page is the definitive resource for core and contrib developers during a code thaw and needs to track what is happening as closely as possible. -Angie
On 04 Jun 2007, at 15:01, Barry Jaspan wrote:
Also also, I think hook_schema() should be moved into .install files; we do not need .schema files. Dries independently commented on my blog that he thinks so, too. So, I'll be submitting a patch for that, too.
We can hold of this until we have a better idea where things are going. I'd rather see you work on documentation and features that let us take advantage of the schema API. -- Dries Buytaert :: http://www.buytaert.net/
participants (4)
-
Angela Byron -
Barry Jaspan -
Dries Buytaert -
Peter Wolanin