summaryrefslogtreecommitdiffstats
path: root/views.install
blob: a698fb0a73eb3dc06d40a034b3cc98a5f96afd27 (plain)
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
<?php
// $Id$
/**
 * @file views.install
 * Contains install and update functions for Views.
 */

function views_install() {
  drupal_set_message('Installing views');
  drupal_install_schema('views');
  db_query("UPDATE {system} SET weight = 10 WHERE name = 'views'");
}

function views_uninstall() {
  drupal_uninstall_schema('views');
}

/**
 * Implementation of hook_schema
 */
function views_schema() {
  $schema['views_view'] = array(
    'description' => t('Stores the general data for a view.'),
    'fields' => array(
      'vid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => t('The view ID of the field, defined by the database.'),
        'no export' => TRUE,
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => '32',
        'default' => '',
        'not null' => TRUE,
        'description' => t('The unique name of the view. This is the primary field views are loaded from, and is used so that views may be internal and not necessarily in the database. May only be alphanumeric characters plus underscores.'),
      ),
      'description' => array(
        'type' => 'varchar',
        'length' => '255',
        'default' => '',
        'description' => t('A description of the view for the admin interface.'),
      ),
      'tag' => array(
        'type' => 'varchar',
        'length' => '255',
        'default' => '',
        'description' => t('A tag used to group/sort views in the admin interface'),
      ),
      'view_php' => array(
        'type' => 'blob',
        'default' => '',
        'description' => t('A chunk of PHP code that can be used to provide modifications to the view prior to building.'),
      ),
      'base_table' => array(
        'type' => 'varchar',
        'length' => '32',
        'default' => '',
        'not null' => TRUE,
        'description' => t('What table this view is based on, such as node, user, comment, or term.'),
      ),
      'is_cacheable' => array(
        'type' => 'int',
        'default' => 0,
        'size' => 'tiny',
        'description' => t('A boolean to indicate whether or not this view may have its query cached.'),
      ),
    ),
    'primary key' => array('vid'),
    'unique key' => array('name' => array('name')),
  );

  $schema['views_display'] = array(
    'description' => t('Stores information about each display attached to a view.'),
    'fields' => array(
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => t('The view this display is attached to.'),
        'no export' => TRUE,
      ),
      'id' => array(
        'type' => 'varchar',
        'length' => '64',
        'default' => '',
        'not null' => TRUE,
        'description' => t('An identifier for this display; usually generated from the display_plugin, so should be something like page or page_1 or block_2, etc.'),
      ),
      'display_title' => array(
        'type' => 'varchar',
        'length' => '64',
        'default' => '',
        'not null' => TRUE,
        'description' => t('The title of the display, viewable by the administrator.'),
      ),
      'display_plugin' => array(
        'type' => 'varchar',
        'length' => '64',
        'default' => '',
        'not null' => TRUE,
        'description' => t('The type of the display. Usually page, block or embed, but is pluggable so may be other things.'),
      ),
      'position' => array(
        'type' => 'int',
        'default' => 0,
        'description' => t('The order in which this display is loaded.'),
      ),
      'display_options' => array(
        'type' => 'blob',
        'description' => t('A serialized array of options for this display; it contains options that are generally only pertinent to that display plugin type.'),
        'serialize' => TRUE,
        'serialized default' => 'a:0:{}',
      ),
    ),
    'indexes' => array('vid' => array('vid', 'position')),
  );

  // This is unfortunately cut & pasted from system.module since cache has no way of
  // telling us what the proper schema is.
  $schema['cache_views'] = array(
    'fields' => array(
      'cid'        => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
      'data'       => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'),
      'expire'     => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
      'created'    => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
      'headers'    => array('type' => 'text', 'not null' => FALSE),
      'serialized' => array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)
    ),
    'indexes' => array('expire' => array('expire')),
    'primary key' => array('cid'),
  );

  $schema['views_object_cache'] = array(
    'description' => t('A special cache used to store objects that are being edited; it serves to save state in an ordinarily stateless environment.'),
    'fields' => array(
      'sid' => array(
        'type' => 'varchar',
        'length' => '64',
        'description' => t('The session ID this cache object belongs to.'),
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => '32',
        'description' => t('The name of the view this cache is attached to.'),
      ),
      'obj' => array(
        'type' => 'varchar',
        'length' => '32',
        'description' => t('The name of the object this cache is attached to; this essentially represents the owner so that several sub-systems can use this cache.'),
      ),
      'updated' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => t('The time this cache was created or updated.'),
      ),
      'data' => array(
        'type' => 'blob',
        'default' => '',
        'description' => t('Serialized data being stored.'),
        'serialize' => TRUE,
      ),
    ),
    'indexes' => array(
      'sid_obj_name' => array('sid', 'obj', 'name'),
      'updated' => array('updated'),
    ),
  );
  return $schema;
}