-
Notifications
You must be signed in to change notification settings - Fork 8
/
shariff_backend.install
64 lines (56 loc) · 1.54 KB
/
shariff_backend.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
<?php
/**
* @file
* Install, update and uninstall functions for the shariff_backend module.
*/
/**
* Implements hook_schema().
*/
function shariff_backend_schema() {
$schema = [];
$schema['shariff_backend'] = array(
'description' => 'Stores Shariff backend share counts.',
'fields' => array(
'url_hash' => array(
'description' => "A hash of the URL to store Shariff backend share counts for.",
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'timestamp' => array(
'description' => 'A Unix timestamp indicating when this Shariff backend share count was saved.',
'type' => 'int',
'not null' => TRUE,
),
'data' => array(
'description' => 'A JSON array containing the Shariff backend counts.',
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
),
),
'primary key' => array('url_hash'),
'indexes' => array(
'timestamp' => array('timestamp'),
),
);
return $schema;
}
/**
* Create 'shariff_backend' database table.
*/
function shariff_backend_update_8001() {
$database = \Drupal::database();
if (!$database->schema()->tableExists('shariff_backend')) {
drupal_install_schema('shariff_backend');
}
}
/**
* Remove obsolete 'cache_shariff_backend' database table.
*/
function shariff_backend_update_8002() {
$database = \Drupal::database();
if ($database->schema()->tableExists('cache_shariff_backend')) {
$database->schema()->dropTable('cache_shariff_backend');
}
}