-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdeploy.install
363 lines (352 loc) · 10.5 KB
/
deploy.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
<?php
/**
* @file
* Deploy module installation functions.
*/
/**
* Implements hook_schema().
*
* @todo
* Add indexes.
*/
function deploy_schema() {
$schema = array();
$schema['deploy_plans'] = array(
'description' => 'Base table holding deployment plans.',
'export' => array(
'api' => array(
'owner' => 'deploy',
'api' => 'deploy_plans',
'minimum_version' => 1,
'current_version' => 1,
),
'key' => 'name',
'key name' => 'Name',
'primary key' => 'pid',
'identifier' => 'plan',
'object factory' => 'deploy_plan_create',
'load callback' => 'deploy_plan_load',
'load all callback' => 'deploy_plan_load_all',
'default hook' => 'deploy_plans_default',
),
'fields' => array(
'pid' => array(
'description' => 'Serial id for this plan. Only used for internal lookups.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'no export' => TRUE,
),
'name' => array(
'description' => 'Machine-readable name for this plan.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'title' => array(
'description' => 'Administrative title for this plan.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'description' => array(
'description' => 'Administrative description for this plan.',
'type' => 'text',
'size' => 'medium',
'not null' => TRUE,
),
'debug' => array(
'description' => 'Debug mode.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'aggregator_plugin' => array(
'description' => 'Aggregator plugin used for this plan.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'aggregator_config' => array(
'description' => "Serialized configuration data this plan's aggregator plugin.",
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'fetch_only' => array(
'description' => 'Indicates if this plan is fetch-only.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'processor_plugin' => array(
'description' => 'Processor plugin used for this plan.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
),
'processor_config' => array(
'description' => "Serialized configuration data this plan's processor plugin.",
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'endpoints' => array(
'description' => 'Serialized array of all endpoints for this plan.',
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'dependency_plugin' => array(
'description' => 'Dependency plugin used for this plan.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array('pid'),
'indexes' => array(
'name' => array('name'),
'fetch_only' => array('fetch_only'),
'aggregator_plugin' => array('aggregator_plugin'),
),
);
$schema['deploy_endpoints'] = array(
'description' => 'Base table holding deployment endpoints.',
'export' => array(
'api' => array(
'owner' => 'deploy',
'api' => 'deploy_endpoints',
'minimum_version' => 1,
'current_version' => 1,
),
'key' => 'name',
'key name' => 'Name',
'primary key' => 'eid',
'identifier' => 'endpoint',
'object factory' => 'deploy_endpoint_create',
'load callback' => 'deploy_endpoint_load',
'load all callback' => 'deploy_endpoint_load_all',
'default hook' => 'deploy_endpoints_default',
),
'fields' => array(
'eid' => array(
'description' => 'Serial id for this endpoint. Only used for internal lookups.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'no export' => TRUE,
),
'name' => array(
'description' => 'Machine-readable name for this endpoint.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'title' => array(
'description' => 'Administrative title for this endpoint.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'description' => array(
'description' => 'Administrative description for this endpoint.',
'type' => 'text',
'size' => 'medium',
'not null' => TRUE,
),
'debug' => array(
'description' => 'Debug mode.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'authenticator_plugin' => array(
'description' => 'Authenticator plugin used for this endpoint.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'authenticator_config' => array(
'description' => "Serialized configuration data for this endpoint's authenticator plugin.",
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'service_plugin' => array(
'description' => 'Service plugin used for this endpoint.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'service_config' => array(
'description' => "Serialized configuration data this endpoint's service plugin.",
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
),
'primary key' => array('eid'),
'indexes' => array(
'name' => array('name'),
),
);
$schema['deploy_deployments'] = array(
'description' => 'Log of all deployments pushed from this site.',
'fields' => array(
'did' => array(
'description' => 'Deployment ID.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'no export' => TRUE,
),
'plan_name' => array(
'description' => 'Plan name responsible for this deployment.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'uuid' => array(
'description' => 'UUID key for tracking a deployment.',
'type' => 'char',
'length' => 36,
'not null' => TRUE,
),
'lid' => array(
'description' => 'Pointer to the latest log entry for this deployment (deploy_log.lid).',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('did'),
'indexes' => array(
'uuid' => array('uuid'),
'plan_name' => array('plan_name'),
'uuid_plan_name' => array('uuid', 'plan_name'),
),
);
$schema['deploy_log'] = array(
'description' => 'Log of all status updates for a deployment.',
'fields' => array(
'lid' => array(
'description' => 'Log ID.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'no export' => TRUE,
),
'uuid' => array(
'description' => 'UUID reference to a deployment (deploy_deployments.uuid).',
'type' => 'char',
'length' => 36,
'not null' => TRUE,
),
'status' => array(
'description' => 'A status code for the deployment.',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
),
'timestamp' => array(
'description' => 'Timestamp when this log entry was updated.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'message' => array(
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
'description' => 'Complementary message, for example the exception in case of a failure.',
),
),
'primary key' => array('lid'),
'indexes' => array(
'uuid' => array('uuid'),
),
);
$schema['deploy_manager_entities'] = array(
'description' => 'Holds entities to be deployed for managed plans.',
'fields' => array(
'plan_name' => array(
'description' => 'The name of the deployment plan this item applies to.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'entity_type' => array(
'description' => 'The type of entity, for example "node", "user".',
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
),
'entity_id' => array(
'description' => 'The entity ID to be deployed.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'revision_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The entity revision ID to be deployed.',
),
'timestamp' => array(
'description' => 'The unix timestamp indicating when this item was added to the deployment plan.',
'type' => 'numeric',
'precision' => 16,
'scale' => 4,
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('plan_name', 'entity_type', 'entity_id', 'revision_id'),
'indexes' => array(
'timstamp' => array('timestamp'),
),
);
return $schema;
}
/**
* Convert timestamp for deploy_manager_entities to float for more precision.
*/
function deploy_update_7001(&$sandbox) {
$spec = array(
'description' => 'The unix timestamp indicating when this item was added to the deployment plan.',
'type' => 'numeric',
'precision' => 16,
'scale' => 4,
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
);
db_change_field('deploy_manager_entities', 'timestamp', 'timestamp', $spec);
// Now we add the new index so MySQL doesn't whinge.
db_add_index('deploy_manager_entities', 'timstamp', array('timestamp'));
}
/**
* Add new fields to the 'deploy_plans' table.
*/
function deploy_update_7002() {
if (!db_field_exists('deploy_plans', 'dependency_plugin')) {
db_add_field('deploy_plans', 'dependency_plugin', array(
'description' => 'Dependency plugin used for this plan.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
));
}
}