1 -- $Id: schema.psql,v 1.9 2001-09-18 19:16:23 dairiki Exp $
6 --================================================================
7 -- Prefix for table names.
9 -- You should set this to the same value you specify for
10 -- $DBParams['prefix'] in index.php.
14 --================================================================
15 -- Which postgres user gets access to the tables?
17 -- You should set this to the name of the postgres
18 -- user who will be accessing the tables.
20 -- Commonly, connections from php are made under
21 -- the user name of 'nobody' or 'apache'.
23 \set httpd_user 'apache'
25 --================================================================
27 -- Don't modify below this point unless you know what you are doing.
29 --================================================================
31 \set qprefix '\'' :prefix '\''
32 \set qhttp_user '\'' :httpd_user '\''
33 \echo Initializing PhpWiki tables with:
34 \echo ' prefix = ' :qprefix
35 \echo ' httpd_user = ' :qhttp_user
37 \echo 'Expect some \'Relation \'*\' does not exists\' errors unless you are'
38 \echo 'overwriting existing tables.'
40 \set page_tbl :prefix 'page'
41 \set page_id :prefix 'page_id'
42 \set page_nm :prefix 'page_nm'
44 \set version_tbl :prefix 'version'
45 \set vers_id :prefix 'vers_id'
46 \set vers_mtime :prefix 'vers_mtime'
48 \set recent_tbl :prefix 'recent'
49 \set recent_id :prefix 'recent_id'
51 \set nonempty_tbl :prefix 'nonempty'
52 \set nonmt_id :prefix 'nonmt_id'
54 \set link_tbl :prefix 'link'
55 \set link_from :prefix 'link_from'
56 \set link_to :prefix 'link_to'
58 \echo Dropping :page_tbl
60 \echo Creating :page_tbl
61 CREATE TABLE :page_tbl (
63 pagename VARCHAR(100) NOT NULL,
64 hits INT NOT NULL DEFAULT 0,
65 pagedata TEXT NOT NULL DEFAULT ''
67 CREATE UNIQUE INDEX :page_id
69 CREATE UNIQUE INDEX :page_nm
70 ON :page_tbl (pagename);
72 \echo Dropping :version_tbl
73 DROP TABLE :version_tbl;
74 \echo Creating :version_tbl
75 CREATE TABLE :version_tbl (
79 --FIXME: should use boolean, but that returns 't' or 'f'. not 0 or 1.
80 minor_edit INT2 DEFAULT 0,
81 content TEXT NOT NULL DEFAULT '',
82 versiondata TEXT NOT NULL DEFAULT ''
84 CREATE UNIQUE INDEX :vers_id
85 ON :version_tbl (id,version);
86 CREATE INDEX :vers_mtime
87 ON :version_tbl (mtime);
89 \echo Dropping :recent_tbl
90 DROP TABLE :recent_tbl;
91 \echo Creating :recent_tbl
92 CREATE TABLE :recent_tbl (
98 CREATE UNIQUE INDEX :recent_id
102 \echo Dropping :nonempty_tbl
103 DROP TABLE :nonempty_tbl;
104 \echo Creating :nonempty_tbl
105 CREATE TABLE :nonempty_tbl (
108 CREATE UNIQUE INDEX :nonmt_id
109 ON :nonempty_tbl (id);
111 \echo Dropping :link_tbl
112 DROP TABLE :link_tbl;
113 \echo Creating :link_tbl
114 CREATE TABLE :link_tbl (
115 linkfrom INT NOT NULL,
118 CREATE INDEX :link_from ON :link_tbl (linkfrom);
119 CREATE INDEX :link_to ON :link_tbl (linkto);
122 GRANT ALL ON :page_tbl TO :httpd_user;
123 GRANT ALL ON :version_tbl TO :httpd_user;
124 GRANT ALL ON :recent_tbl TO :httpd_user;
125 GRANT ALL ON :nonempty_tbl TO :httpd_user;
126 GRANT ALL ON :link_tbl TO :httpd_user;