aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/install/schemas/firebird_schema.sql
blob: 8b5bc90afaad521c17083cc6395284289327f17a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
# DO NOT EDIT THIS FILE, IT IS GENERATED
#
# To change the contents of this file, edit
# phpBB/develop/create_schema_files.php and
# run it.

# Table: 'phpbb_attachments'
CREATE TABLE phpbb_attachments (
	attach_id INTEGER NOT NULL,
	post_msg_id INTEGER DEFAULT 0 NOT NULL,
	topic_id INTEGER DEFAULT 0 NOT NULL,
	in_message INTEGER DEFAULT 0 NOT NULL,
	poster_id INTEGER DEFAULT 0 NOT NULL,
	is_orphan INTEGER DEFAULT 1 NOT NULL,
	physical_filename VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	real_filename VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	download_count INTEGER DEFAULT 0 NOT NULL,
	attach_comment BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	extension VARCHAR(100) CHARACTER SET NONE DEFAULT '' NOT NULL,
	mimetype VARCHAR(100) CHARACTER SET NONE DEFAULT '' NOT NULL,
	filesize INTEGER DEFAULT 0 NOT NULL,
	filetime INTEGER DEFAULT 0 NOT NULL,
	thumbnail INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_attachments ADD PRIMARY KEY (attach_id);;

CREATE INDEX phpbb_attachments_filetime ON phpbb_attachments(filetime);;
CREATE INDEX phpbb_attachments_post_msg_id ON phpbb_attachments(post_msg_id);;
CREATE INDEX phpbb_attachments_topic_id ON phpbb_attachments(topic_id);;
CREATE INDEX phpbb_attachments_poster_id ON phpbb_attachments(poster_id);;
CREATE INDEX phpbb_attachments_is_orphan ON phpbb_attachments(is_orphan);;

CREATE GENERATOR phpbb_attachments_gen;;
SET GENERATOR phpbb_attachments_gen TO 0;;

CREATE TRIGGER t_phpbb_attachments FOR phpbb_attachments
BEFORE INSERT
AS
BEGIN
	NEW.attach_id = GEN_ID(phpbb_attachments_gen, 1);
END;;


# Table: 'phpbb_acl_groups'
CREATE TABLE phpbb_acl_groups (
	group_id INTEGER DEFAULT 0 NOT NULL,
	forum_id INTEGER DEFAULT 0 NOT NULL,
	auth_option_id INTEGER DEFAULT 0 NOT NULL,
	auth_role_id INTEGER DEFAULT 0 NOT NULL,
	auth_setting INTEGER DEFAULT 0 NOT NULL
);;

CREATE INDEX phpbb_acl_groups_group_id ON phpbb_acl_groups(group_id);;
CREATE INDEX phpbb_acl_groups_auth_opt_id ON phpbb_acl_groups(auth_option_id);;
CREATE INDEX phpbb_acl_groups_auth_role_id ON phpbb_acl_groups(auth_role_id);;

# Table: 'phpbb_acl_options'
CREATE TABLE phpbb_acl_options (
	auth_option_id INTEGER NOT NULL,
	auth_option VARCHAR(50) CHARACTER SET NONE DEFAULT '' NOT NULL,
	is_global INTEGER DEFAULT 0 NOT NULL,
	is_local INTEGER DEFAULT 0 NOT NULL,
	founder_only INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_acl_options ADD PRIMARY KEY (auth_option_id);;

CREATE UNIQUE INDEX phpbb_acl_options_auth_option ON phpbb_acl_options(auth_option);;

CREATE GENERATOR phpbb_acl_options_gen;;
SET GENERATOR phpbb_acl_options_gen TO 0;;

CREATE TRIGGER t_phpbb_acl_options FOR phpbb_acl_options
BEFORE INSERT
AS
BEGIN
	NEW.auth_option_id = GEN_ID(phpbb_acl_options_gen, 1);
END;;


# Table: 'phpbb_acl_roles'
CREATE TABLE phpbb_acl_roles (
	role_id INTEGER NOT NULL,
	role_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	role_description BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	role_type VARCHAR(10) CHARACTER SET NONE DEFAULT '' NOT NULL,
	role_order INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_acl_roles ADD PRIMARY KEY (role_id);;

CREATE INDEX phpbb_acl_roles_role_type ON phpbb_acl_roles(role_type);;
CREATE INDEX phpbb_acl_roles_role_order ON phpbb_acl_roles(role_order);;

CREATE GENERATOR phpbb_acl_roles_gen;;
SET GENERATOR phpbb_acl_roles_gen TO 0;;

CREATE TRIGGER t_phpbb_acl_roles FOR phpbb_acl_roles
BEFORE INSERT
AS
BEGIN
	NEW.role_id = GEN_ID(phpbb_acl_roles_gen, 1);
END;;


# Table: 'phpbb_acl_roles_data'
CREATE TABLE phpbb_acl_roles_data (
	role_id INTEGER DEFAULT 0 NOT NULL,
	auth_option_id INTEGER DEFAULT 0 NOT NULL,
	auth_setting INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_acl_roles_data ADD PRIMARY KEY (role_id, auth_option_id);;

CREATE INDEX phpbb_acl_roles_data_ath_op_id ON phpbb_acl_roles_data(auth_option_id);;

# Table: 'phpbb_acl_users'
CREATE TABLE phpbb_acl_users (
	user_id INTEGER DEFAULT 0 NOT NULL,
	forum_id INTEGER DEFAULT 0 NOT NULL,
	auth_option_id INTEGER DEFAULT 0 NOT NULL,
	auth_role_id INTEGER DEFAULT 0 NOT NULL,
	auth_setting INTEGER DEFAULT 0 NOT NULL
);;

CREATE INDEX phpbb_acl_users_user_id ON phpbb_acl_users(user_id);;
CREATE INDEX phpbb_acl_users_auth_option_id ON phpbb_acl_users(auth_option_id);;
CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users(auth_role_id);;

# Table: 'phpbb_banlist'
CREATE TABLE phpbb_banlist (
	ban_id INTEGER NOT NULL,
	ban_userid INTEGER DEFAULT 0 NOT NULL,
	ban_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL,
	ban_email VARCHAR(100) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	ban_start INTEGER DEFAULT 0 NOT NULL,
	ban_end INTEGER DEFAULT 0 NOT NULL,
	ban_exclude INTEGER DEFAULT 0 NOT NULL,
	ban_reason VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	ban_give_reason VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE
);;

ALTER TABLE phpbb_banlist ADD PRIMARY KEY (ban_id);;

CREATE INDEX phpbb_banlist_ban_end ON phpbb_banlist(ban_end);;
CREATE INDEX phpbb_banlist_ban_user ON phpbb_banlist(ban_userid, ban_exclude);;
CREATE INDEX phpbb_banlist_ban_email ON phpbb_banlist(ban_email, ban_exclude);;
CREATE INDEX phpbb_banlist_ban_ip ON phpbb_banlist(ban_ip, ban_exclude);;

CREATE GENERATOR phpbb_banlist_gen;;
SET GENERATOR phpbb_banlist_gen TO 0;;

CREATE TRIGGER t_phpbb_banlist FOR phpbb_banlist
BEFORE INSERT
AS
BEGIN
	NEW.ban_id = GEN_ID(phpbb_banlist_gen, 1);
END;;


# Table: 'phpbb_bbcodes'
CREATE TABLE phpbb_bbcodes (
	bbcode_id INTEGER DEFAULT 0 NOT NULL,
	bbcode_tag VARCHAR(16) CHARACTER SET NONE DEFAULT '' NOT NULL,
	bbcode_helpline VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	display_on_posting INTEGER DEFAULT 0 NOT NULL,
	bbcode_match BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	bbcode_tpl BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	first_pass_match BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	first_pass_replace BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	second_pass_match BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	second_pass_replace BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL
);;

ALTER TABLE phpbb_bbcodes ADD PRIMARY KEY (bbcode_id);;

CREATE INDEX phpbb_bbcodes_display_on_post ON phpbb_bbcodes(display_on_posting);;

# Table: 'phpbb_bookmarks'
CREATE TABLE phpbb_bookmarks (
	topic_id INTEGER DEFAULT 0 NOT NULL,
	user_id INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_bookmarks ADD PRIMARY KEY (topic_id, user_id);;


# Table: 'phpbb_bots'
CREATE TABLE phpbb_bots (
	bot_id INTEGER NOT NULL,
	bot_active INTEGER DEFAULT 1 NOT NULL,
	bot_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	user_id INTEGER DEFAULT 0 NOT NULL,
	bot_agent VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	bot_ip VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL
);;

ALTER TABLE phpbb_bots ADD PRIMARY KEY (bot_id);;

CREATE INDEX phpbb_bots_bot_active ON phpbb_bots(bot_active);;

CREATE GENERATOR phpbb_bots_gen;;
SET GENERATOR phpbb_bots_gen TO 0;;

CREATE TRIGGER t_phpbb_bots FOR phpbb_bots
BEFORE INSERT
AS
BEGIN
	NEW.bot_id = GEN_ID(phpbb_bots_gen, 1);
END;;


# Table: 'phpbb_config'
CREATE TABLE phpbb_config (
	config_name VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	config_value VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	is_dynamic INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_config ADD PRIMARY KEY (config_name);;

CREATE INDEX phpbb_config_is_dynamic ON phpbb_config(is_dynamic);;

# Table: 'phpbb_confirm'
CREATE TABLE phpbb_confirm (
	confirm_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL,
	session_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL,
	confirm_type INTEGER DEFAULT 0 NOT NULL,
	code VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL,
	seed INTEGER DEFAULT 0 NOT NULL,
	attempts INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_confirm ADD PRIMARY KEY (session_id, confirm_id);;

CREATE INDEX phpbb_confirm_confirm_type ON phpbb_confirm(confirm_type);;

# Table: 'phpbb_disallow'
CREATE TABLE phpbb_disallow (
	disallow_id INTEGER NOT NULL,
	disallow_username VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE
);;

ALTER TABLE phpbb_disallow ADD PRIMARY KEY (disallow_id);;


CREATE GENERATOR phpbb_disallow_gen;;
SET GENERATOR phpbb_disallow_gen TO 0;;

CREATE TRIGGER t_phpbb_disallow FOR phpbb_disallow
BEFORE INSERT
AS
BEGIN
	NEW.disallow_id = GEN_ID(phpbb_disallow_gen, 1);
END;;


# Table: 'phpbb_drafts'
CREATE TABLE phpbb_drafts (
	draft_id INTEGER NOT NULL,
	user_id INTEGER DEFAULT 0 NOT NULL,
	topic_id INTEGER DEFAULT 0 NOT NULL,
	forum_id INTEGER DEFAULT 0 NOT NULL,
	save_time INTEGER DEFAULT 0 NOT NULL,
	draft_subject VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	draft_message BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL
);;

ALTER TABLE phpbb_drafts ADD PRIMARY KEY (draft_id);;

CREATE INDEX phpbb_drafts_save_time ON phpbb_drafts(save_time);;

CREATE GENERATOR phpbb_drafts_gen;;
SET GENERATOR phpbb_drafts_gen TO 0;;

CREATE TRIGGER t_phpbb_drafts FOR phpbb_drafts
BEFORE INSERT
AS
BEGIN
	NEW.draft_id = GEN_ID(phpbb_drafts_gen, 1);
END;;


# Table: 'phpbb_ext'
CREATE TABLE phpbb_ext (
	ext_name VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	ext_active INTEGER DEFAULT 0 NOT NULL,
	ext_state BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL
);;

CREATE UNIQUE INDEX phpbb_ext_ext_name ON phpbb_ext(ext_name);;

# Table: 'phpbb_extensions'
CREATE TABLE phpbb_extensions (
	extension_id INTEGER NOT NULL,
	group_id INTEGER DEFAULT 0 NOT NULL,
	extension VARCHAR(100) CHARACTER SET NONE DEFAULT '' NOT NULL
);;

ALTER TABLE phpbb_extensions ADD PRIMARY KEY (extension_id);;


CREATE GENERATOR phpbb_extensions_gen;;
SET GENERATOR phpbb_extensions_gen TO 0;;

CREATE TRIGGER t_phpbb_extensions FOR phpbb_extensions
BEFORE INSERT
AS
BEGIN
	NEW.extension_id = GEN_ID(phpbb_extensions_gen, 1);
END;;


# Table: 'phpbb_extension_groups'
CREATE TABLE phpbb_extension_groups (
	group_id INTEGER NOT NULL,
	group_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	cat_id INTEGER DEFAULT 0 NOT NULL,
	allow_group INTEGER DEFAULT 0 NOT NULL,
	download_mode INTEGER DEFAULT 1 NOT NULL,
	upload_icon VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	max_filesize INTEGER DEFAULT 0 NOT NULL,
	allowed_forums BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL,
	allow_in_pm INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_extension_groups ADD PRIMARY KEY (group_id);;


CREATE GENERATOR phpbb_extension_groups_gen;;
SET GENERATOR phpbb_extension_groups_gen TO 0;;

CREATE TRIGGER t_phpbb_extension_groups FOR phpbb_extension_groups
BEFORE INSERT
AS
BEGIN
	NEW.group_id = GEN_ID(phpbb_extension_groups_gen, 1);
END;;


# Table: 'phpbb_forums'
CREATE TABLE phpbb_forums (
	forum_id INTEGER NOT NULL,
	parent_id INTEGER DEFAULT 0 NOT NULL,
	left_id INTEGER DEFAULT 0 NOT NULL,
	right_id INTEGER DEFAULT 0 NOT NULL,
	forum_parents BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL,
	forum_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	forum_desc BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	forum_desc_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	forum_desc_options INTEGER DEFAULT 7 NOT NULL,
	forum_desc_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL,
	forum_link VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	forum_password VARCHAR(40) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	forum_style INTEGER DEFAULT 0 NOT NULL,
	forum_image VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	forum_rules BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	forum_rules_link VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	forum_rules_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	forum_rules_options INTEGER DEFAULT 7 NOT NULL,
	forum_rules_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL,
	forum_topics_per_page INTEGER DEFAULT 0 NOT NULL,
	forum_type INTEGER DEFAULT 0 NOT NULL,
	forum_status INTEGER DEFAULT 0 NOT NULL,
	forum_posts INTEGER DEFAULT 0 NOT NULL,
	forum_topics INTEGER DEFAULT 0 NOT NULL,
	forum_topics_real INTEGER DEFAULT 0 NOT NULL,
	forum_last_post_id INTEGER DEFAULT 0 NOT NULL,
	forum_last_poster_id INTEGER DEFAULT 0 NOT NULL,
	forum_last_post_subject VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	forum_last_post_time INTEGER DEFAULT 0 NOT NULL,
	forum_last_poster_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	forum_last_poster_colour VARCHAR(6) CHARACTER SET NONE DEFAULT '' NOT NULL,
	forum_flags INTEGER DEFAULT 32 NOT NULL,
	forum_options INTEGER DEFAULT 0 NOT NULL,
	display_subforum_list INTEGER DEFAULT 1 NOT NULL,
	display_on_index INTEGER DEFAULT 1 NOT NULL,
	enable_indexing INTEGER DEFAULT 1 NOT NULL,
	enable_icons INTEGER DEFAULT 1 NOT NULL,
	enable_prune INTEGER DEFAULT 0 NOT NULL,
	prune_next INTEGER DEFAULT 0 NOT NULL,
	prune_days INTEGER DEFAULT 0 NOT NULL,
	prune_viewed INTEGER DEFAULT 0 NOT NULL,
	prune_freq INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_forums ADD PRIMARY KEY (forum_id);;

CREATE INDEX phpbb_forums_left_right_id ON phpbb_forums(left_id, right_id);;
CREATE INDEX phpbb_forums_forum_lastpost_id ON phpbb_forums(forum_last_post_id);;

CREATE GENERATOR phpbb_forums_gen;;
SET GENERATOR phpbb_forums_gen TO 0;;

CREATE TRIGGER t_phpbb_forums FOR phpbb_forums
BEFORE INSERT
AS
BEGIN
	NEW.forum_id = GEN_ID(phpbb_forums_gen, 1);
END;;


# Table: 'phpbb_forums_access'
CREATE TABLE phpbb_forums_access (
	forum_id INTEGER DEFAULT 0 NOT NULL,
	user_id INTEGER DEFAULT 0 NOT NULL,
	session_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL
);;

ALTER TABLE phpbb_forums_access ADD PRIMARY KEY (forum_id, user_id, session_id);;


# Table: 'phpbb_forums_track'
CREATE TABLE phpbb_forums_track (
	user_id INTEGER DEFAULT 0 NOT NULL,
	forum_id INTEGER DEFAULT 0 NOT NULL,
	mark_time INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_forums_track ADD PRIMARY KEY (user_id, forum_id);;


# Table: 'phpbb_forums_watch'
CREATE TABLE phpbb_forums_watch (
	forum_id INTEGER DEFAULT 0 NOT NULL,
	user_id INTEGER DEFAULT 0 NOT NULL,
	notify_status INTEGER DEFAULT 0 NOT NULL
);;

CREATE INDEX phpbb_forums_watch_forum_id ON phpbb_forums_watch(forum_id);;
CREATE INDEX phpbb_forums_watch_user_id ON phpbb_forums_watch(user_id);;
CREATE INDEX phpbb_forums_watch_notify_stat ON phpbb_forums_watch(notify_status);;

# Table: 'phpbb_groups'
CREATE TABLE phpbb_groups (
	group_id INTEGER NOT NULL,
	group_type INTEGER DEFAULT 1 NOT NULL,
	group_founder_manage INTEGER DEFAULT 0 NOT NULL,
	group_skip_auth INTEGER DEFAULT 0 NOT NULL,
	group_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	group_desc BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	group_desc_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	group_desc_options INTEGER DEFAULT 7 NOT NULL,
	group_desc_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL,
	group_display INTEGER DEFAULT 0 NOT NULL,
	group_avatar VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	group_avatar_type VARCHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL,
	group_avatar_width INTEGER DEFAULT 0 NOT NULL,
	group_avatar_height INTEGER DEFAULT 0 NOT NULL,
	group_rank INTEGER DEFAULT 0 NOT NULL,
	group_colour VARCHAR(6) CHARACTER SET NONE DEFAULT '' NOT NULL,
	group_sig_chars INTEGER DEFAULT 0 NOT NULL,
	group_receive_pm INTEGER DEFAULT 0 NOT NULL,
	group_message_limit INTEGER DEFAULT 0 NOT NULL,
	group_max_recipients INTEGER DEFAULT 0 NOT NULL,
	group_legend INTEGER DEFAULT 0 NOT NULL,
	group_teampage INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_groups ADD PRIMARY KEY (group_id);;

CREATE INDEX phpbb_groups_group_legend_name ON phpbb_groups(group_legend, group_name);;

CREATE GENERATOR phpbb_groups_gen;;
SET GENERATOR phpbb_groups_gen TO 0;;

CREATE TRIGGER t_phpbb_groups FOR phpbb_groups
BEFORE INSERT
AS
BEGIN
	NEW.group_id = GEN_ID(phpbb_groups_gen, 1);
END;;


# Table: 'phpbb_icons'
CREATE TABLE phpbb_icons (
	icons_id INTEGER NOT NULL,
	icons_url VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	icons_width INTEGER DEFAULT 0 NOT NULL,
	icons_height INTEGER DEFAULT 0 NOT NULL,
	icons_order INTEGER DEFAULT 0 NOT NULL,
	display_on_posting INTEGER DEFAULT 1 NOT NULL
);;

ALTER TABLE phpbb_icons ADD PRIMARY KEY (icons_id);;

CREATE INDEX phpbb_icons_display_on_posting ON phpbb_icons(display_on_posting);;

CREATE GENERATOR phpbb_icons_gen;;
SET GENERATOR phpbb_icons_gen TO 0;;

CREATE TRIGGER t_phpbb_icons FOR phpbb_icons
BEFORE INSERT
AS
BEGIN
	NEW.icons_id = GEN_ID(phpbb_icons_gen, 1);
END;;


# Table: 'phpbb_lang'
CREATE TABLE phpbb_lang (
	lang_id INTEGER NOT NULL,
	lang_iso VARCHAR(30) CHARACTER SET NONE DEFAULT '' NOT NULL,
	lang_dir VARCHAR(30) CHARACTER SET NONE DEFAULT '' NOT NULL,
	lang_english_name VARCHAR(100) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	lang_local_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	lang_author VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE
);;

ALTER TABLE phpbb_lang ADD PRIMARY KEY (lang_id);;

CREATE INDEX phpbb_lang_lang_iso ON phpbb_lang(lang_iso);;

CREATE GENERATOR phpbb_lang_gen;;
SET GENERATOR phpbb_lang_gen TO 0;;

CREATE TRIGGER t_phpbb_lang FOR phpbb_lang
BEFORE INSERT
AS
BEGIN
	NEW.lang_id = GEN_ID(phpbb_lang_gen, 1);
END;;


# Table: 'phpbb_log'
CREATE TABLE phpbb_log (
	log_id INTEGER NOT NULL,
	log_type INTEGER DEFAULT 0 NOT NULL,
	user_id INTEGER DEFAULT 0 NOT NULL,
	forum_id INTEGER DEFAULT 0 NOT NULL,
	topic_id INTEGER DEFAULT 0 NOT NULL,
	reportee_id INTEGER DEFAULT 0 NOT NULL,
	log_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL,
	log_time INTEGER DEFAULT 0 NOT NULL,
	log_operation BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	log_data BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL
);;

ALTER TABLE phpbb_log ADD PRIMARY KEY (log_id);;

CREATE INDEX phpbb_log_log_type ON phpbb_log(log_type);;
CREATE INDEX phpbb_log_log_time ON phpbb_log(log_time);;
CREATE INDEX phpbb_log_forum_id ON phpbb_log(forum_id);;
CREATE INDEX phpbb_log_topic_id ON phpbb_log(topic_id);;
CREATE INDEX phpbb_log_reportee_id ON phpbb_log(reportee_id);;
CREATE INDEX phpbb_log_user_id ON phpbb_log(user_id);;

CREATE GENERATOR phpbb_log_gen;;
SET GENERATOR phpbb_log_gen TO 0;;

CREATE TRIGGER t_phpbb_log FOR phpbb_log
BEFORE INSERT
AS
BEGIN
	NEW.log_id = GEN_ID(phpbb_log_gen, 1);
END;;


# Table: 'phpbb_login_attempts'
CREATE TABLE phpbb_login_attempts (
	attempt_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL,
	attempt_browser VARCHAR(150) CHARACTER SET NONE DEFAULT '' NOT NULL,
	attempt_forwarded_for VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	attempt_time INTEGER DEFAULT 0 NOT NULL,
	user_id INTEGER DEFAULT 0 NOT NULL,
	username VARCHAR(255) CHARACTER SET UTF8 DEFAULT 0 NOT NULL COLLATE UNICODE,
	username_clean VARCHAR(255) CHARACTER SET UTF8 DEFAULT 0 NOT NULL COLLATE UNICODE
);;

CREATE INDEX phpbb_login_attempts_att_ip ON phpbb_login_attempts(attempt_ip, attempt_time);;
CREATE INDEX phpbb_login_attempts_att_for ON phpbb_login_attempts(attempt_forwarded_for, attempt_time);;
CREATE INDEX phpbb_login_attempts_att_time ON phpbb_login_attempts(attempt_time);;
CREATE INDEX phpbb_login_attempts_user_id ON phpbb_login_attempts(user_id);;

# Table: 'phpbb_moderator_cache'
CREATE TABLE phpbb_moderator_cache (
	forum_id INTEGER DEFAULT 0 NOT NULL,
	user_id INTEGER DEFAULT 0 NOT NULL,
	username VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	group_id INTEGER DEFAULT 0 NOT NULL,
	group_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	display_on_index INTEGER DEFAULT 1 NOT NULL
);;

CREATE INDEX phpbb_moderator_cache_disp_idx ON phpbb_moderator_cache(display_on_index);;
CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache(forum_id);;

# Table: 'phpbb_modules'
CREATE TABLE phpbb_modules (
	module_id INTEGER NOT NULL,
	module_enabled INTEGER DEFAULT 1 NOT NULL,
	module_display INTEGER DEFAULT 1 NOT NULL,
	module_basename VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	module_class VARCHAR(10) CHARACTER SET NONE DEFAULT '' NOT NULL,
	parent_id INTEGER DEFAULT 0 NOT NULL,
	left_id INTEGER DEFAULT 0 NOT NULL,
	right_id INTEGER DEFAULT 0 NOT NULL,
	module_langname VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	module_mode VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	module_auth VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL
);;

ALTER TABLE phpbb_modules ADD PRIMARY KEY (module_id);;

CREATE INDEX phpbb_modules_left_right_id ON phpbb_modules(left_id, right_id);;
CREATE INDEX phpbb_modules_module_enabled ON phpbb_modules(module_enabled);;
CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules(module_class, left_id);;

CREATE GENERATOR phpbb_modules_gen;;
SET GENERATOR phpbb_modules_gen TO 0;;

CREATE TRIGGER t_phpbb_modules FOR phpbb_modules
BEFORE INSERT
AS
BEGIN
	NEW.module_id = GEN_ID(phpbb_modules_gen, 1);
END;;


# Table: 'phpbb_poll_options'
CREATE TABLE phpbb_poll_options (
	poll_option_id INTEGER DEFAULT 0 NOT NULL,
	topic_id INTEGER DEFAULT 0 NOT NULL,
	poll_option_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	poll_option_total INTEGER DEFAULT 0 NOT NULL
);;

CREATE INDEX phpbb_poll_options_poll_opt_id ON phpbb_poll_options(poll_option_id);;
CREATE INDEX phpbb_poll_options_topic_id ON phpbb_poll_options(topic_id);;

# Table: 'phpbb_poll_votes'
CREATE TABLE phpbb_poll_votes (
	topic_id INTEGER DEFAULT 0 NOT NULL,
	poll_option_id INTEGER DEFAULT 0 NOT NULL,
	vote_user_id INTEGER DEFAULT 0 NOT NULL,
	vote_user_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL
);;

CREATE INDEX phpbb_poll_votes_topic_id ON phpbb_poll_votes(topic_id);;
CREATE INDEX phpbb_poll_votes_vote_user_id ON phpbb_poll_votes(vote_user_id);;
CREATE INDEX phpbb_poll_votes_vote_user_ip ON phpbb_poll_votes(vote_user_ip);;

# Table: 'phpbb_posts'
CREATE TABLE phpbb_posts (
	post_id INTEGER NOT NULL,
	topic_id INTEGER DEFAULT 0 NOT NULL,
	forum_id INTEGER DEFAULT 0 NOT NULL,
	poster_id INTEGER DEFAULT 0 NOT NULL,
	icon_id INTEGER DEFAULT 0 NOT NULL,
	poster_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL,
	post_time INTEGER DEFAULT 0 NOT NULL,
	post_approved INTEGER DEFAULT 1 NOT NULL,
	post_reported INTEGER DEFAULT 0 NOT NULL,
	enable_bbcode INTEGER DEFAULT 1 NOT NULL,
	enable_smilies INTEGER DEFAULT 1 NOT NULL,
	enable_magic_url INTEGER DEFAULT 1 NOT NULL,
	enable_sig INTEGER DEFAULT 1 NOT NULL,
	post_username VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	post_subject VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	post_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	post_checksum VARCHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL,
	post_attachment INTEGER DEFAULT 0 NOT NULL,
	bbcode_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	bbcode_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL,
	post_postcount INTEGER DEFAULT 1 NOT NULL,
	post_edit_time INTEGER DEFAULT 0 NOT NULL,
	post_edit_reason VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	post_edit_user INTEGER DEFAULT 0 NOT NULL,
	post_edit_count INTEGER DEFAULT 0 NOT NULL,
	post_edit_locked INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_posts ADD PRIMARY KEY (post_id);;

CREATE INDEX phpbb_posts_forum_id ON phpbb_posts(forum_id);;
CREATE INDEX phpbb_posts_topic_id ON phpbb_posts(topic_id);;
CREATE INDEX phpbb_posts_poster_ip ON phpbb_posts(poster_ip);;
CREATE INDEX phpbb_posts_poster_id ON phpbb_posts(poster_id);;
CREATE INDEX phpbb_posts_post_approved ON phpbb_posts(post_approved);;
CREATE INDEX phpbb_posts_post_username ON phpbb_posts(post_username);;
CREATE INDEX phpbb_posts_tid_post_time ON phpbb_posts(topic_id, post_time);;

CREATE GENERATOR phpbb_posts_gen;;
SET GENERATOR phpbb_posts_gen TO 0;;

CREATE TRIGGER t_phpbb_posts FOR phpbb_posts
BEFORE INSERT
AS
BEGIN
	NEW.post_id = GEN_ID(phpbb_posts_gen, 1);
END;;


# Table: 'phpbb_privmsgs'
CREATE TABLE phpbb_privmsgs (
	msg_id INTEGER NOT NULL,
	root_level INTEGER DEFAULT 0 NOT NULL,
	author_id INTEGER DEFAULT 0 NOT NULL,
	icon_id INTEGER DEFAULT 0 NOT NULL,
	author_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL,
	message_time INTEGER DEFAULT 0 NOT NULL,
	enable_bbcode INTEGER DEFAULT 1 NOT NULL,
	enable_smilies INTEGER DEFAULT 1 NOT NULL,
	enable_magic_url INTEGER DEFAULT 1 NOT NULL,
	enable_sig INTEGER DEFAULT 1 NOT NULL,
	message_subject VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	message_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	message_edit_reason VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	message_edit_user INTEGER DEFAULT 0 NOT NULL,
	message_attachment INTEGER DEFAULT 0 NOT NULL,
	bbcode_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	bbcode_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL,
	message_edit_time INTEGER DEFAULT 0 NOT NULL,
	message_edit_count INTEGER DEFAULT 0 NOT NULL,
	to_address BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	bcc_address BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	message_reported INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_privmsgs ADD PRIMARY KEY (msg_id);;

CREATE INDEX phpbb_privmsgs_author_ip ON phpbb_privmsgs(author_ip);;
CREATE INDEX phpbb_privmsgs_message_time ON phpbb_privmsgs(message_time);;
CREATE INDEX phpbb_privmsgs_author_id ON phpbb_privmsgs(author_id);;
CREATE INDEX phpbb_privmsgs_root_level ON phpbb_privmsgs(root_level);;

CREATE GENERATOR phpbb_privmsgs_gen;;
SET GENERATOR phpbb_privmsgs_gen TO 0;;

CREATE TRIGGER t_phpbb_privmsgs FOR phpbb_privmsgs
BEFORE INSERT
AS
BEGIN
	NEW.msg_id = GEN_ID(phpbb_privmsgs_gen, 1);
END;;


# Table: 'phpbb_privmsgs_folder'
CREATE TABLE phpbb_privmsgs_folder (
	folder_id INTEGER NOT NULL,
	user_id INTEGER DEFAULT 0 NOT NULL,
	folder_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	pm_count INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_privmsgs_folder ADD PRIMARY KEY (folder_id);;

CREATE INDEX phpbb_privmsgs_folder_user_id ON phpbb_privmsgs_folder(user_id);;

CREATE GENERATOR phpbb_privmsgs_folder_gen;;
SET GENERATOR phpbb_privmsgs_folder_gen TO 0;;

CREATE TRIGGER t_phpbb_privmsgs_folder FOR phpbb_privmsgs_folder
BEFORE INSERT
AS
BEGIN
	NEW.folder_id = GEN_ID(phpbb_privmsgs_folder_gen, 1);
END;;


# Table: 'phpbb_privmsgs_rules'
CREATE TABLE phpbb_privmsgs_rules (
	rule_id INTEGER NOT NULL,
	user_id INTEGER DEFAULT 0 NOT NULL,
	rule_check INTEGER DEFAULT 0 NOT NULL,
	rule_connection INTEGER DEFAULT 0 NOT NULL,
	rule_string VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	rule_user_id INTEGER DEFAULT 0 NOT NULL,
	rule_group_id INTEGER DEFAULT 0 NOT NULL,
	rule_action INTEGER DEFAULT 0 NOT NULL,
	rule_folder_id INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_privmsgs_rules ADD PRIMARY KEY (rule_id);;

CREATE INDEX phpbb_privmsgs_rules_user_id ON phpbb_privmsgs_rules(user_id);;

CREATE GENERATOR phpbb_privmsgs_rules_gen;;
SET GENERATOR phpbb_privmsgs_rules_gen TO 0;;

CREATE TRIGGER t_phpbb_privmsgs_rules FOR phpbb_privmsgs_rules
BEFORE INSERT
AS
BEGIN
	NEW.rule_id = GEN_ID(phpbb_privmsgs_rules_gen, 1);
END;;


# Table: 'phpbb_privmsgs_to'
CREATE TABLE phpbb_privmsgs_to (
	msg_id INTEGER DEFAULT 0 NOT NULL,
	user_id INTEGER DEFAULT 0 NOT NULL,
	author_id INTEGER DEFAULT 0 NOT NULL,
	pm_deleted INTEGER DEFAULT 0 NOT NULL,
	pm_new INTEGER DEFAULT 1 NOT NULL,
	pm_unread INTEGER DEFAULT 1 NOT NULL,
	pm_replied INTEGER DEFAULT 0 NOT NULL,
	pm_marked INTEGER DEFAULT 0 NOT NULL,
	pm_forwarded INTEGER DEFAULT 0 NOT NULL,
	folder_id INTEGER DEFAULT 0 NOT NULL
);;

CREATE INDEX phpbb_privmsgs_to_msg_id ON phpbb_privmsgs_to(msg_id);;
CREATE INDEX phpbb_privmsgs_to_author_id ON phpbb_privmsgs_to(author_id);;
CREATE INDEX phpbb_privmsgs_to_usr_flder_id ON phpbb_privmsgs_to(user_id, folder_id);;

# Table: 'phpbb_profile_fields'
CREATE TABLE phpbb_profile_fields (
	field_id INTEGER NOT NULL,
	field_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	field_type INTEGER DEFAULT 0 NOT NULL,
	field_ident VARCHAR(20) CHARACTER SET NONE DEFAULT '' NOT NULL,
	field_length VARCHAR(20) CHARACTER SET NONE DEFAULT '' NOT NULL,
	field_minlen VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	field_maxlen VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	field_novalue VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	field_default_value VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	field_validation VARCHAR(20) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	field_required INTEGER DEFAULT 0 NOT NULL,
	field_show_on_reg INTEGER DEFAULT 0 NOT NULL,
	field_show_on_pm INTEGER DEFAULT 0 NOT NULL,
	field_show_on_vt INTEGER DEFAULT 0 NOT NULL,
	field_show_profile INTEGER DEFAULT 0 NOT NULL,
	field_hide INTEGER DEFAULT 0 NOT NULL,
	field_no_view INTEGER DEFAULT 0 NOT NULL,
	field_active INTEGER DEFAULT 0 NOT NULL,
	field_order INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_profile_fields ADD PRIMARY KEY (field_id);;

CREATE INDEX phpbb_profile_fields_fld_type ON phpbb_profile_fields(field_type);;
CREATE INDEX phpbb_profile_fields_fld_ordr ON phpbb_profile_fields(field_order);;

CREATE GENERATOR phpbb_profile_fields_gen;;
SET GENERATOR phpbb_profile_fields_gen TO 0;;

CREATE TRIGGER t_phpbb_profile_fields FOR phpbb_profile_fields
BEFORE INSERT
AS
BEGIN
	NEW.field_id = GEN_ID(phpbb_profile_fields_gen, 1);
END;;


# Table: 'phpbb_profile_fields_data'
CREATE TABLE phpbb_profile_fields_data (
	user_id INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_profile_fields_data ADD PRIMARY KEY (user_id);;


# Table: 'phpbb_profile_fields_lang'
CREATE TABLE phpbb_profile_fields_lang (
	field_id INTEGER DEFAULT 0 NOT NULL,
	lang_id INTEGER DEFAULT 0 NOT NULL,
	option_id INTEGER DEFAULT 0 NOT NULL,
	field_type INTEGER DEFAULT 0 NOT NULL,
	lang_value VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE
);;

ALTER TABLE phpbb_profile_fields_lang ADD PRIMARY KEY (field_id, lang_id, option_id);;


# Table: 'phpbb_profile_lang'
CREATE TABLE phpbb_profile_lang (
	field_id INTEGER DEFAULT 0 NOT NULL,
	lang_id INTEGER DEFAULT 0 NOT NULL,
	lang_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	lang_explain BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	lang_default_value VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE
);;

ALTER TABLE phpbb_profile_lang ADD PRIMARY KEY (field_id, lang_id);;


# Table: 'phpbb_ranks'
CREATE TABLE phpbb_ranks (
	rank_id INTEGER NOT NULL,
	rank_title VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	rank_min INTEGER DEFAULT 0 NOT NULL,
	rank_special INTEGER DEFAULT 0 NOT NULL,
	rank_image VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL
);;

ALTER TABLE phpbb_ranks ADD PRIMARY KEY (rank_id);;


CREATE GENERATOR phpbb_ranks_gen;;
SET GENERATOR phpbb_ranks_gen TO 0;;

CREATE TRIGGER t_phpbb_ranks FOR phpbb_ranks
BEFORE INSERT
AS
BEGIN
	NEW.rank_id = GEN_ID(phpbb_ranks_gen, 1);
END;;


# Table: 'phpbb_reports'
CREATE TABLE phpbb_reports (
	report_id INTEGER NOT NULL,
	reason_id INTEGER DEFAULT 0 NOT NULL,
	post_id INTEGER DEFAULT 0 NOT NULL,
	pm_id INTEGER DEFAULT 0 NOT NULL,
	user_id INTEGER DEFAULT 0 NOT NULL,
	user_notify INTEGER DEFAULT 0 NOT NULL,
	report_closed INTEGER DEFAULT 0 NOT NULL,
	report_time INTEGER DEFAULT 0 NOT NULL,
	report_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL
);;

ALTER TABLE phpbb_reports ADD PRIMARY KEY (report_id);;

CREATE INDEX phpbb_reports_post_id ON phpbb_reports(post_id);;
CREATE INDEX phpbb_reports_pm_id ON phpbb_reports(pm_id);;

CREATE GENERATOR phpbb_reports_gen;;
SET GENERATOR phpbb_reports_gen TO 0;;

CREATE TRIGGER t_phpbb_reports FOR phpbb_reports
BEFORE INSERT
AS
BEGIN
	NEW.report_id = GEN_ID(phpbb_reports_gen, 1);
END;;


# Table: 'phpbb_reports_reasons'
CREATE TABLE phpbb_reports_reasons (
	reason_id INTEGER NOT NULL,
	reason_title VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	reason_description BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	reason_order INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_reports_reasons ADD PRIMARY KEY (reason_id);;


CREATE GENERATOR phpbb_reports_reasons_gen;;
SET GENERATOR phpbb_reports_reasons_gen TO 0;;

CREATE TRIGGER t_phpbb_reports_reasons FOR phpbb_reports_reasons
BEFORE INSERT
AS
BEGIN
	NEW.reason_id = GEN_ID(phpbb_reports_reasons_gen, 1);
END;;


# Table: 'phpbb_search_results'
CREATE TABLE phpbb_search_results (
	search_key VARCHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL,
	search_time INTEGER DEFAULT 0 NOT NULL,
	search_keywords BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	search_authors BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL
);;

ALTER TABLE phpbb_search_results ADD PRIMARY KEY (search_key);;


# Table: 'phpbb_search_wordlist'
CREATE TABLE phpbb_search_wordlist (
	word_id INTEGER NOT NULL,
	word_text VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	word_common INTEGER DEFAULT 0 NOT NULL,
	word_count INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_search_wordlist ADD PRIMARY KEY (word_id);;

CREATE UNIQUE INDEX phpbb_search_wordlist_wrd_txt ON phpbb_search_wordlist(word_text);;
CREATE INDEX phpbb_search_wordlist_wrd_cnt ON phpbb_search_wordlist(word_count);;

CREATE GENERATOR phpbb_search_wordlist_gen;;
SET GENERATOR phpbb_search_wordlist_gen TO 0;;

CREATE TRIGGER t_phpbb_search_wordlist FOR phpbb_search_wordlist
BEFORE INSERT
AS
BEGIN
	NEW.word_id = GEN_ID(phpbb_search_wordlist_gen, 1);
END;;


# Table: 'phpbb_search_wordmatch'
CREATE TABLE phpbb_search_wordmatch (
	post_id INTEGER DEFAULT 0 NOT NULL,
	word_id INTEGER DEFAULT 0 NOT NULL,
	title_match INTEGER DEFAULT 0 NOT NULL
);;

CREATE UNIQUE INDEX phpbb_search_wordmatch_unq_mtch ON phpbb_search_wordmatch(word_id, post_id, title_match);;
CREATE INDEX phpbb_search_wordmatch_word_id ON phpbb_search_wordmatch(word_id);;
CREATE INDEX phpbb_search_wordmatch_post_id ON phpbb_search_wordmatch(post_id);;

# Table: 'phpbb_sessions'
CREATE TABLE phpbb_sessions (
	session_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL,
	session_user_id INTEGER DEFAULT 0 NOT NULL,
	session_forum_id INTEGER DEFAULT 0 NOT NULL,
	session_last_visit INTEGER DEFAULT 0 NOT NULL,
	session_start INTEGER DEFAULT 0 NOT NULL,
	session_time INTEGER DEFAULT 0 NOT NULL,
	session_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL,
	session_browser VARCHAR(150) CHARACTER SET NONE DEFAULT '' NOT NULL,
	session_forwarded_for VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	session_page VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	session_viewonline INTEGER DEFAULT 1 NOT NULL,
	session_autologin INTEGER DEFAULT 0 NOT NULL,
	session_admin INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_sessions ADD PRIMARY KEY (session_id);;

CREATE INDEX phpbb_sessions_session_time ON phpbb_sessions(session_time);;
CREATE INDEX phpbb_sessions_session_user_id ON phpbb_sessions(session_user_id);;
CREATE INDEX phpbb_sessions_session_fid ON phpbb_sessions(session_forum_id);;

# Table: 'phpbb_sessions_keys'
CREATE TABLE phpbb_sessions_keys (
	key_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL,
	user_id INTEGER DEFAULT 0 NOT NULL,
	last_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL,
	last_login INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_sessions_keys ADD PRIMARY KEY (key_id, user_id);;

CREATE INDEX phpbb_sessions_keys_last_login ON phpbb_sessions_keys(last_login);;

# Table: 'phpbb_sitelist'
CREATE TABLE phpbb_sitelist (
	site_id INTEGER NOT NULL,
	site_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL,
	site_hostname VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	ip_exclude INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_sitelist ADD PRIMARY KEY (site_id);;


CREATE GENERATOR phpbb_sitelist_gen;;
SET GENERATOR phpbb_sitelist_gen TO 0;;

CREATE TRIGGER t_phpbb_sitelist FOR phpbb_sitelist
BEFORE INSERT
AS
BEGIN
	NEW.site_id = GEN_ID(phpbb_sitelist_gen, 1);
END;;


# Table: 'phpbb_smilies'
CREATE TABLE phpbb_smilies (
	smiley_id INTEGER NOT NULL,
	code VARCHAR(50) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	emotion VARCHAR(50) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	smiley_url VARCHAR(50) CHARACTER SET NONE DEFAULT '' NOT NULL,
	smiley_width INTEGER DEFAULT 0 NOT NULL,
	smiley_height INTEGER DEFAULT 0 NOT NULL,
	smiley_order INTEGER DEFAULT 0 NOT NULL,
	display_on_posting INTEGER DEFAULT 1 NOT NULL
);;

ALTER TABLE phpbb_smilies ADD PRIMARY KEY (smiley_id);;

CREATE INDEX phpbb_smilies_display_on_post ON phpbb_smilies(display_on_posting);;

CREATE GENERATOR phpbb_smilies_gen;;
SET GENERATOR phpbb_smilies_gen TO 0;;

CREATE TRIGGER t_phpbb_smilies FOR phpbb_smilies
BEFORE INSERT
AS
BEGIN
	NEW.smiley_id = GEN_ID(phpbb_smilies_gen, 1);
END;;


# Table: 'phpbb_styles'
CREATE TABLE phpbb_styles (
	style_id INTEGER NOT NULL,
	style_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	style_copyright VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	style_active INTEGER DEFAULT 1 NOT NULL,
	template_id INTEGER DEFAULT 0 NOT NULL,
	theme_id INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_styles ADD PRIMARY KEY (style_id);;

CREATE UNIQUE INDEX phpbb_styles_style_name ON phpbb_styles(style_name);;
CREATE INDEX phpbb_styles_template_id ON phpbb_styles(template_id);;
CREATE INDEX phpbb_styles_theme_id ON phpbb_styles(theme_id);;

CREATE GENERATOR phpbb_styles_gen;;
SET GENERATOR phpbb_styles_gen TO 0;;

CREATE TRIGGER t_phpbb_styles FOR phpbb_styles
BEFORE INSERT
AS
BEGIN
	NEW.style_id = GEN_ID(phpbb_styles_gen, 1);
END;;


# Table: 'phpbb_styles_template'
CREATE TABLE phpbb_styles_template (
	template_id INTEGER NOT NULL,
	template_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	template_copyright VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	template_path VARCHAR(100) CHARACTER SET NONE DEFAULT '' NOT NULL,
	bbcode_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT 'kNg=' NOT NULL,
	template_inherits_id INTEGER DEFAULT 0 NOT NULL,
	template_inherit_path VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL
);;

ALTER TABLE phpbb_styles_template ADD PRIMARY KEY (template_id);;

CREATE UNIQUE INDEX phpbb_styles_template_tmplte_nm ON phpbb_styles_template(template_name);;

CREATE GENERATOR phpbb_styles_template_gen;;
SET GENERATOR phpbb_styles_template_gen TO 0;;

CREATE TRIGGER t_phpbb_styles_template FOR phpbb_styles_template
BEFORE INSERT
AS
BEGIN
	NEW.template_id = GEN_ID(phpbb_styles_template_gen, 1);
END;;


# Table: 'phpbb_styles_theme'
CREATE TABLE phpbb_styles_theme (
	theme_id INTEGER NOT NULL,
	theme_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	theme_copyright VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	theme_path VARCHAR(100) CHARACTER SET NONE DEFAULT '' NOT NULL
);;

ALTER TABLE phpbb_styles_theme ADD PRIMARY KEY (theme_id);;

CREATE UNIQUE INDEX phpbb_styles_theme_theme_name ON phpbb_styles_theme(theme_name);;

CREATE GENERATOR phpbb_styles_theme_gen;;
SET GENERATOR phpbb_styles_theme_gen TO 0;;

CREATE TRIGGER t_phpbb_styles_theme FOR phpbb_styles_theme
BEFORE INSERT
AS
BEGIN
	NEW.theme_id = GEN_ID(phpbb_styles_theme_gen, 1);
END;;


# Table: 'phpbb_topics'
CREATE TABLE phpbb_topics (
	topic_id INTEGER NOT NULL,
	forum_id INTEGER DEFAULT 0 NOT NULL,
	icon_id INTEGER DEFAULT 0 NOT NULL,
	topic_attachment INTEGER DEFAULT 0 NOT NULL,
	topic_approved INTEGER DEFAULT 1 NOT NULL,
	topic_reported INTEGER DEFAULT 0 NOT NULL,
	topic_title VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	topic_poster INTEGER DEFAULT 0 NOT NULL,
	topic_time INTEGER DEFAULT 0 NOT NULL,
	topic_time_limit INTEGER DEFAULT 0 NOT NULL,
	topic_views INTEGER DEFAULT 0 NOT NULL,
	topic_replies INTEGER DEFAULT 0 NOT NULL,
	topic_replies_real INTEGER DEFAULT 0 NOT NULL,
	topic_status INTEGER DEFAULT 0 NOT NULL,
	topic_type INTEGER DEFAULT 0 NOT NULL,
	topic_first_post_id INTEGER DEFAULT 0 NOT NULL,
	topic_first_poster_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	topic_first_poster_colour VARCHAR(6) CHARACTER SET NONE DEFAULT '' NOT NULL,
	topic_last_post_id INTEGER DEFAULT 0 NOT NULL,
	topic_last_poster_id INTEGER DEFAULT 0 NOT NULL,
	topic_last_poster_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	topic_last_poster_colour VARCHAR(6) CHARACTER SET NONE DEFAULT '' NOT NULL,
	topic_last_post_subject VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	topic_last_post_time INTEGER DEFAULT 0 NOT NULL,
	topic_last_view_time INTEGER DEFAULT 0 NOT NULL,
	topic_moved_id INTEGER DEFAULT 0 NOT NULL,
	topic_bumped INTEGER DEFAULT 0 NOT NULL,
	topic_bumper INTEGER DEFAULT 0 NOT NULL,
	poll_title VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	poll_start INTEGER DEFAULT 0 NOT NULL,
	poll_length INTEGER DEFAULT 0 NOT NULL,
	poll_max_options INTEGER DEFAULT 1 NOT NULL,
	poll_last_vote INTEGER DEFAULT 0 NOT NULL,
	poll_vote_change INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_topics ADD PRIMARY KEY (topic_id);;

CREATE INDEX phpbb_topics_forum_id ON phpbb_topics(forum_id);;
CREATE INDEX phpbb_topics_forum_id_type ON phpbb_topics(forum_id, topic_type);;
CREATE INDEX phpbb_topics_last_post_time ON phpbb_topics(topic_last_post_time);;
CREATE INDEX phpbb_topics_topic_approved ON phpbb_topics(topic_approved);;
CREATE INDEX phpbb_topics_forum_appr_last ON phpbb_topics(forum_id, topic_approved, topic_last_post_id);;
CREATE INDEX phpbb_topics_fid_time_moved ON phpbb_topics(forum_id, topic_last_post_time, topic_moved_id);;

CREATE GENERATOR phpbb_topics_gen;;
SET GENERATOR phpbb_topics_gen TO 0;;

CREATE TRIGGER t_phpbb_topics FOR phpbb_topics
BEFORE INSERT
AS
BEGIN
	NEW.topic_id = GEN_ID(phpbb_topics_gen, 1);
END;;


# Table: 'phpbb_topics_track'
CREATE TABLE phpbb_topics_track (
	user_id INTEGER DEFAULT 0 NOT NULL,
	topic_id INTEGER DEFAULT 0 NOT NULL,
	forum_id INTEGER DEFAULT 0 NOT NULL,
	mark_time INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_topics_track ADD PRIMARY KEY (user_id, topic_id);;

CREATE INDEX phpbb_topics_track_topic_id ON phpbb_topics_track(topic_id);;
CREATE INDEX phpbb_topics_track_forum_id ON phpbb_topics_track(forum_id);;

# Table: 'phpbb_topics_posted'
CREATE TABLE phpbb_topics_posted (
	user_id INTEGER DEFAULT 0 NOT NULL,
	topic_id INTEGER DEFAULT 0 NOT NULL,
	topic_posted INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_topics_posted ADD PRIMARY KEY (user_id, topic_id);;


# Table: 'phpbb_topics_watch'
CREATE TABLE phpbb_topics_watch (
	topic_id INTEGER DEFAULT 0 NOT NULL,
	user_id INTEGER DEFAULT 0 NOT NULL,
	notify_status INTEGER DEFAULT 0 NOT NULL
);;

CREATE INDEX phpbb_topics_watch_topic_id ON phpbb_topics_watch(topic_id);;
CREATE INDEX phpbb_topics_watch_user_id ON phpbb_topics_watch(user_id);;
CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch(notify_status);;

# Table: 'phpbb_user_group'
CREATE TABLE phpbb_user_group (
	group_id INTEGER DEFAULT 0 NOT NULL,
	user_id INTEGER DEFAULT 0 NOT NULL,
	group_leader INTEGER DEFAULT 0 NOT NULL,
	user_pending INTEGER DEFAULT 1 NOT NULL
);;

CREATE INDEX phpbb_user_group_group_id ON phpbb_user_group(group_id);;
CREATE INDEX phpbb_user_group_user_id ON phpbb_user_group(user_id);;
CREATE INDEX phpbb_user_group_group_leader ON phpbb_user_group(group_leader);;

# Table: 'phpbb_users'
CREATE TABLE phpbb_users (
	user_id INTEGER NOT NULL,
	user_type INTEGER DEFAULT 0 NOT NULL,
	group_id INTEGER DEFAULT 3 NOT NULL,
	user_permissions BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL,
	user_perm_from INTEGER DEFAULT 0 NOT NULL,
	user_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL,
	user_regdate INTEGER DEFAULT 0 NOT NULL,
	username VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	username_clean VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	user_password VARCHAR(40) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	user_passchg INTEGER DEFAULT 0 NOT NULL,
	user_pass_convert INTEGER DEFAULT 0 NOT NULL,
	user_email VARCHAR(100) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	user_email_hash DOUBLE PRECISION DEFAULT 0 NOT NULL,
	user_birthday VARCHAR(10) CHARACTER SET NONE DEFAULT '' NOT NULL,
	user_lastvisit INTEGER DEFAULT 0 NOT NULL,
	user_lastmark INTEGER DEFAULT 0 NOT NULL,
	user_lastpost_time INTEGER DEFAULT 0 NOT NULL,
	user_lastpage VARCHAR(200) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	user_last_confirm_key VARCHAR(10) CHARACTER SET NONE DEFAULT '' NOT NULL,
	user_last_search INTEGER DEFAULT 0 NOT NULL,
	user_warnings INTEGER DEFAULT 0 NOT NULL,
	user_last_warning INTEGER DEFAULT 0 NOT NULL,
	user_login_attempts INTEGER DEFAULT 0 NOT NULL,
	user_inactive_reason INTEGER DEFAULT 0 NOT NULL,
	user_inactive_time INTEGER DEFAULT 0 NOT NULL,
	user_posts INTEGER DEFAULT 0 NOT NULL,
	user_lang VARCHAR(30) CHARACTER SET NONE DEFAULT '' NOT NULL,
	user_timezone DOUBLE PRECISION DEFAULT 0 NOT NULL,
	user_dst INTEGER DEFAULT 0 NOT NULL,
	user_dateformat VARCHAR(30) CHARACTER SET UTF8 DEFAULT 'd M Y H:i' NOT NULL COLLATE UNICODE,
	user_style INTEGER DEFAULT 0 NOT NULL,
	user_rank INTEGER DEFAULT 0 NOT NULL,
	user_colour VARCHAR(6) CHARACTER SET NONE DEFAULT '' NOT NULL,
	user_new_privmsg INTEGER DEFAULT 0 NOT NULL,
	user_unread_privmsg INTEGER DEFAULT 0 NOT NULL,
	user_last_privmsg INTEGER DEFAULT 0 NOT NULL,
	user_message_rules INTEGER DEFAULT 0 NOT NULL,
	user_full_folder INTEGER DEFAULT -3 NOT NULL,
	user_emailtime INTEGER DEFAULT 0 NOT NULL,
	user_topic_show_days INTEGER DEFAULT 0 NOT NULL,
	user_topic_sortby_type VARCHAR(1) CHARACTER SET NONE DEFAULT 't' NOT NULL,
	user_topic_sortby_dir VARCHAR(1) CHARACTER SET NONE DEFAULT 'd' NOT NULL,
	user_post_show_days INTEGER DEFAULT 0 NOT NULL,
	user_post_sortby_type VARCHAR(1) CHARACTER SET NONE DEFAULT 't' NOT NULL,
	user_post_sortby_dir VARCHAR(1) CHARACTER SET NONE DEFAULT 'a' NOT NULL,
	user_notify INTEGER DEFAULT 0 NOT NULL,
	user_notify_pm INTEGER DEFAULT 1 NOT NULL,
	user_notify_type INTEGER DEFAULT 0 NOT NULL,
	user_allow_pm INTEGER DEFAULT 1 NOT NULL,
	user_allow_viewonline INTEGER DEFAULT 1 NOT NULL,
	user_allow_viewemail INTEGER DEFAULT 1 NOT NULL,
	user_allow_massemail INTEGER DEFAULT 1 NOT NULL,
	user_options INTEGER DEFAULT 230271 NOT NULL,
	user_avatar VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	user_avatar_type VARCHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL,
	user_avatar_width INTEGER DEFAULT 0 NOT NULL,
	user_avatar_height INTEGER DEFAULT 0 NOT NULL,
	user_sig BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	user_sig_bbcode_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL,
	user_sig_bbcode_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
	user_from VARCHAR(100) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	user_icq VARCHAR(15) CHARACTER SET NONE DEFAULT '' NOT NULL,
	user_aim VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	user_yim VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	user_msnm VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	user_jabber VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	user_website VARCHAR(200) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	user_occ BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	user_interests BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
	user_actkey VARCHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL,
	user_newpasswd VARCHAR(40) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	user_form_salt VARCHAR(32) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	user_new INTEGER DEFAULT 1 NOT NULL,
	user_reminded INTEGER DEFAULT 0 NOT NULL,
	user_reminded_time INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_users ADD PRIMARY KEY (user_id);;

CREATE INDEX phpbb_users_user_birthday ON phpbb_users(user_birthday);;
CREATE INDEX phpbb_users_user_email_hash ON phpbb_users(user_email_hash);;
CREATE INDEX phpbb_users_user_type ON phpbb_users(user_type);;
CREATE UNIQUE INDEX phpbb_users_username_clean ON phpbb_users(username_clean);;

CREATE GENERATOR phpbb_users_gen;;
SET GENERATOR phpbb_users_gen TO 0;;

CREATE TRIGGER t_phpbb_users FOR phpbb_users
BEFORE INSERT
AS
BEGIN
	NEW.user_id = GEN_ID(phpbb_users_gen, 1);
END;;


# Table: 'phpbb_warnings'
CREATE TABLE phpbb_warnings (
	warning_id INTEGER NOT NULL,
	user_id INTEGER DEFAULT 0 NOT NULL,
	post_id INTEGER DEFAULT 0 NOT NULL,
	log_id INTEGER DEFAULT 0 NOT NULL,
	warning_time INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_warnings ADD PRIMARY KEY (warning_id);;


CREATE GENERATOR phpbb_warnings_gen;;
SET GENERATOR phpbb_warnings_gen TO 0;;

CREATE TRIGGER t_phpbb_warnings FOR phpbb_warnings
BEFORE INSERT
AS
BEGIN
	NEW.warning_id = GEN_ID(phpbb_warnings_gen, 1);
END;;


# Table: 'phpbb_words'
CREATE TABLE phpbb_words (
	word_id INTEGER NOT NULL,
	word VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
	replacement VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE
);;

ALTER TABLE phpbb_words ADD PRIMARY KEY (word_id);;


CREATE GENERATOR phpbb_words_gen;;
SET GENERATOR phpbb_words_gen TO 0;;

CREATE TRIGGER t_phpbb_words FOR phpbb_words
BEFORE INSERT
AS
BEGIN
	NEW.word_id = GEN_ID(phpbb_words_gen, 1);
END;;


# Table: 'phpbb_zebra'
CREATE TABLE phpbb_zebra (
	user_id INTEGER DEFAULT 0 NOT NULL,
	zebra_id INTEGER DEFAULT 0 NOT NULL,
	friend INTEGER DEFAULT 0 NOT NULL,
	foe INTEGER DEFAULT 0 NOT NULL
);;

ALTER TABLE phpbb_zebra ADD PRIMARY KEY (user_id, zebra_id);;