Newer
Older
Wolfgang Ziegler
committed
<?php
/**
* @file
* Install, update and uninstall functions for the entity_test module.
*/
/**
Wolfgang Ziegler
committed
* Implements hook_uninstall().
Wolfgang Ziegler
committed
*/
Wolfgang Ziegler
committed
function entity_test_uninstall() {
// Bypass entity_load() as we cannot use it here.
$types = db_select('entity_test_type', 'et')
->fields('et')
->execute()
->fetchAllAssoc('name');
Wolfgang Ziegler
committed
Wolfgang Ziegler
committed
foreach ($types as $name => $type) {
field_attach_delete_bundle('entity_test', $name);
}
Wolfgang Ziegler
committed
}
/**
Wolfgang Ziegler
committed
* Implements hook_schema().
Wolfgang Ziegler
committed
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
*/
function entity_test_schema() {
$schema['entity_test'] = array(
'description' => 'Stores entity_test items.',
'fields' => array(
'pid' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique entity_test item ID.',
),
'name' => array(
'description' => 'The name of the entity_test.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'uid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => NULL,
'description' => "The {users}.uid of the associated user.",
),
),
'indexes' => array(
'uid' => array('uid'),
),
'foreign keys' => array(
'uid' => array('users' => 'uid'),
'name' => array('entity_test_types' => 'name'),
),
'primary key' => array('pid'),
);
$schema['entity_test_type'] = array(
'description' => 'Stores information about all defined entity_test types.',
'fields' => array(
Wolfgang Ziegler
committed
'id' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique entity_test type ID.',
),
Wolfgang Ziegler
committed
'name' => array(
'description' => 'The machine-readable name of this entity_test type.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'label' => array(
'description' => 'The human-readable name of this entity_test type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'The weight of this entity_test type in relation to others.',
),
'locked' => array(
'description' => 'A boolean indicating whether the administrator may delete this type.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'data' => array(
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'A serialized array of additional data related to this entity_test type.',
Wolfgang Ziegler
committed
'merge' => TRUE,
Wolfgang Ziegler
committed
),
Wolfgang Ziegler
committed
'status' => array(
'type' => 'int',
'not null' => TRUE,
// Set the default to ENTITY_CUSTOM without using the constant as it is
// not safe to use it at this point.
'default' => 0x01,
'size' => 'tiny',
'description' => 'The exportable status of the entity.',
),
'module' => array(
'description' => 'The name of the providing module if the entity has been defined in code.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
),
Wolfgang Ziegler
committed
'primary key' => array('id'),
'unique keys' => array(
'name' => array('name'),
),
Wolfgang Ziegler
committed
);
return $schema;
}