forked from backdrop-contrib/githubapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithubapi.install
More file actions
202 lines (193 loc) · 5.45 KB
/
githubapi.install
File metadata and controls
202 lines (193 loc) · 5.45 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
192
193
194
195
196
197
198
199
200
201
202
<?php
/**
* @file
* Install, update, and uninstall functions for the githubapi module.
*/
/**
* Implements hook_install().
*/
function githubapi_install() {
}
/**
* Implements hook_schema().
*/
function githubapi_schema() {
$schema['githubapi_payload'] = array(
'description' => 'Stores githubapi-specific payload logs.',
'fields' => array(
'id' => array(
'description' => 'Primary Key: Unique report ID.',
'type' => 'serial',
'not null' => TRUE,
'unsigned' => TRUE,
),
'type' => array(
'description' => 'Payload type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'sender' => array(
'description' => 'Event sender.',
'type' => 'blob',
'size' => 'big',
'serialize' => TRUE,
),
'rid' => array(
'description' => 'The {githubapi_repositories}.id of the repo for hook.',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
'data' => array(
'description' => 'Event data execept sender and repository.',
'type' => 'blob',
'size' => 'big',
'serialize' => TRUE,
),
'timestamp' => array(
'description' => 'Unix timestamp of when report created.',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
),
),
'primary key' => array('id'),
'indexes' => array(
'type' => array('type'),
'rid' => array('rid'),
),
);
$schema['githubapi_repositories'] = array(
'description' => '{githubapi} repository config.',
'fields' => array(
'id' => array(
'description' => 'Primary Key: Unique repository ID.',
'type' => 'serial',
'not null' => TRUE,
'unsigned' => TRUE,
),
'repo_id' => array(
'description' => 'Repository ID.',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
),
'owner' => array(
'description' => 'Repository owner.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'name' => array(
'description' => 'Repository name.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'private' => array(
'description' => 'Repository private status.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
'cache' => array(
'description' => 'Owner data cache.',
'type' => 'blob',
'size' => 'normal',
'serialize' => TRUE,
),
'timestamp' => array(
'description' => 'Unix timestamp of when cache updated.',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
),
'secret' => array(
'description' => 'Secret key for webhook.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
),
'indexes' => array(
'owner_name' => array('owner', 'name'),
'secret' => array('secret'),
),
'unique keys' => array(
'id' => array('id'),
),
);
$schema['githubapi_hooks'] = array(
'description' => '{githubapi} repository hooks.',
'fields' => array(
'id' => array(
'description' => 'Primary Key: Unique hook ID.',
'type' => 'serial',
'not null' => TRUE,
'unsigned' => TRUE,
),
'rid' => array(
'description' => 'The {githubapi_repositories}.id of the repo for hook.',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
'hook_id' => array(
'description' => 'Hook ID in Github.',
'type' => 'int',
'not null' => TRUE,
),
'child' => array(
'description' => 'Status hook child.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
'timestamp' => array(
'description' => 'Unix timestamp of when hook created.',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
),
),
'indexes' => array(
'rid' => array('rid'),
),
'primary key' => array('id'),
);
return $schema;
}
/**
* Add repository and hook tables. Update payload table to use rid instead of repository.
*/
function githubapi_update_1001() {
$schema = backdrop_get_schema_unprocessed('githubapi');
db_create_table('githubapi_repositories', $schema['githubapi_repositories']);
db_create_table('githubapi_hooks', $schema['githubapi_hooks']);
db_add_field('githubapi_payload', 'rid', $schema['githubapi_payload']['fields']['rid']);
db_drop_field('githubapi_payload', 'repository');
db_add_index('githubapi_payload', 'rid', array('rid'));
}
/**
* Add secret fields to repository.
*/
function githubapi_update_1002() {
$schema = backdrop_get_schema_unprocessed('githubapi');
db_add_field('githubapi_repositories', 'secret', $schema['githubapi_repositories']['fields']['secret']);
db_add_index('githubapi_repositories', 'secret', array('secret'));
}
/**
* Fix secret. It should be varchar.
*/
function githubapi_update_1003() {
$schema = backdrop_get_schema_unprocessed('githubapi');
db_change_field('githubapi_repositories', 'secret', 'secret', $schema['githubapi_repositories']['fields']['secret']);
}