I am working on a custom module which does not have an install file but nevertheless uses a lot of tables. The one who worked on it previously, created the database tables manually. Now I want to add more tables to it. I could run the query manually to get the job done but I wanted to use the 'Drupal' way to do that. So I was wondering if we could use a hook_update_N for a module without hook_install?
No module needs to implement every hook. You can use hook_update_n() and not have a hook_install() function just fine.
You'll probably at 1 point want to define hook_schema() for these tables. An easy tool to get the "drupal" schema for any mysql table (already defined) in your mysql database is the Schema module.
- Schema documentation: hyperlinked display of the schema's embedded documentation explaining what each table and field is for.
- Schema structure generation: the module examines the live database and creates Schema API data structures for all tables that match the live database.
- Schema comparison: the module compares the live database structure with the schema structure declared by all enabled modules, reporting on any missing or incorrect tables.
Note for MySQL users: The Schema module requires MySQL 5. Prior versions of MySQL do not support the INFORMATION_SCHEMA database that the Schema module uses to inspect the database.