forked from hugowetterberg/sshkey
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sshkey.install
82 lines (74 loc) · 2.05 KB
/
sshkey.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
<?php
function sshkey_install() {
drupal_install_schema('sshkey');
}
function sshkey_uninstall() {
drupal_uninstall_schema('sshkey');
}
function sshkey_schema() {
$schema = array();
$schema['sshkey'] = array(
'description' => 'Stores ssh keys for users',
'fields' => array(
'fingerprint' => array(
'description' => 'The md5 hash for the public key',
'type' => 'char',
'length' => 32,
'not null' => TRUE,
),
'name' => array(
'description' => 'The name of the key file.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => ''
),
'created' => array(
'description' => 'The time that the key was created, as a Unix timestamp.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'obj_type' => array(
'description' => 'The type of object that this key is associated with.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'obj_id' => array(
'description' => 'The object id associated with the public key.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'primary key' => array('fingerprint'),
'indexes' => array(
'obj' => array('obj_type', 'obj_id'),
),
);
return $schema;
}
/**
* Convert all the keys to the new object reference system.
*/
function sshkey_update_6000() {
$ret = array();
db_drop_index($ret, 'sshkey', 'uid');
db_add_field($ret, 'sshkey', 'obj_type', array(
'description' => 'The type of object that this key is associated with.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
));
db_change_field($ret, 'sshkey', 'uid', 'obj_id', array(
'description' => 'The object id associated with the public key.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
));
db_add_index($ret, 'sshkey', 'obj', array('obj_type', 'obj_id'));
return $ret;
}