rules_scheduler.install
5.49 KB
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
<?php
/**
* @file
* Rules Scheduler - Installation file.
*/
/**
* Implements hook_schema().
*/
function rules_scheduler_schema() {
$schema['rules_scheduler'] = array(
'description' => 'Stores scheduled tasks.',
'fields' => array(
'tid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => "The scheduled task's id.",
),
'config' => array(
'type' => 'varchar',
'length' => '64',
'default' => '',
'not null' => TRUE,
'description' => "The scheduled configuration's name.",
),
'date' => array(
'description' => 'The Unix timestamp of when the task is to be scheduled.',
'type' => 'int',
'not null' => TRUE,
),
'data' => array(
'type' => 'text',
'not null' => FALSE,
'serialize' => TRUE,
'description' => 'The whole, serialized evaluation data.',
),
'identifier' => array(
'type' => 'varchar',
'length' => '255',
'default' => '',
'not null' => FALSE,
'description' => 'The user defined string identifying this task.',
),
'handler' => array(
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
'description' => 'The fully qualified class name of a the queue item handler.',
),
),
'primary key' => array('tid'),
'indexes' => array(
'date' => array('date'),
),
'unique key' => array(
'id' => array('config', 'identifier'),
),
);
return $schema;
}
/**
* Upgrade from Rules scheduler 6.x-1.x to 7.x.
*/
function rules_scheduler_update_7200() {
// Rename the old table so we can keep its content and start over with a
// fresh one.
db_rename_table('rules_scheduler', 'rules_scheduler_d6');
// Create the d7 table.
$schema['rules_scheduler'] = array(
'description' => 'Stores scheduled tasks.',
'fields' => array(
'tid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => "The scheduled task's id.",
),
'config' => array(
'type' => 'varchar',
'length' => '255',
'default' => '',
'not null' => TRUE,
'description' => "The scheduled configuration's name.",
),
'date' => array(
'description' => 'The Unix timestamp of when the task is to be scheduled.',
'type' => 'int',
'not null' => TRUE,
),
'data' => array(
'type' => 'text',
'not null' => FALSE,
'serialize' => TRUE,
'description' => 'The whole, serialized evaluation data.',
),
'identifier' => array(
'type' => 'varchar',
'length' => '255',
'default' => '',
'not null' => FALSE,
'description' => 'The user defined string identifying this task.',
),
),
'primary key' => array('tid'),
'indexes' => array('date' => array('date')),
);
db_create_table('rules_scheduler', $schema['rules_scheduler']);
}
/**
* Fix the length of the rules_scheduler.name column.
*/
function rules_scheduler_update_7202() {
// Note that update 7201 (add the 'id' unique key') has been removed as it is
// incorporated by 7202. For anyone that has already run the previous update
// 7201, we have to first drop the unique key.
db_drop_unique_key('rules_scheduler', 'id');
db_change_field('rules_scheduler', 'config', 'config', array(
'type' => 'varchar',
'length' => '64',
'default' => '',
'not null' => TRUE,
'description' => "The scheduled configuration's name.",
));
db_add_unique_key('rules_scheduler', 'id', array('config', 'identifier'));
}
/**
* Add a database column for specifying a queue item handler.
*/
function rules_scheduler_update_7203() {
db_add_field('rules_scheduler', 'handler', array(
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
'description' => 'The fully qualified class name of a the queue item handler.',
));
}
/**
* Rename rules_scheduler.state into rules_scheduler.data.
*/
function rules_scheduler_update_7204() {
if (db_field_exists('rules_scheduler', 'state')) {
db_change_field('rules_scheduler', 'state', 'data', array(
'type' => 'text',
'not null' => FALSE,
'serialize' => TRUE,
'description' => 'The whole, serialized evaluation data.',
));
}
}
/**
* Rules upgrade callback for mapping the action name.
*/
function rules_scheduler_action_upgrade_map_name($element) {
return 'schedule';
}
/**
* Rules upgrade callback.
*/
function rules_scheduler_action_upgrade($element, $target) {
$target->settings['component'] = $element['#info']['set'];
$target->settings['date'] = $element['#settings']['task_date'];
$target->settings['identifier'] = $element['#settings']['task_identifier'];
unset($element['#info']['arguments']['task_date'], $element['#info']['arguments']['task_identifier']);
foreach ($element['#info']['arguments'] as $name => $info) {
rules_upgrade_element_parameter_settings($element, $target, $name, $info, 'param_' . $name);
}
}
/**
* Rules upgrade callback for mapping the action name.
*/
function rules_action_delete_scheduled_set_upgrade_map_name($element) {
return 'schedule_delete';
}
/**
* Rules upgrade callback.
*/
function rules_action_delete_scheduled_set_upgrade($element, $target) {
$target->settings['component'] = $element['#settings']['ruleset'];
$target->settings['task'] = $element['#settings']['task_identifier'];
}