Last updated June 6, 2013. Created by peterx on August 7, 2010.
Edited by droetker, mlncn, jn2. Log in to edit this page.

Drupal 6 uses .install files to create database tables and fields, and to insert data. See Writing .install files, (Drupal 6.x). Drupal 6 .install files can also provide updates to change the database structure and content. Drupal 7 also uses .install files and includes the Field module in core. Field provides a different way to send data to nodes and could replace some .install files. Here is a start for the Drupal 7 .install page.

.install file

In Drupal 7 as in Drupal 6, .install files can define new tables, load data, and implement conversions during updates. This page on conversions from Drupal 6 to Drupal 7, http://drupal.org/node/224333, mentions .install in several places. Follow the Drupal 6 .install documentation and include the following changes. Please help complete this documentation; when you verify that something from the Drupal 6 .install works the same in Drupal 7, note that here.
http://drupal.org/node/224333#registry
http://drupal.org/node/224333#update_php
http://drupal.org/node/224333#schema_translation
http://drupal.org/node/224333#schema_html
http://drupal.org/node/224333#module_file_during_install
http://drupal.org/node/224333#foreign-keys-added

Fields as a replacement

With the Field module, you can add fields to nodes. If the only thing you do in your install file is add fields to nodes by adding a table and some columns, you can now use the Field API, http://api.drupal.org/api/group/field/7, and the field hooks. You can search for the field hooks in http://api.drupal.org/api/7. Search for hook_field_.

hook_field_schema is a hook for adding fields. You can see examples of its use in modules/image/image.field.inc and modules/taxonomy/taxonomy.module. The hook is used in your .module file and might replace the schema in your .install file if you are not adding any other tables. If the only thing in your .install file is a schema, you might not need the .install file.

One other use for the .install file is to delete stuff when someone uninstalls the module. No information yet on how the Field module handles an uninstall.

Dependencies

When you are installing a module that is dependent on another module, the other module might not be 100% functional. Install and test the other module first. During the alpha and beta stage, you can really only depend on Drupal core modules. Add-on modules can be a long way behind. Even core modules can be a problem so, if you have to switch on extra core modules, switch them on one at a time.

White screen of death

Drupal and PHP suppress a lot of errors. If your changes to the .install or .info files produce a blank white screen, the dreaded Drupal White Screen of Death, see Show all errors while developing.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

When a hook_schema() function is available in the .install file D7 automatically creates the table when installing the module. It also automatically drops the table when uninstalling the module.
An explicit call to drupal_install_schema in hook_install results in an error (creating a table that already exists).
This seems to be different from D6.

Hans

Indeed. Here's a link to more information: http://drupal.org/update/modules/6/7#install-schema