-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtbs_department.install
178 lines (173 loc) · 6.3 KB
/
tbs_department.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
function tbs_department_schema(){
$schema['tbs_department'] = array(
'description' => 'the base table for department.',
'fields' => array(
'dep_id' => array(
'description' => 'The primary identifier for a department',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'dep_vid' => array(
'description' => 'The current {tbs_department_revision}.dep_vid version identifier',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'dep_uid' => array(
'description' => 'The current user id that entered the department.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'dep_type' => array(
'description' => 'The machine readable name of the deparment.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'dep_name' => array(
'description' => 'The name of the department.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'dep_created' => array(
'description' => 'the unix timestamp when the department was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'dep_changed' => array(
'description' => 'the unix timestamp when the department was most recently saved',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'unique keys' => array(
'dep_id_dep_vid' => array('dep_id','dep_vid'),
'dep_id' => array('dep_id')
),
'primary key' => array('dep_id'),
);
$schema['tbs_department_type'] = array(
'description' => 'this table stores information about the types of bundel',
'fields' => array(
'dep_type_id' => array(
'description' => 'The {tbs_department_type}. this is the primary identifier for a department type.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'dep_type' => array(
'description' => 'this holds the bundle machine readable name.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'name' => array(
'description' => 'This holds the human readable name of the bundle.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'description' => array(
'description' => 'This holds a short description of the bundle',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'weight' => array(
'description' => 'The weight of this department type in relation to others',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'data' => array(
'description' => 'A serialized array of additional data related to the type',
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
),
'created' => array(
'description' => 'This holds the unix timstamp on when the type was created',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('dep_type_id'),
'unique keys' => array(
'dep_type' => array('dep_type')
),
);
$schema['tbs_department_revision'] = array(
'description' => 'Stores information about each saved version of a department.',
'fields' => array(
'dep_id' => array(
'description' => 'The {tbs_department} this version belongs to.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'dep_vid' => array(
'description' => 'The primary identifier for this version.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'dep_name' => array(
'description' => 'The Department of this version',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'dep_created' => array(
'description' => 'The unix timestamp when the department was created',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'dep_id' => array('dep_id'),
),
'primary key' => array('dep_vid'),
'foreign Keys' => array(
'tbs_department' => array(
'table' => 'tbs_department',
'columns' => array('dep_id'=> 'dep_id'),
),
'users' => array(
'table' => 'users',
'columns' => array('uid' => 'dep_id'),
),
),
);
return $schema;
}
/**
* Implements hook_uninstall().
*/
function tbs_department_uninstall()
{
// Make sure tbs_department.module is included.
require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'tbs_department.module';
// Bypass entity_load() as we cannot use it here.
foreach(department_types() as $department_type ) {
field_attach_delete_bundle('department', $department_type->dep_type);
}
}