]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - schemas/sqlsrv-initialize.sql
Allow bold, italics or underlined for numbers
[SourceForge/phpwiki.git] / schemas / sqlsrv-initialize.sql
1 -- UNTESTED!
2
3 -- the CREATE FUNCTION section must be run as a separate query. cut/paste run before executing the remainder
4 -- of the contents of this file
5 CREATE FUNCTION hasContent
6         (@ContentField varchar(max))
7 RETURNS bit
8 AS
9 BEGIN
10
11 IF @ContentField NOT LIKE ''
12         RETURN 1
13 RETURN 0
14
15 END
16 -- end separate section
17
18
19 CREATE TABLE page (
20         id              INT NOT NULL ,
21         pagename        VARCHAR(100) NOT NULL,
22         hits            INT NOT NULL DEFAULT 0,
23         pagedata        TEXT NOT NULL DEFAULT '',
24         cached_html     TEXT NOT NULL DEFAULT '',   -- added with 1.3.11
25         PRIMARY KEY (id),
26         UNIQUE (pagename)
27 );
28 -- SET IDENTITY_INSERT page ON;
29
30 CREATE TABLE version (
31         id              INT NOT NULL,
32         version         INT NOT NULL,
33         mtime           INT NOT NULL,
34         minor_edit      TINYINT DEFAULT 0,
35         content         varchar(max) NOT NULL DEFAULT '', -- can't be text
36         versiondata     TEXT NOT NULL DEFAULT '',
37         PRIMARY KEY (id,version)
38 );
39 CREATE INDEX version_mtime ON version (mtime);
40
41 CREATE TABLE recent (
42         id              INT NOT NULL,
43         latestversion   INT,
44         latestmajor     INT,
45         latestminor     INT,
46         PRIMARY KEY (id)
47 );
48
49 CREATE TABLE nonempty (
50         id              INT NOT NULL,
51         PRIMARY KEY (id)
52 );
53
54 CREATE TABLE link (
55         linkfrom        INT NOT NULL,
56         linkto          INT NOT NULL,
57         relation        INT
58 );
59 CREATE INDEX linkfrom ON link (linkfrom);
60 CREATE INDEX linkto ON link (linkto);
61
62 CREATE TABLE session (
63         sess_id         CHAR(32) NOT NULL DEFAULT '',
64         sess_data       IMAGE NOT NULL,
65         sess_date       BIGINT NOT NULL,
66         sess_ip         CHAR(40) NOT NULL,
67         PRIMARY KEY (sess_id)
68 );
69 CREATE INDEX sessdate_index ON session (sess_date);
70 CREATE INDEX sessip_index ON session (sess_ip);
71
72 -- Optional DB Auth and Prefs
73 -- For these tables below the default table prefix must be used 
74 -- in the DBAuthParam SQL statements also.
75
76 CREATE TABLE pref (
77         userid  CHAR(48) NOT NULL,
78         prefs   TEXT NULL DEFAULT '',
79         passwd  CHAR(48) DEFAULT '',
80         groupname CHAR(48) DEFAULT 'users',
81         PRIMARY KEY (userid)
82 );
83
84 -- update to 1.3.12: (see lib/upgrade.php)
85 -- ALTER TABLE pref ADD passwd  CHAR(48) BINARY DEFAULT '';
86 -- ALTER TABLE pref ADD groupname CHAR(48) BINARY DEFAULT 'users';
87
88 -- deprecated since 1.3.12. only useful for separate databases.
89 -- better use the extra pref table where such users can be created easily 
90 -- without password.
91 -- CREATE TABLE user (
92 --      userid  CHAR(48) NOT NULL,
93 --      passwd  CHAR(48) DEFAULT '',
94 --      prefs   TEXT NULL DEFAULT '',
95 --      groupname CHAR(48) DEFAULT 'users'
96 -- );
97
98 -- Use the member table, if you need it for n:m user-group relations,
99 -- and adjust your DBAUTH_AUTH_ SQL statements.
100 CREATE TABLE member (
101         userid    CHAR(48) NOT NULL,
102         groupname CHAR(48) NOT NULL DEFAULT 'users'
103 );
104 CREATE INDEX member_userid ON member (userid);
105 CREATE INDEX member_groupname ON member (groupname);
106
107 -- only if you plan to use the wikilens theme
108 CREATE TABLE rating (
109         dimension smallINT NOT NULL,
110         raterpage INT NOT NULL,
111         rateepage INT NOT NULL,
112         ratingvalue FLOAT NOT NULL,
113         rateeversion INT NOT NULL,
114         tstamp bigint NOT NULL,
115         PRIMARY KEY (dimension, raterpage, rateepage)
116 );
117 CREATE INDEX rating_dimension ON rating (dimension);
118 CREATE INDEX rating_raterpage ON rating (raterpage);
119 CREATE INDEX rating_rateepage ON rating (rateepage);
120
121 -- if ACCESS_LOG_SQL > 0
122 -- only if you need fast log-analysis (spam prevention, recent referrers)
123 -- see http://www.outoforder.cc/projects/apache/mod_log_sql/docs-2.0/#id2756178
124 CREATE TABLE accesslog (
125         time_stamp    BIGINT,
126         remote_host   VARCHAR(255),
127         remote_user   VARCHAR(50),
128         request_method VARCHAR(10),
129         request_line  text,
130         request_args  text,
131         request_file  text,
132         request_uri   text,
133         request_time  CHAR(28),
134         status        INT,
135         bytes_sent    INT,
136         referer       text, 
137         agent         text,
138         request_duration FLOAT
139 );
140 CREATE INDEX log_time ON accesslog (time_stamp);
141 CREATE INDEX log_host ON accesslog (remote_host);
142 -- create extra indices on demand (usually referer. see plugin/AccessLogSql)
143