我正在 drupal 7.15 中创建一个模块,它依赖于实体 api 。我的模块名称是employee 我已经创建了一个employee.info 文件以及employee.install 文件。但是在数据库中,我在employee.install 文件中看不到我自己创建的数据库模式。这是我的 .info 文件和 .install 文件分别编辑:
name = Employee Management
description = A module that describes about the employee management
core = 7.x
package = Employee management module
files[] = employee.module
编辑:
<?php
/**
* @file
* Install for a employee entity - need to create the base table for our entity.
* This table can have as many colums as you need to keep track of entity-specific
* data that will not be added via attached fields.
* The minimum information for the entity to work is an id and an entity name.
*/
/**
* Implements hook_schema()
*/
function employee_schema() {
$schema = array();
$schema['employee'] = array(
'description' => 'The base table for employee entity.',
'fields' => array(
'employee_id' => array(
'description' => 'Primary Key: Identifier for a employee entity.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'first_name' => array(
'description' => 'The First name of employee entity.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'last_name' => array(
'description' => 'The Last name of employee entity.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'employee_add' => array(
'description' => 'The address of employee entity.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'employee_doj' => array(
'description' => 'The address of employee entity.',
'type' => 'date',
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array('employee_id'),
);
return $schema;
}