I am developing a module (using drupal 4.6) to track schedules and results for baseball games. I plan to create a new table that has one record for each game with all schedule and scoring information. I thought that perhaps there would be a hook_firstrun or hook_setup or something, but only found hook_init, which isn't related to what I'm doing.

I would like to know what the suggested method for creating a module's own table is:
1 - put it in an sql file like the initial drupal database setup and require the user to run it as admin?
2 - provide a link in a settings node and hope the drupal database account used has permissions to create table?
3 - dynamically check for existence of table upon creation of a new game each time, building it on the fly if it's not there?

Any help or advice would be appreciated. I'd like to build this so it will fit into existing code well without causing any more work for the user than necessary, but also ensuring I won't have to fight it or slow down the site in the future.

Thanks,
Mike

Comments

mightypile’s picture

I know this has to be a pretty common thing for people to do, any references to other modules to reverse-engineer or anything? I'm not asking for hand-holding, just advice to make sure the module is built correctly and avoids hacking things up.
-Mike

venkat-rk’s picture

I am not a drupal expert, but, are you sure a custom table is necessary? Some sites have done similar things to what you want just by using flexinode.

Here is an example, although it is mostly for player information:
http://drupal.org/node/20097#comment-34310

RobRoy’s picture

It may not be necessary, but if it is just include a baseball.mysql file with your baseball.module file that has the CREATE TABLE sql code, etc. That is how all the other modules do it. Then in a readme.txt file tell users to install that mysql file first.

Download another module like Organic Groups to see the mysql file and readme.txt.