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

Contents of /contributions/modules/bookreview/bookreview.install

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


Revision 1.1 - (show annotations) (download) (as text)
Thu Jun 15 14:32:33 2006 UTC (3 years, 5 months ago) by jeremy
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5, DRUPAL-4-7
File MIME type: text/x-php
Replace sql scripts with .install file.
1 <?php
2 // $Id: $
3
4 /**
5 * Implementation of hook_install()
6 */
7 function bookreview_install() {
8 global $db_type;
9 switch ($db_type) {
10 case 'mysql':
11 case 'mysqli':
12 db_query("CREATE TABLE bookreview (
13 nid int(10) unsigned NOT NULL,
14 booktitle varchar(255) NOT NULL default '',
15 cover varchar(255) NOT NULL default '',
16 publisher varchar(255) NOT NULL default '',
17 copyright varchar(255) NOT NULL default 0,
18 isbn varchar(255) NOT NULL default '',
19 price varchar(255) NOT NULL default '',
20 pages varchar(255) NOT NULL default 0,
21 rating int(1) NOT NULL default 0,
22 synopsis text,
23 contents text,
24 review text,
25 PRIMARY KEY (nid),
26 KEY (booktitle)
27 );");
28
29 db_query("CREATE TABLE bookreview_links (
30 lid int(10) unsigned NOT NULL auto_increment,
31 nid int(10) unsigned NOT NULL,
32 booklink varchar(255) NOT NULL default '',
33 description varchar(255) NOT NULL default '',
34 weight tinyint DEFAULT '0',
35 KEY (lid),
36 KEY (nid)
37 );");
38
39 db_query("CREATE TABLE bookreview_authors (
40 aid int(10) unsigned NOT NULL auto_increment,
41 nid int(10) unsigned NOT NULL,
42 author varchar(255) NOT NULL default '',
43 weight tinyint DEFAULT '0',
44 KEY (aid),
45 KEY (nid)
46 );");
47 break;
48 case 'pgsql':
49 db_query("CREATE TABLE bookreview (
50 nid integer NOT NULL,
51 booktitle varchar(255) NOT NULL default '',
52 cover varchar(255) NOT NULL default '',
53 publisher varchar(255) NOT NULL default '',
54 copyright varchar(255) NOT NULL default '',
55 isbn varchar(255) NOT NULL default '',
56 price varchar(255) NOT NULL default '',
57 pages varchar(255) NOT NULL default '',
58 rating integer NOT NULL default 0,
59 synopsis text,
60 contents text,
61 review text,
62 PRIMARY KEY (nid)
63 );");
64 db_query("CREATE index bookreview_booktitle on bookreview (booktitle);");
65
66 db_query("CREATE TABLE bookreview_links (
67 lid serial NOT NULL,
68 nid integer NOT NULL,
69 booklink varchar(255) NOT NULL default '',
70 description varchar(255) NOT NULL default '',
71 weight smallint DEFAULT '0'
72 );");
73 db_query("CREATE index bookreview_links_lid on bookreview_links (lid);");
74 db_query("CREATE index bookreview_links_nid on bookreview_links (nid);");
75
76 db_query("CREATE TABLE bookreview_authors (
77 aid serial NOT NULL,
78 nid integer NOT NULL,
79 author varchar(255) NOT NULL default '',
80 weight smallint DEFAULT '0');");
81 db_query("CREATE index bookreview_authors_aid on bookreview_authors (aid);");
82 db_query("CREATE index bookreview_authors_nid on bookreview_authors (nid);");
83 break;
84 }
85 drupal_set_message(t('All tables required by the bookreview module have been created.'));
86 }

  ViewVC Help
Powered by ViewVC 1.1.2