Prefix in install script is the same as in runtime scripts
[mailer.git] / install / tables.sql
1 DROP TABLE IF EXISTS `{!prefix!}_admin_menu`;
2 CREATE TABLE `{!prefix!}_admin_menu` (
3   `id` BIGINT(22) NOT NULL AUTO_INCREMENT,
4   `action` VARCHAR(255) NOT NULL DEFAULT '',
5   `what` VARCHAR(255) NULL DEFAULT NULL,
6   `title` VARCHAR(50) NOT NULL DEFAULT '',
7   `sort` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
8   `descr` TEXT NOT NULL,
9   PRIMARY KEY  (`id`)
10 ) TYPE={!type!};
11
12 DROP TABLE IF EXISTS `{!prefix!}_admins`;
13 CREATE TABLE `{!prefix!}_admins` (
14   `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
15   `login` VARCHAR(100) NOT NULL DEFAULT '',
16   `password` VARCHAR(40) NOT NULL DEFAULT '',
17   PRIMARY KEY  (`id`)
18 ) TYPE={!type!};
19
20 DROP TABLE IF EXISTS `{!prefix!}_cats`;
21 CREATE TABLE `{!prefix!}_cats` (
22   `id` BIGINT(22) NOT NULL AUTO_INCREMENT,
23   `cat` VARCHAR(255) NOT NULL DEFAULT '',
24   `visible` ENUM('Y','N') NOT NULL DEFAULT 'Y',
25   `sort` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
26   PRIMARY KEY  (`id`)
27 ) TYPE={!type!};
28
29 DROP TABLE IF EXISTS `{!prefix!}_config`;
30 CREATE TABLE `{!prefix!}_config` (
31   `config` tinyint(1) NOT NULL DEFAULT 0,
32   `pass_len` TINYINT(3) UNSIGNED NOT NULL DEFAULT 5,
33   `points_register` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
34   `points_ref` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
35   `least_cats` TINYINT(3) UNSIGNED NOT NULL DEFAULT 5,
36   `check_double_email` ENUM('Y','N') NOT NULL DEFAULT 'Y',
37   `check_double_pass` ENUM('Y','N') NOT NULL DEFAULT 'N',
38   `admin_notify` ENUM('Y','N') NOT NULL DEFAULT 'Y',
39   `url_tlock` BIGINT(20) UNSIGNED NOT NULL DEFAULT '86400',
40   `test_text` ENUM('Y','N') NOT NULL DEFAULT 'Y',
41   `max_tlength` BIGINT(20) UNSIGNED NOT NULL DEFAULT '1000',
42   `test_subj` ENUM('Y','N') NOT NULL DEFAULT 'Y',
43   `autosend_active` ENUM('Y','N') NOT NULL DEFAULT 'N',
44   PRIMARY KEY  (`config`)
45 ) TYPE={!type!};
46
47 INSERT INTO `{!prefix!}_config` VALUES (0,5,2000,200,5,'Y','N','Y',86400,'Y',1000,'Y','N');
48
49 DROP TABLE IF EXISTS `{!prefix!}_guest_menu`;
50 CREATE TABLE `{!prefix!}_guest_menu` (
51   `id` BIGINT(22) NOT NULL AUTO_INCREMENT,
52   `action` VARCHAR(255) NOT NULL DEFAULT '',
53   `what` VARCHAR(255) NULL DEFAULT NULL,
54   `title` VARCHAR(50) NOT NULL DEFAULT '',
55   `sort` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
56   `visible` ENUM('Y','N') NOT NULL DEFAULT 'Y',
57   `locked` ENUM('Y','N') NOT NULL DEFAULT 'Y',
58   `counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
59   PRIMARY KEY  (`id`)
60 ) TYPE={!type!};
61
62 DROP TABLE IF EXISTS `{!prefix!}_max_receive`;
63 CREATE TABLE `{!prefix!}_max_receive` (
64   `id` BIGINT(22) NOT NULL AUTO_INCREMENT,
65   `value` MEDIUMINT(9) NOT NULL DEFAULT 0,
66   `comment` VARCHAR(255) NOT NULL DEFAULT '',
67   PRIMARY KEY  (`id`)
68 ) TYPE={!type!};
69
70 DROP TABLE IF EXISTS `{!prefix!}_member_menu`;
71 CREATE TABLE `{!prefix!}_member_menu` (
72   `id` BIGINT(22) NOT NULL AUTO_INCREMENT,
73   `action` VARCHAR(255) NOT NULL DEFAULT '',
74   `what` VARCHAR(255) NULL DEFAULT NULL,
75   `title` VARCHAR(50) NOT NULL DEFAULT '',
76   `sort` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
77   `visible` ENUM('Y','N') NOT NULL DEFAULT 'Y',
78   `locked` ENUM('Y','N') NOT NULL DEFAULT 'Y',
79   `counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
80   PRIMARY KEY  (`id`)
81 ) TYPE={!type!};
82
83 DROP TABLE IF EXISTS `{!prefix!}_mod_reg`;
84 CREATE TABLE `{!prefix!}_mod_reg` (
85   `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
86   `module` VARCHAR(50) NOT NULL DEFAULT '',
87   `locked` ENUM('Y','N') NOT NULL DEFAULT 'Y',
88   `hidden` ENUM('Y','N') NOT NULL DEFAULT 'N',
89   `admin_only` ENUM('Y','N') NOT NULL DEFAULT 'N',
90   `title` VARCHAR(200) NOT NULL DEFAULT '',
91   `mem_only` ENUM('Y','N') NOT NULL DEFAULT 'N',
92   `clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
93   PRIMARY KEY  (`id`)
94 ) TYPE={!type!};
95
96 INSERT INTO `{!prefix!}_mod_reg` VALUES (1,'admin','N','N','Y','','N',0);
97 INSERT INTO `{!prefix!}_mod_reg` VALUES (2,'index','N','N','N','','N',0);
98 INSERT INTO `{!prefix!}_mod_reg` VALUES (3,'frameset','Y','N','N','','N',0);
99 INSERT INTO `{!prefix!}_mod_reg` VALUES (4,'login','N','N','N','','Y',0);
100 INSERT INTO `{!prefix!}_mod_reg` VALUES (6,'frametester','N','Y','N','','N',0);
101 INSERT INTO `{!prefix!}_mod_reg` VALUES (7,'loader','N','Y','N','','N',0);
102 INSERT INTO `{!prefix!}_mod_reg` VALUES (8,'order','N','N','N','','N',0);
103
104 DROP TABLE IF EXISTS `{!prefix!}_payments`;
105 CREATE TABLE `{!prefix!}_payments` (
106   `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
107   `time` INT(7) NOT NULL DEFAULT 0,
108   `payment` FLOAT(5,3) UNSIGNED NOT NULL DEFAULT '0.000',
109   `mail_title` VARCHAR(255) NOT NULL DEFAULT '',
110   `price` FLOAT(5,5) UNSIGNED NOT NULL DEFAULT '0.00000',
111   PRIMARY KEY  (`id`)
112 ) TYPE={!type!};
113
114 DROP TABLE IF EXISTS `{!prefix!}_pool`;
115 CREATE TABLE `{!prefix!}_pool` (
116   `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
117   `sender` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
118   `subject` VARCHAR(200) NOT NULL DEFAULT '',
119   `text` LONGTEXT NOT NULL,
120   `receivers` LONGTEXT NOT NULL,
121   `payment_id` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
122   `data_type` ENUM('TEMP','SEND','NEW','ADMIN') NOT NULL DEFAULT 'TEMP',
123   `timestamp` VARCHAR(10) NOT NULL DEFAULT 0,
124   `url` TINYTEXT NOT NULL,
125   `target_send` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
126   `cat_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
127   PRIMARY KEY  (`id`)
128 ) TYPE={!type!};
129
130 DROP TABLE IF EXISTS `{!prefix!}_refbanner`;
131 CREATE TABLE `{!prefix!}_refbanner` (
132   `id` BIGINT(22) NOT NULL AUTO_INCREMENT,
133   `url` TEXT NOT NULL,
134   `alternate` TEXT NOT NULL,
135   `visible` ENUM('Y','N') NOT NULL DEFAULT 'Y',
136   `counter` BIGINT(22) NOT NULL DEFAULT 0,
137   PRIMARY KEY  (`id`)
138 ) TYPE={!type!};
139
140 DROP TABLE IF EXISTS `{!prefix!}_refdepths`;
141 CREATE TABLE `{!prefix!}_refdepths` (
142   `id` TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
143   `level` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
144   `percents` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
145   PRIMARY KEY  (`id`)
146 ) TYPE={!type!};
147
148 INSERT INTO `{!prefix!}_refdepths` VALUES (1,0,100);
149 INSERT INTO `{!prefix!}_refdepths` VALUES (2,1,30);
150 INSERT INTO `{!prefix!}_refdepths` VALUES (3,2,15);
151 INSERT INTO `{!prefix!}_refdepths` VALUES (4,3,10);
152 INSERT INTO `{!prefix!}_refdepths` VALUES (5,4,8);
153 INSERT INTO `{!prefix!}_refdepths` VALUES (6,5,5);
154
155 DROP TABLE IF EXISTS `{!prefix!}_refsystem`;
156 CREATE TABLE `{!prefix!}_refsystem` (
157   `id` BIGINT(22) NOT NULL AUTO_INCREMENT,
158   `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
159   `level` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
160   `counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
161   PRIMARY KEY  (`id`)
162 ) TYPE={!type!};
163
164 ALTER TABLE `{!prefix!}_config` ADD `max_send` TINYINT(3) UNSIGNED NOT NULL DEFAULT '100';
165 ALTER TABLE `{!prefix!}_config` ADD `url_blacklist` ENUM('Y','N') NOT NULL DEFAULT 'Y';
166 ALTER TABLE `{!prefix!}_config` ADD `auto_purge` TINYINT(3) UNSIGNED NOT NULL DEFAULT '14';
167 ALTER TABLE `{!prefix!}_config` ADD `auto_purge_active` ENUM('Y','N') NOT NULL DEFAULT 'Y';
168
169 ALTER TABLE `{!prefix!}_pool` MODIFY `url` TINYTEXT NOT NULL;
170 ALTER TABLE `{!prefix!}_pool` CHANGE `url` `url` TINYTEXT NOT NULL;
171 ALTER TABLE `{!prefix!}_pool` MODIFY `data_type` ENUM('TEMP','SEND','NEW','ADMIN','ACTIVE') NOT NULL DEFAULT 'TEMP';
172
173 ALTER TABLE `{!prefix!}_config` ADD `last_update` VARCHAR(10) NOT NULL DEFAULT 0;
174
175 INSERT INTO `{!prefix!}_mod_reg` VALUES (NULL,'chk_login','N','N','N','','N',0);
176 ALTER TABLE `{!prefix!}_pool` MODIFY `data_type` ENUM('TEMP','SEND','NEW','ADMIN','ACTIVE') NOT NULL DEFAULT 'TEMP';
177 ALTER TABLE `{!prefix!}_config` ADD `unconfirmed` BIGINT(20) UNSIGNED NOT NULL DEFAULT '100';
178 ALTER TABLE `{!prefix!}_config` ADD `profile_lock` BIGINT(20) UNSIGNED NOT NULL DEFAULT '86400';
179 ALTER TABLE `{!prefix!}_refbanner` ADD `clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0;
180 ALTER TABLE `{!prefix!}_config` ADD `online_timeout` BIGINT(20) UNSIGNED NOT NULL DEFAULT '1800';
181
182 ALTER TABLE `{!prefix!}_config` ADD `mad_timestamp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0;
183 ALTER TABLE `{!prefix!}_config` ADD `mad_count` BIGINT(20) UNSIGNED NOT NULL;
184 ALTER TABLE `{!prefix!}_config` ADD `profile_update` BIGINT(20) UNSIGNED NOT NULL DEFAULT '15768000';
185 ALTER TABLE `{!prefix!}_config` ADD `send_prof_update` ENUM('Y','N') NOT NULL DEFAULT 'Y';
186 ALTER TABLE `{!prefix!}_config` ADD `resend_profile_update` BIGINT(20) UNSIGNED NOT NULL DEFAULT '172800';
187
188 ALTER TABLE `{!prefix!}_config` ADD `patch_level` VARCHAR(100) NOT NULL DEFAULT '78';
189 ALTER TABLE `{!prefix!}_config` ADD `patch_ctime` VARCHAR(10) NOT NULL DEFAULT 0;
190
191 ALTER TABLE `{!prefix!}_admins` ADD `email` VARCHAR(255) NOT NULL;
192
193 DROP TABLE IF EXISTS `{!prefix!}_task_system`;
194 CREATE TABLE `{!prefix!}_task_system` (
195   `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
196   `assigned_admin` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
197   `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
198   `status` ENUM('NEW','OPEN','SOLVED','CLOSED','DELETED') NOT NULL DEFAULT 'NEW',
199   `task_type` ENUM('FIRST_USER','SUPPORT_MEMBER','SUPPORT_ADMIN','OTHERS','EXTENSION','EXTENSION_UPDATE') NOT NULL DEFAULT 'FIRST_USER',
200   `subject` VARCHAR(255) NOT NULL DEFAULT '',
201   `text` LONGTEXT NOT NULL,
202   `task_created` VARCHAR(10) NOT NULL DEFAULT 0,
203   KEY (`assigned_admin`),
204   PRIMARY KEY  (`id`)
205 ) TYPE={!type!};
206
207 ALTER TABLE `{!prefix!}_pool` ADD INDEX (`sender`);
208 ALTER TABLE `{!prefix!}_pool` ADD INDEX (`payment_id`);
209 ALTER TABLE `{!prefix!}_pool` ADD INDEX (`cat_id`);
210 ALTER TABLE `{!prefix!}_refsystem` ADD INDEX (`userid`);
211 ALTER TABLE `{!prefix!}_task_system` ADD INDEX (`assigned_admin`);
212 ALTER TABLE `{!prefix!}_task_system` ADD INDEX (`userid`);
213
214 ALTER TABLE `{!prefix!}_config` ADD `code_length` TINYINT(3) UNSIGNED NOT NULL DEFAULT 5;
215 ALTER TABLE `{!prefix!}_config` ADD `guest_stats` ENUM('MEMBERS','MODULES','INACTIVE') NOT NULL DEFAULT 'MEMBERS';
216 ALTER TABLE `{!prefix!}_config` ADD `ref_payout` TINYINT(3) UNSIGNED NOT NULL DEFAULT 5;
217
218 DROP TABLE IF EXISTS `{!prefix!}_extensions`;
219 CREATE TABLE `{!prefix!}_extensions` (
220   `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
221   `ext_name` VARCHAR(255) NOT NULL DEFAULT '',
222   `ext_active` ENUM('Y','N') NOT NULL DEFAULT 'N',
223   `ext_version` VARCHAR(255) NOT NULL DEFAULT 'INVALID',
224   PRIMARY KEY  (`id`)
225 ) TYPE={!type!};
226
227 DROP TABLE IF EXISTS `{!prefix!}_jackpot`;
228 CREATE TABLE `{!prefix!}_jackpot` (
229   `ok` CHAR(2) NOT NULL DEFAULT 'ok',
230   `points` FLOAT(20,3) NOT NULL DEFAULT '0.000',
231   PRIMARY KEY  (`ok`)
232 ) TYPE={!type!};
233
234 ALTER TABLE `{!prefix!}_config` ADD `activate_xchange` BIGINT(20) UNSIGNED NOT NULL DEFAULT 100;
235 ALTER TABLE `{!prefix!}_config` ADD `order_multi_page` ENUM('Y','N') NOT NULL DEFAULT 'Y';
236 ALTER TABLE `{!prefix!}_config` ADD `display_refid` ENUM('Y','N') NOT NULL DEFAULT 'Y';
237 ALTER TABLE `{!prefix!}_config` ADD `ip_timeout` BIGINT(20) UNSIGNED NOT NULL DEFAULT 86400;
238 ALTER TABLE `{!prefix!}_pool` ADD `zip` VARCHAR(6) NOT NULL DEFAULT '';
239
240 ALTER TABLE `{!prefix!}_task_system` CHANGE `task_type` `task_type` VARCHAR(255)  NOT NULL DEFAULT 'FIRST_USER';
241 ALTER TABLE `{!prefix!}_config` ADD `allow_direct_pay` ENUM('Y','N') NOT NULL DEFAULT 'N';