UI saves! Simple view even works again!
[project/views.git] / views.install
1 <?php
2 // $Id$
3 /**
4 * @file views.install
5 * Contains install and update functions for Views.
6 */
7
8 function views_install() {
9 drupal_set_message('Installing views');
10 drupal_install_schema('views');
11 db_query("UPDATE {system} SET weight = 10 WHERE name = 'views'");
12 }
13
14 function views_uninstall() {
15 drupal_uninstall_schema('views');
16 }
17
18 /**
19 * Implementation of hook_schema
20 */
21 function views_schema() {
22 $schema['views_view'] = array(
23 'description' => t('Stores the general data for a view.'),
24 'fields' => array(
25 'vid' => array(
26 'type' => 'serial',
27 'unsigned' => TRUE,
28 'not null' => TRUE,
29 'description' => t('The view ID of the field, defined by the database.'),
30 'no export' => TRUE,
31 ),
32 'name' => array(
33 'type' => 'varchar',
34 'length' => '32',
35 'default' => '',
36 'not null' => TRUE,
37 '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.'),
38 ),
39 'description' => array(
40 'type' => 'varchar',
41 'length' => '255',
42 'default' => '',
43 'description' => t('A description of the view for the admin interface.'),
44 ),
45 'tag' => array(
46 'type' => 'varchar',
47 'length' => '255',
48 'default' => '',
49 'description' => t('A tag used to group/sort views in the admin interface'),
50 ),
51 'view_php' => array(
52 'type' => 'blob',
53 'default' => '',
54 'description' => t('A chunk of PHP code that can be used to provide modifications to the view prior to building.'),
55 ),
56 'base_table' => array(
57 'type' => 'varchar',
58 'length' => '32',
59 'default' => '',
60 'not null' => TRUE,
61 'description' => t('What table this view is based on, such as node, user, comment, or term.'),
62 ),
63 'is_cacheable' => array(
64 'type' => 'int',
65 'default' => 0,
66 'size' => 'tiny',
67 'description' => t('A boolean to indicate whether or not this view may have its query cached.'),
68 ),
69 ),
70 'primary key' => array('vid'),
71 'unique key' => array('name' => array('name')),
72 );
73
74 $schema['views_display'] = array(
75 'description' => t('Stores information about each display attached to a view.'),
76 'fields' => array(
77 'vid' => array(
78 'type' => 'int',
79 'unsigned' => TRUE,
80 'not null' => TRUE,
81 'default' => 0,
82 'description' => t('The view this display is attached to.'),
83 'no export' => TRUE,
84 ),
85 'id' => array(
86 'type' => 'varchar',
87 'length' => '64',
88 'default' => '',
89 'not null' => TRUE,
90 '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.'),
91 ),
92 'display_title' => array(
93 'type' => 'varchar',
94 'length' => '64',
95 'default' => '',
96 'not null' => TRUE,
97 'description' => t('The title of the display, viewable by the administrator.'),
98 ),
99 'display_plugin' => array(
100 'type' => 'varchar',
101 'length' => '64',
102 'default' => '',
103 'not null' => TRUE,
104 'description' => t('The type of the display. Usually page, block or embed, but is pluggable so may be other things.'),
105 ),
106 'position' => array(
107 'type' => 'int',
108 'default' => 0,
109 'description' => t('The order in which this display is loaded.'),
110 ),
111 'display_options' => array(
112 'type' => 'blob',
113 'description' => t('A serialized array of options for this display; it contains options that are generally only pertinent to that display plugin type.'),
114 'serialize' => TRUE,
115 'serialized default' => 'a:0:{}',
116 ),
117 ),
118 'indexes' => array('vid' => array('vid', 'position')),
119 );
120
121 // This is unfortunately cut & pasted from system.module since cache has no way of
122 // telling us what the proper schema is.
123 $schema['cache_views'] = array(
124 'fields' => array(
125 'cid' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
126 'data' => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'),
127 'expire' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
128 'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
129 'headers' => array('type' => 'text', 'not null' => FALSE),
130 'serialized' => array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)
131 ),
132 'indexes' => array('expire' => array('expire')),
133 'primary key' => array('cid'),
134 );
135
136 $schema['views_object_cache'] = array(
137 'description' => t('A special cache used to store objects that are being edited; it serves to save state in an ordinarily stateless environment.'),
138 'fields' => array(
139 'sid' => array(
140 'type' => 'varchar',
141 'length' => '64',
142 'description' => t('The session ID this cache object belongs to.'),
143 ),
144 'name' => array(
145 'type' => 'varchar',
146 'length' => '32',
147 'description' => t('The name of the view this cache is attached to.'),
148 ),
149 'obj' => array(
150 'type' => 'varchar',
151 'length' => '32',
152 '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.'),
153 ),
154 'updated' => array(
155 'type' => 'int',
156 'unsigned' => TRUE,
157 'not null' => TRUE,
158 'default' => 0,
159 'description' => t('The time this cache was created or updated.'),
160 ),
161 'data' => array(
162 'type' => 'blob',
163 'default' => '',
164 'description' => t('Serialized data being stored.'),
165 'serialize' => TRUE,
166 ),
167 ),
168 'indexes' => array(
169 'sid_obj_name' => array('sid', 'obj', 'name'),
170 'updated' => array('updated'),
171 ),
172 );
173 return $schema;
174 }