/
micro.install
executable file
·65 lines (59 loc) · 3.13 KB
/
micro.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
63
64
65
<?php
// $Id$
/**
* @file
* Install, update and uninstall functions for the micro module.
*/
/**
* Implement hook_install().
*/
function micro_install() {
}
/**
* Implements hook_uninstall()
*/
function micro_uninstall() {
$result = db_select('variable', 'v')
->fields('v', array('name'))
->condition('name', 'micro_%', 'LIKE')
->execute();
foreach ($result as $row) {
variable_del($row->name);
}
drupal_set_message(t('Micro has been uninstalled.'));
}
/**
* Implement hook_schema().
*/
function micro_schema() {
$schema['micro'] = array(
'description' => 'Stores micro items.',
'fields' => array(
'mid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'Primary Key: Micro item ID'),
'mtid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The micro type id of this item.'),
'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The uid of the item\'s author'),
'eid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The entity ID to which the post is attached to'),
'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'Creation date'),
),
'indexes' => array('eid' => array('eid')),
'foreign keys' => array('mtid' => array('micro_types' => 'mtid')),
'primary key' => array('mid'),
);
$schema['micro_type'] = array(
'description' => 'Stores information about all defined micro types.',
'fields' => array(
'mtid' => array('type' => 'serial', 'not null' => TRUE, 'description' => 'Primary Key: Unique micro type ID'),
'machine_name' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'description' => 'The machine-readable name of this micro type'),
'name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', 'description' => 'The human-readable name of this micro type'),
'entity' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => 'node', 'description' => 'The entity type to which this micro type is attached to'),
'bundles' => array('type' => 'text', 'size' => 'big', 'not null' => FALSE, 'serialize' => TRUE, 'description' => 'The bundle type(s) to which this micro type is attached to'),
'module' => array('description' => 'The module defining this micro type.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE),
'disabled' => array('description' => 'A boolean indicating whether the node type is disabled.', 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
'status' => array('description' => 'The exportable status of the entity.', 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'),
'description' => array('description' => 'A brief description of this type.', 'type' => 'text', 'not null' => TRUE, 'size' => 'medium', 'translatable' => TRUE),
),
'primary key' => array('mtid'),
'unique keys' => array('machine_name' => array('machine_name')),
);
return $schema;
}