/[drupal]/contributions/modules/planet/planet.install
ViewVC logotype

Contents of /contributions/modules/planet/planet.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download) (as text)
Mon Jun 8 19:22:28 2009 UTC (5 months, 2 weeks ago) by rockyroad
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
Changes since 1.4: +75 -11 lines
File MIME type: text/x-php
[support request] #[476042] by [swe3tdave, RockyRoad]: swe3dave development branch snapshot (2009-03-23)
See ChangeLog (new) file for details.
1 <?php
2 // $Id: planet.install Exp $
3
4 /**
5 * Implementation of hook_schema().
6 */
7
8 function planet_schema() {
9 $schema['planet_feeds'] = array(
10 'description' => t('The base table for planet.'),
11 'fields' => array(
12 'fid' => array(
13 'description' => t('Primary Key: Unique identifier for a planet RSS feed.'),
14 'type' => 'serial',
15 'unsigned' => TRUE,
16 'not null' => TRUE,
17 ),
18 'uid' => array(
19 'description' => t('Foreign key to {users}.uid . Identifies user who choose the feed.'),
20 'type' => 'int',
21 'unsigned' => 1,
22 'not null' => FALSE,
23 ),
24 'title' => array(
25 'type' => 'varchar',
26 'description' => t('Title of the feed.'),
27 'length' => 50,
28 'not null' => TRUE,
29 ),
30 'link' => array(
31 'type' => 'varchar',
32 'description' => t('URL to the feed'),
33 'length' => 80,
34 'not null' => TRUE,
35 ),
36 'image' => array(
37 'description' => t('An image representing the feed'),
38 'type' => 'varchar',
39 'length' => 120,
40 'not null' => FALSE,
41 ),
42 'checked' => array(
43 'description' => t('Last time feed was checked for new items, as Unix timestamp'),
44 'type' => 'int',
45 'not null' => FALSE,
46 ),
47 'frozen' => array(
48 // TODO: add field description 'description' => t(''),
49 'type' => 'int', // TODO change to boolean when supported
50 'not null' => TRUE,
51 'default' => 0,
52 ),
53 'hash' => array(
54 'type' => 'varchar',
55 'length' => 32,
56 'description' => t("A hash of the feed's headers."),
57 ),
58 'error' => array(
59 'type' => 'int',
60 'not null' => TRUE,
61 'default' => 0,
62 'length' => 1,
63 'description' => t("Whether the feed is throwing errors or not."),
64 ),
65 ),
66 'primary key' => array('fid'),
67 'indexes' => array(
68 'error' => array('error'),
69 ),
70 );
71
72 $schema['planet_items'] = array(
73 'description' => t('contain feed id and its corresponding nid'),
74 'fields' => array(
75 'id' => array(
76 'description' => t('Primary key: Unique identifier for a planet feed item'),
77 'type' => 'serial',
78 'unsigned' => 1,
79 'not null' => TRUE,
80 ),
81 'fid' => array(
82 'type' => 'int',
83 'unsigned' => 1,
84 'not null' => FALSE,
85 ),
86 'nid' => array(
87 'type' => 'int',
88 'unsigned' => 1,
89 'not null' => FALSE,
90 ),
91 'iid' => array(
92 'type' => 'varchar',
93 'length' => 32,
94 'not null' => TRUE,
95 'description' => t("md5 of the feed item's title and body."),
96 ),
97 'guid' => array(
98 'type' => 'varchar',
99 'length' => 120,
100 'not null' => FALSE,
101 ),
102 'link' => array(
103 'type' => 'varchar',
104 'length' => 180,
105 'not null' => FALSE,
106 ),
107 'created' => array(
108 'type' => 'int',
109 'not null' => FALSE,
110 ),
111 ),
112 'primary key' => array('id'),
113 );
114
115 return $schema;
116 }
117
118 /**
119 * Implementation of hook_install()
120 *
121 * This will automatically install the database tables for the planet
122 * module, using Drupal's data abstraction layer.
123 *
124 */
125
126 function planet_install() {
127 // Create tables.
128 drupal_install_schema('planet');
129 }
130
131 /**
132 * Implementation of hook_uninstall()
133 *
134 * Uninstalls planet module by removing its own database tables, nodes
135 * and persistent variables.
136 *
137 */
138
139 function planet_uninstall() {
140 variable_del('planet_redirect_page');
141 variable_del('planet_filter_formats');
142 variable_del('planet_author_roles');
143 cache_clear_all('planet:', 'cache', true);
144 drupal_uninstall_schema('planet');
145 db_query("DELETE FROM {node} WHERE type = '%s'", planet);
146
147 }
148
149 function planet_update_1() {
150 $ret = array();
151 db_add_field($ret, 'planet_feeds', 'hash', array(
152 'type' => 'varchar',
153 'length' => 32,
154 'description' => t("A hash of the feed's headers."),
155 )
156 );
157 return $ret;
158 }
159
160 function planet_update_2() {
161 $ret = array();
162 db_add_field($ret, 'planet_items', 'iid', array(
163 'type' => 'varchar',
164 'length' => 32,
165 'not null' => TRUE,
166 'default' => '',
167 'description' => t("md5 of the feed item's title and body."),
168 )
169 );
170 return $ret;
171 }
172
173 function planet_update_3() {
174 $ret = array();
175 db_add_field($ret, 'planet_feeds', 'error', array(
176 'type' => 'int',
177 'not null' => TRUE,
178 'default' => 0,
179 'size' => 'tiny',
180 'description' => t("Whether the feed is throwing errors or not."),
181 )
182 );
183 db_add_index($ret, 'planet_feeds', 'error', array('error'));
184
185 return $ret;
186 }

  ViewVC Help
Powered by ViewVC 1.1.2