]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - tests/unit/mysql-test-initialize.sql
new tables, better options handling
[SourceForge/phpwiki.git] / tests / unit / mysql-test-initialize.sql
1 -- $Id: mysql-test-initialize.sql,v 1.2 2004-11-15 16:53:01 rurban Exp $
2 -- for the regression suite
3
4 drop table if exists test_page;
5 drop table if exists test_version;
6 drop table if exists test_recent;
7 drop table if exists test_nonempty;
8 drop table if exists test_link;
9 drop table if exists test_session;
10
11 -- since 1.3.7:
12
13 drop table if exists test_pref;
14 drop table if exists test_user;
15 drop table if exists test_member;
16
17 drop table if exists test_rating;
18 drop table if exists test_accesslog;
19
20 CREATE TABLE test_page (
21         id              INT NOT NULL AUTO_INCREMENT,
22         pagename        VARCHAR(100) BINARY NOT NULL,
23         hits            INT NOT NULL DEFAULT 0,
24         pagedata        MEDIUMTEXT NOT NULL DEFAULT '',
25         PRIMARY KEY (id),
26         UNIQUE KEY (pagename)
27 );
28
29 CREATE TABLE test_version (
30         id              INT NOT NULL,
31         version         INT NOT NULL,
32         mtime           INT NOT NULL,
33         minor_edit      TINYINT DEFAULT 0,
34         content         MEDIUMTEXT NOT NULL DEFAULT '',
35         versiondata     MEDIUMTEXT NOT NULL DEFAULT '',
36         PRIMARY KEY (id,version),
37         INDEX (mtime)
38 );
39
40 CREATE TABLE test_recent (
41         id              INT NOT NULL,
42         latestversion   INT,
43         latestmajor     INT,
44         latestminor     INT,
45         PRIMARY KEY (id)
46 );
47
48 CREATE TABLE test_nonempty (
49         id              INT NOT NULL,
50         PRIMARY KEY (id)
51 );
52
53 CREATE TABLE test_link (
54         linkfrom        INT NOT NULL,
55         linkto          INT NOT NULL,
56         INDEX (linkfrom),
57         INDEX (linkto)
58 );
59
60 CREATE TABLE test_session (
61         sess_id         CHAR(32) NOT NULL DEFAULT '',
62         sess_data       BLOB NOT NULL,
63         sess_date       INT UNSIGNED NOT NULL,
64         sess_ip         CHAR(15) NOT NULL,
65         PRIMARY KEY (sess_id),
66         INDEX (sess_date)
67 ); -- TYPE=heap; -- if your Mysql supports it and you have enough RAM
68
69 -- upgrade to 1.3.8: (see lib/upgrade.php)
70 -- ALTER TABLE session ADD sess_ip CHAR(15) NOT NULL;
71 -- CREATE INDEX sess_date on session (sess_date);
72 -- update to 1.3.10: (see lib/upgrade.php)
73 -- ALTER TABLE page CHANGE id id INT NOT NULL AUTO_INCREMENT;
74
75 -- Optional DB Auth and Prefs
76 -- For these tables below the default table prefix must be used 
77 -- in the DBAuthParam SQL statements also.
78
79 CREATE TABLE test_pref (
80         userid  CHAR(48) BINARY NOT NULL UNIQUE,
81         prefs   TEXT NULL DEFAULT '',
82         PRIMARY KEY (userid)
83 ) TYPE=MyISAM;
84
85 -- better use the extra pref table where such users can be created easily 
86 -- without password.
87 CREATE TABLE test_user (
88         userid  CHAR(48) BINARY NOT NULL UNIQUE,
89         passwd  CHAR(48) BINARY DEFAULT '',
90 --      prefs   TEXT NULL DEFAULT '',
91 --      groupname CHAR(48) BINARY DEFAULT 'users',
92         PRIMARY KEY (userid)
93 ) TYPE=MyISAM;
94
95 -- only if you plan to use the wikilens theme
96 CREATE TABLE test_rating (
97         dimension INT(4) NOT NULL,
98         raterpage INT(11) NOT NULL,
99         rateepage INT(11) NOT NULL,
100         ratingvalue FLOAT NOT NULL,
101         rateeversion INT(11) NOT NULL,
102         tstamp TIMESTAMP(14) NOT NULL,
103         PRIMARY KEY (dimension, raterpage, rateepage)
104 );
105
106 -- only if you need fast log-analysis (spam prevention, recent referrers)
107 -- see http://www.outoforder.cc/projects/apache/mod_log_sql/docs-2.0/#id2756178
108 CREATE TABLE test_accesslog (
109         time_stamp    int unsigned,
110         remote_host   varchar(50),
111         remote_user   varchar(50),
112         request_method varchar(10),
113         request_line  varchar(255),
114         request_args  varchar(255),
115         request_file  varchar(255),
116         request_uri   varchar(255),
117         request_time  char(28),
118         status        smallint unsigned,
119         bytes_sent    smallint unsigned,
120         referer       varchar(255), 
121         agent         varchar(255),
122         request_duration float
123 );
124 CREATE INDEX log_time ON test_accesslog (time_stamp);
125 CREATE INDEX log_host ON test_accesslog (remote_host);