-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtrpfancy_fields.install
111 lines (104 loc) · 3.31 KB
/
trpfancy_fields.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/**
* @file
* Handles installation of this module
*/
/**
* Implements hook_schema().
*/
function trpfancy_fields_schema() {
$schema = array();
//-------------------------
// Quick Browse Field
// A) Options are Constant for a given field instance.
$schema['trpfancy_browse_options'] = array(
'description' => 'Stores options that are constant for a given field instance.',
'fields' => array(
'option_id' => array(
'description' => 'The primary identifier for the option.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE
),
'instance_id' => array(
'description' => 'The field instance these options are for.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE
),
'category' => array(
'description' => 'The category the option belongs to.',
'type' => 'varchar',
'not null' => TRUE
),
'key' => array(
'description' => 'The key for the given option. This should be a machine friendly name for the option.',
'type' => 'varchar',
'not null' => TRUE
),
'value' => array(
'description' => 'The key for the given option. This should be a machine friendly name for the option.',
'type' => 'varchar',
'not null' => TRUE
),
),
'indexes' => array(
'field_id' => array('instance_id'),
),
'unique keys' => array( ),
'primary key' => array('option_id'),
);
// B) Options are specific to an entity / field instance combination.
$schema['trpfancy_browse_options_per_entity'] = array(
'description' => 'Stores options that are specific to the entity for a given field instance.',
'fields' => array(
'option_id' => array(
'description' => 'The primary identifier for the option.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE
),
'instance_id' => array(
'description' => 'The field instance these options are for.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE
),
'entity_id' => array(
'description' => 'The entity these options are for.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE
),
'category' => array(
'description' => 'The category the option belongs to.',
'type' => 'varchar',
'not null' => TRUE
),
'key' => array(
'description' => 'The key for the given option. This should be a machine friendly name for the option.',
'type' => 'varchar',
'not null' => TRUE
),
'value' => array(
'description' => 'The key for the given option. This should be a machine friendly name for the option.',
'type' => 'varchar',
'not null' => TRUE
),
),
'indexes' => array(
'field_id' => array('instance_id', 'entity_id'),
),
'unique keys' => array( ),
'primary key' => array('option_id'),
);
return $schema;
}
/**
* Add Quick Browse option tables.
*/
function trpfancy_fields_update_7001(&$sandbox) {
$schema = trpfancy_fields_schema();
db_create_table('trpfancy_browse_options', $schema['trpfancy_browse_options']);
db_create_table('trpfancy_browse_options_per_entity', $schema['trpfancy_browse_options_per_entity']);
}