-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelloworld.install
89 lines (78 loc) · 2.47 KB
/
helloworld.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
<?php
/*
* Implements hook_schema().
*
* @see: https://www.drupal.org/node/876250 (Writing .install files (Drupal 7.x))
* @see: https://www.drupal.org/node/146843 (Schema API)
* @see: https://www.drupal.org/node/159605 (Data types)
* @see: https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_schema/7 (function hook_schema)
*
*/
function helloworld_schema() {
$schema ['helloworld'] = array(
'fields' => array(
'id' => array(
/* serial and int are the same internal column types,
* but serial is also set to be auto-increment, whereas int is not. */
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE
),
'title' => array(
'type' => 'varchar',
'length' => 250,
'not null' => TRUE,
'default' => '',
),
'text' => array(
'type' => 'varchar',
'length' => 250,
'not null' => TRUE,
'default' => '',
),
'timestamp' => array(
'type' => 'int',
'length' => 20,
'not null' => FALSE,
),
),
'primary key' => array('id')
);
return $schema;
}
//function helloworld_install() {
// Set an initial value for the schema version so we can run updates after install.
// http://www.deliciouscreative.com/blog/run-drupal-updates-directly-after-enabling-deployment-module
// drupal_set_installed_schema_version('helloworld', 7000);
// Run all update hooks
// http://dcycleproject.org/blog/43/run-all-update-hooks-install-hook
// for ($i = 7001; $i < 8000; $i++) {
// $candidate = 'helloworld_update_' . $i;
// if (function_exists($candidate)) {
// $candidate();
// }
// }
//}
// Updates:
// @see https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_update_N/7
/**
* Add an additional time column to the hello world table
*/
/*
function helloworld_update_7001() {
// @see: @see: https://www.drupal.org/node/150215
$spec = array(
'type' => 'varchar',
'length' => 20,
'not null' => FALSE,
);
db_add_field( 'helloworld', 'timestamp', $spec);
$time = time();
db_update('helloworld')
->fields(array(
'timestamp' => $time
))
->execute();
}
*/
?>