forked from chilek/lms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlms.mysql
2557 lines (2423 loc) · 86 KB
/
lms.mysql
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
# --------------------------------------------------------
# $Id$
# --------------------------------------------------------
# -- Drop tables first, MySQL doesn't support CASCADE
DROP VIEW IF EXISTS nas;
DROP VIEW IF EXISTS vnodes_mac;
DROP VIEW IF EXISTS vnodes;
DROP VIEW IF EXISTS vmacs;
DROP VIEW IF EXISTS customerview;
DROP VIEW IF EXISTS contractorview;
DROP VIEW IF EXISTS customeraddressview;
DROP VIEW IF EXISTS teryt_terc;
DROP VIEW IF EXISTS teryt_ulic;
DROP VIEW IF EXISTS teryt_simc;
DROP TABLE IF EXISTS ewx_stm_nodes;
DROP TABLE IF EXISTS ewx_stm_channels;
DROP TABLE IF EXISTS ewx_pt_config;
DROP TABLE IF EXISTS ewx_channels;
DROP TABLE IF EXISTS numberplans;
DROP TABLE IF EXISTS nodeassignments;
DROP TABLE IF EXISTS assignments;
DROP TABLE IF EXISTS nodelocks;
DROP TABLE IF EXISTS taxes;
DROP TABLE IF EXISTS cash;
DROP TABLE IF EXISTS dbinfo;
DROP TABLE IF EXISTS numberplanassignments;
DROP TABLE IF EXISTS invoicecontents;
DROP TABLE IF EXISTS debitnotecontents;
DROP TABLE IF EXISTS documents;
DROP TABLE IF EXISTS documentcontents;
DROP TABLE IF EXISTS receiptcontents;
DROP TABLE IF EXISTS location_street_types;
DROP TABLE IF EXISTS location_streets;
DROP TABLE IF EXISTS location_cities;
DROP TABLE IF EXISTS location_boroughs;
DROP TABLE IF EXISTS location_districts;
DROP TABLE IF EXISTS location_states;
DROP TABLE IF EXISTS pna;
DROP TABLE IF EXISTS netdevices;
DROP TABLE IF EXISTS netradiosectors;
DROP TABLE IF EXISTS netlinks;
DROP TABLE IF EXISTS networks;
DROP TABLE IF EXISTS macs;
DROP TABLE IF EXISTS nodes;
DROP TABLE IF EXISTS nodegroups;
DROP TABLE IF EXISTS nodegroupassignments;
DROP TABLE IF EXISTS payments;
DROP TABLE IF EXISTS rtticketcategories;
DROP TABLE IF EXISTS rtcategoryusers;
DROP TABLE IF EXISTS rtcategories;
DROP TABLE IF EXISTS rtattachments;
DROP TABLE IF EXISTS rtmessages;
DROP TABLE IF EXISTS rtnotes;
DROP TABLE IF EXISTS rtqueues;
DROP TABLE IF EXISTS rttickets;
DROP TABLE IF EXISTS rtrights;
DROP TABLE IF EXISTS stats;
DROP TABLE IF EXISTS nodesessions;
DROP TABLE IF EXISTS tariffs;
DROP TABLE IF EXISTS promotions;
DROP TABLE IF EXISTS promotionschemas;
DROP TABLE IF EXISTS promotionassignments;
DROP TABLE IF EXISTS liabilities;
DROP TABLE IF EXISTS customergroups;
DROP TABLE IF EXISTS customerassignments;
DROP TABLE IF EXISTS records;
DROP TABLE IF EXISTS domainmetadata;
DROP TABLE IF EXISTS passwd;
DROP TABLE IF EXISTS domains;
DROP TABLE IF EXISTS aliases;
DROP TABLE IF EXISTS aliasassignments;
DROP TABLE IF EXISTS uiconfig;
DROP TABLE IF EXISTS events;
DROP TABLE IF EXISTS eventassignments;
DROP TABLE IF EXISTS sessions;
DROP TABLE IF EXISTS cashsources;
DROP TABLE IF EXISTS sourcefiles;
DROP TABLE IF EXISTS cashimport;
DROP TABLE IF EXISTS hosts;
DROP TABLE IF EXISTS daemoninstances;
DROP TABLE IF EXISTS daemonconfig;
DROP TABLE IF EXISTS docrights;
DROP TABLE IF EXISTS cashrights;
DROP TABLE IF EXISTS cashregs;
DROP TABLE IF EXISTS cashreglog;
DROP TABLE IF EXISTS imessengers;
DROP TABLE IF EXISTS customercontacts;
DROP TABLE IF EXISTS states;
DROP TABLE IF EXISTS countries;
DROP TABLE IF EXISTS zipcodes;
DROP TABLE IF EXISTS divisions;
DROP TABLE IF EXISTS excludedgroups;
DROP TABLE IF EXISTS voipaccounts;
DROP TABLE IF EXISTS messages;
DROP TABLE IF EXISTS messageitems;
DROP TABLE IF EXISTS nastypes;
DROP TABLE IF EXISTS managementurls;
DROP TABLE IF EXISTS logtransactions;
DROP TABLE IF EXISTS logmessages;
DROP TABLE IF EXISTS logmessagekeys;
DROP TABLE IF EXISTS logmessagedata;
DROP TABLE IF EXISTS up_rights;
DROP TABLE IF EXISTS up_rights_assignments;
DROP TABLE IF EXISTS up_customers;
DROP TABLE IF EXISTS up_help;
DROP TABLE IF EXISTS up_info_changes;
DROP TABLE IF EXISTS supermasters;
DROP TABLE IF EXISTS users;
DROP TABLE IF EXISTS customers;
DROP TABLE IF EXISTS invprojects;
DROP TABLE IF EXISTS netnodes;
DROP TABLE IF EXISTS usergroups;
DROP TABLE IF EXISTS userassignments;
DROP TABLE IF EXISTS passwdhistory;
# --------------------------------------------------------
#
# Structure of table users
#
CREATE TABLE users (
id int(11) NOT NULL auto_increment,
login varchar(32) NOT NULL DEFAULT '',
name varchar(64) NOT NULL DEFAULT '',
email varchar(255) NOT NULL DEFAULT '',
phone varchar(32) DEFAULT NULL,
position varchar(255) NOT NULL DEFAULT '',
rights text NOT NULL DEFAULT '',
hosts varchar(255) NOT NULL DEFAULT '',
passwd varchar(255) NOT NULL DEFAULT '',
ntype smallint DEFAULT NULL,
lastlogindate int(11) NOT NULL DEFAULT '0',
lastloginip varchar(16) NOT NULL DEFAULT '',
failedlogindate int(11) NOT NULL DEFAULT '0',
failedloginip varchar(16) NOT NULL DEFAULT '',
deleted tinyint(1) NOT NULL DEFAULT '0',
passwdexpiration int(11) NOT NULL DEFAULT '0',
passwdlastchange int(11) NOT NULL DEFAULT '0',
access tinyint(1) NOT NULL DEFAULT '1',
accessfrom int(11) NOT NULL DEFAULT '0',
accessto int(11) NOT NULL DEFAULT '0',
swekey_id varchar(32) NULL DEFAULT NULL,
settings mediumtext NOT NULL DEFAULT '',
PRIMARY KEY (id),
UNIQUE KEY login (login, swekey_id)
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table customers (customers)
#
CREATE TABLE customers (
id int(11) NOT NULL auto_increment,
extid varchar(32) NOT NULL DEFAULT '',
lastname varchar(128) NOT NULL DEFAULT '',
name varchar(128) NOT NULL DEFAULT '',
status smallint NOT NULL DEFAULT '0',
type smallint NOT NULL DEFAULT '0',
street varchar(255) DEFAULT '' NOT NULL,
building varchar(20) DEFAULT NULL,
apartment varchar(20) DEFAULT NULL,
zip varchar(10) NOT NULL DEFAULT '',
city varchar(32) NOT NULL DEFAULT '',
countryid int(11) DEFAULT NULL,
post_name varchar(255) DEFAULT NULL,
post_street varchar(255) DEFAULT NULL,
post_building varchar(20) DEFAULT NULL,
post_apartment varchar(20) DEFAULT NULL,
post_zip varchar(10) DEFAULT NULL,
post_city varchar(32) DEFAULT NULL,
post_countryid int(11) DEFAULT NULL,
ten varchar(16) NOT NULL DEFAULT '',
ssn varchar(11) NOT NULL DEFAULT '',
regon varchar(255) NOT NULL DEFAULT '',
rbe varchar(255) NOT NULL DEFAULT '',
icn varchar(255) NOT NULL DEFAULT '',
info text NOT NULL,
notes text NOT NULL DEFAULT '',
creationdate int(11) NOT NULL DEFAULT '0',
moddate int(11) NOT NULL DEFAULT '0',
creatorid int(11) NOT NULL DEFAULT '0',
modid int(11) NOT NULL DEFAULT '0',
deleted tinyint(1) NOT NULL DEFAULT '0',
message text NOT NULL,
pin varchar(6) NOT NULL DEFAULT '0',
cutoffstop int(11) NOT NULL DEFAULT '0',
consentdate int(11) NOT NULL DEFAULT '0',
einvoice tinyint(1) DEFAULT NULL,
invoicenotice tinyint(1) DEFAULT NULL,
mailingnotice tinyint(1) DEFAULT NULL,
divisionid int(11) NOT NULL DEFAULT '0',
paytime smallint NOT NULL DEFAULT '-1',
paytype smallint DEFAULT NULL,
PRIMARY KEY (id),
INDEX zip (zip),
INDEX name (lastname, name)
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table numberplans
#
CREATE TABLE numberplans (
id int(11) NOT NULL auto_increment,
template varchar(255) NOT NULL DEFAULT '',
period smallint NOT NULL DEFAULT '0',
doctype int(11) NOT NULL DEFAULT '0',
isdefault tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (id)
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table assignments
#
CREATE TABLE assignments (
id int(11) NOT NULL auto_increment,
tariffid int(11) NOT NULL DEFAULT '0',
liabilityid int(11) NOT NULL DEFAULT '0',
customerid int(11) NOT NULL,
period smallint NOT NULL DEFAULT '0',
at int(11) NOT NULL DEFAULT '0',
datefrom int(11) NOT NULL DEFAULT '0',
dateto int(11) NOT NULL DEFAULT '0',
invoice tinyint(1) NOT NULL DEFAULT '0',
suspended tinyint(1) NOT NULL DEFAULT '0',
settlement tinyint(1) NOT NULL DEFAULT '0',
pdiscount decimal(4,2) NOT NULL DEFAULT '0',
vdiscount decimal(9,2) NOT NULL DEFAULT '0',
paytype smallint DEFAULT NULL,
numberplanid int(11) DEFAULT NULL,
attribute varchar(255) DEFAULT NULL,
PRIMARY KEY (id),
INDEX tariffid (tariffid),
INDEX customerid (customerid),
INDEX numberplanid (numberplanid),
FOREIGN KEY (customerid) REFERENCES customers (id) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (numberplanid) REFERENCES numberplans (id) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table taxes
#
CREATE TABLE taxes (
id int(11) NOT NULL auto_increment,
value decimal(4,2) NOT NULL DEFAULT '0',
taxed tinyint NOT NULL DEFAULT '0',
label varchar(16) NOT NULL DEFAULT '',
validfrom int(11) NOT NULL DEFAULT '0',
validto int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (id)
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table cash
#
CREATE TABLE cash (
id int(11) NOT NULL auto_increment,
time int(11) NOT NULL DEFAULT '0',
type smallint NOT NULL DEFAULT '0',
userid int(11) NOT NULL DEFAULT '0',
value decimal(9,2) NOT NULL DEFAULT '0',
taxid int(11) NOT NULL DEFAULT '0',
customerid int(11) NOT NULL DEFAULT '0',
comment text NOT NULL DEFAULT '',
docid int(11) NOT NULL DEFAULT '0',
itemid smallint NOT NULL DEFAULT '0',
importid int(11) DEFAULT NULL,
sourceid int(11) DEFAULT NULL,
PRIMARY KEY (id),
INDEX customerid (customerid),
INDEX docid (docid),
INDEX time (time),
INDEX importid (importid),
INDEX sourceid (sourceid)
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table dbinfo
#
CREATE TABLE dbinfo (
keytype varchar(255) NOT NULL DEFAULT '',
keyvalue varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (keytype)
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table numberplanassignments
#
CREATE TABLE numberplanassignments (
id int(11) NOT NULL auto_increment,
planid int(11) NOT NULL DEFAULT '0',
divisionid int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (id),
UNIQUE KEY planid (planid, divisionid),
INDEX divisionid (divisionid)
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table invoicecontents
#
CREATE TABLE invoicecontents (
docid int(11) NOT NULL DEFAULT '0',
itemid smallint NOT NULL DEFAULT '0',
value decimal(12,5) NOT NULL DEFAULT '0',
pdiscount decimal(4,2) NOT NULL DEFAULT '0',
vdiscount decimal(9,2) NOT NULL DEFAULT '0',
taxid int(11) NOT NULL DEFAULT '0',
prodid varchar(255) NOT NULL DEFAULT '',
content varchar(16) NOT NULL DEFAULT '',
count decimal(9,2) NOT NULL DEFAULT '0',
description text NOT NULL DEFAULT '',
tariffid int(11) NOT NULL DEFAULT '0',
INDEX docid (docid)
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table debitnotecontents
#
CREATE TABLE debitnotecontents (
id int(11) NOT NULL auto_increment,
docid int(11) NOT NULL DEFAULT '0',
itemid smallint NOT NULL DEFAULT '0',
value decimal(9,2) NOT NULL DEFAULT '0',
description text NOT NULL DEFAULT '',
PRIMARY KEY (id),
UNIQUE KEY docid (docid, itemid)
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table documents
#
CREATE TABLE documents (
id int(11) NOT NULL auto_increment,
type tinyint NOT NULL DEFAULT '0',
number int(11) NOT NULL DEFAULT '0',
numberplanid int(11) NOT NULL DEFAULT '0',
extnumber varchar(255) NOT NULL DEFAULT '',
cdate int(11) NOT NULL DEFAULT '0',
sdate int(11) NOT NULL DEFAULT '0',
customerid int(11) NOT NULL DEFAULT '0',
userid int(11) NOT NULL DEFAULT '0',
divisionid int(11) NOT NULL DEFAULT '0',
name varchar(255) NOT NULL DEFAULT '',
address varchar(255) NOT NULL DEFAULT '',
zip varchar(10) NOT NULL DEFAULT '',
city varchar(32) NOT NULL DEFAULT '',
countryid int(11) NOT NULL DEFAULT '0',
ten varchar(16) NOT NULL DEFAULT '',
ssn varchar(11) NOT NULL DEFAULT '',
paytime smallint NOT NULL DEFAULT '0',
paytype smallint DEFAULT NULL,
closed tinyint(1) NOT NULL DEFAULT '0',
reference int(11) NOT NULL DEFAULT '0',
reason varchar(255) NOT NULL DEFAULT '',
div_name text NOT NULL DEFAULT '',
div_shortname text NOT NULL DEFAULT '',
div_address varchar(255) NOT NULL DEFAULT '',
div_city varchar(255) NOT NULL DEFAULT '',
div_zip varchar(255) NOT NULL DEFAULT '',
div_countryid int(11) NOT NULL DEFAULT '0',
div_ten varchar(255) NOT NULL DEFAULT '',
div_regon varchar(255) NOT NULL DEFAULT '',
div_account varchar(48) NOT NULL DEFAULT '',
div_inv_header text NOT NULL DEFAULT '',
div_inv_footer text NOT NULL DEFAULT '',
div_inv_author text NOT NULL DEFAULT '',
div_inv_cplace text NOT NULL DEFAULT '',
fullnumber varchar(50) DEFAULT NULL,
cancelled smallint DEFAULT 0 NOT NULL,
PRIMARY KEY (id),
INDEX cdate (cdate),
INDEX numberplanid (numberplanid),
INDEX customerid (customerid),
INDEX closed (closed),
INDEX reference (reference)
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table documentcontents
#
CREATE TABLE documentcontents (
docid int(11) DEFAULT '0' NOT NULL,
title text DEFAULT '' NOT NULL,
fromdate int(11) DEFAULT '0' NOT NULL,
todate int(11) DEFAULT '0' NOT NULL,
filename varchar(255) DEFAULT '' NOT NULL,
contenttype varchar(255) DEFAULT '' NOT NULL,
md5sum varchar(32) DEFAULT '' NOT NULL,
description text DEFAULT '' NOT NULL,
INDEX md5sum (md5sum),
INDEX fromdate (fromdate),
INDEX todate (todate),
UNIQUE KEY docid (docid)
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table receiptcontents
#
CREATE TABLE receiptcontents (
docid int(11) NOT NULL DEFAULT '0',
itemid TINYINT NOT NULL DEFAULT '0',
value decimal(9,2) NOT NULL DEFAULT '0',
description text NOT NULL DEFAULT '',
regid int(11) NOT NULL DEFAULT '0',
INDEX docid (docid),
INDEX regid (regid)
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table location_states
#
CREATE TABLE location_states (
id int(11) NOT NULL auto_increment,
ident varchar(8) NOT NULL, -- TERYT: WOJ
name varchar(64) NOT NULL, -- TERYT: NAZWA
PRIMARY KEY (id),
UNIQUE KEY name (name)
) ENGINE=INNODB;
# --------------------------------------------------------
#
# Structure of table location_districts
#
CREATE TABLE location_districts (
id int(11) NOT NULL auto_increment,
name varchar(64) NOT NULL, -- TERYT: NAZWA
ident varchar(8) NOT NULL, -- TERYT: POW
stateid int(11) NOT NULL, -- TERYT: WOJ
PRIMARY KEY (id),
UNIQUE KEY stateid (stateid, name),
FOREIGN KEY (stateid) REFERENCES location_states (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table location_boroughs
#
CREATE TABLE location_boroughs (
id int(11) NOT NULL auto_increment,
name varchar(64) NOT NULL, -- TERYT: NAZWA
ident varchar(8) NOT NULL, -- TERYT: GMI
districtid int(11) NOT NULL,
type smallint NOT NULL, -- TERYT: RODZ
PRIMARY KEY (id),
UNIQUE KEY districtid (districtid, name, type),
FOREIGN KEY (districtid) REFERENCES location_districts (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=INNODB;
# --------------------------------------------------------
#
# Structure of table location_cities
#
CREATE TABLE location_cities (
id int(11) NOT NULL auto_increment,
ident varchar(8) NOT NULL, -- TERYT: SYM / SYMPOD
name varchar(64) NOT NULL, -- TERYT: NAZWA
cityid int(11) DEFAULT NULL,
boroughid int(11) DEFAULT NULL,
PRIMARY KEY (id),
INDEX cityid (cityid),
INDEX boroughid (boroughid, name),
FOREIGN KEY (boroughid) REFERENCES location_boroughs (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=INNODB;
# --------------------------------------------------------
#
# Structure of table location_street_types
#
CREATE TABLE location_street_types (
id int(11) NOT NULL auto_increment,
name varchar(8) NOT NULL, -- TERYT: CECHA
PRIMARY KEY (id)
) ENGINE=INNODB;
# --------------------------------------------------------
#
# Structure of table location_streets
#
CREATE TABLE location_streets (
id int(11) NOT NULL auto_increment,
name varchar(128) NOT NULL, -- TERYT: NAZWA_1
name2 varchar(128) DEFAULT NULL, -- TERYT: NAZWA_2
ident varchar(8) NOT NULL, -- TERYT: SYM_UL
typeid int(11) DEFAULT NULL,
cityid int(11) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY (cityid, name, ident),
FOREIGN KEY (typeid) REFERENCES location_street_types (id) ON DELETE SET NULL ON UPDATE CASCADE,
FOREIGN KEY (cityid) REFERENCES location_cities (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=INNODB;
# --------------------------------------------------------
#
# Structure of table pna
#
CREATE TABLE pna (
id int(11) NOT NULL auto_increment,
zip varchar(10) NOT NULL,
cityid int(11) NOT NULL,
streetid int(11) DEFAULT NULL,
fromhouse varchar(10) DEFAULT NULL,
tohouse varchar(10) DEFAULT NULL,
parity smallint DEFAULT '0' NOT NULL,
PRIMARY KEY (id),
UNIQUE (zip, cityid, streetid, fromhouse, tohouse, parity),
FOREIGN KEY (cityid) REFERENCES location_cities (id) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (streetid) REFERENCES location_streets (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=INNODB;
# --------------------------------------------------------
#
# Structure of tables ewx_* (EtherWerX(R))
#
CREATE TABLE ewx_stm_nodes (
id int(11) NOT NULL auto_increment,
nodeid int(11) DEFAULT '0' NOT NULL,
mac varchar(20) DEFAULT '' NOT NULL,
ipaddr int(16) unsigned DEFAULT '0' NOT NULL,
channelid int(11) DEFAULT '0' NOT NULL,
uprate int(11) DEFAULT '0' NOT NULL,
upceil int(11) DEFAULT '0' NOT NULL,
downrate int(11) DEFAULT '0' NOT NULL,
downceil int(11) DEFAULT '0' NOT NULL,
halfduplex tinyint(1) DEFAULT '0' NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY nodeid (nodeid)
) ENGINE=InnoDB;
CREATE TABLE ewx_stm_channels (
id int(11) NOT NULL auto_increment,
cid int(11) DEFAULT '0' NOT NULL,
upceil int(11) DEFAULT '0' NOT NULL,
downceil int(11) DEFAULT '0' NOT NULL,
halfduplex tinyint(1) DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY cid (cid)
) ENGINE=InnoDB;
CREATE TABLE ewx_pt_config (
id int(11) NOT NULL auto_increment,
nodeid int(11) DEFAULT '0' NOT NULL,
name varchar(32) DEFAULT '' NOT NULL,
mac varchar(20) DEFAULT '' NOT NULL,
ipaddr int(16) unsigned DEFAULT '0' NOT NULL,
passwd varchar(32) DEFAULT '' NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY nodeid (nodeid)
) ENGINE=InnoDB;
CREATE TABLE ewx_channels (
id int(11) NOT NULL auto_increment,
name varchar(32) DEFAULT '' NOT NULL,
upceil int(11) DEFAULT '0' NOT NULL,
downceil int(11) DEFAULT '0' NOT NULL,
upceil_n int(11) DEFAULT NULL,
downceil_n int(11) DEFAULT NULL,
halfduplex tinyint(1) DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY name (name)
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table divisions
#
CREATE TABLE divisions (
id int(11) NOT NULL auto_increment,
shortname varchar(255) NOT NULL DEFAULT '',
name text NOT NULL DEFAULT '',
address varchar(255) NOT NULL DEFAULT '',
city varchar(255) NOT NULL DEFAULT '',
zip varchar(255) NOT NULL DEFAULT '',
countryid int(11) NOT NULL DEFAULT '0',
ten varchar(16) NOT NULL DEFAULT '',
regon varchar(255) NOT NULL DEFAULT '',
account varchar(48) NOT NULL DEFAULT '',
inv_header text NOT NULL DEFAULT '',
inv_footer text NOT NULL DEFAULT '',
inv_author text NOT NULL DEFAULT '',
inv_cplace text NOT NULL DEFAULT '',
inv_paytime smallint DEFAULT NULL,
inv_paytype smallint DEFAULT NULL,
description text NOT NULL DEFAULT '',
status tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (id),
UNIQUE KEY shortname (shortname)
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table invprojects
#
CREATE TABLE invprojects (
id int(11) NOT NULL auto_increment,
name varchar(255) NOT NULL,
type tinyint DEFAULT 0,
divisionid int(11) DEFAULT NULL,
PRIMARY KEY (id),
FOREIGN KEY (divisionid) REFERENCES divisions (id) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=INNODB;
# --------------------------------------------------------
#
# Structure of table netnodes
#
CREATE TABLE netnodes (
id int(11) NOT NULL auto_increment,
name varchar(255) NOT NULL,
type tinyint DEFAULT 0,
invprojectid int(11),
status tinyint DEFAULT 0,
location varchar(255) DEFAULT '',
location_city int(11) DEFAULT NULL,
location_street int(11) DEFAULT NULL,
location_house varchar(32) DEFAULT NULL,
location_flat varchar(32) DEFAULT NULL,
longitude decimal(10,6) DEFAULT NULL,
latitude decimal(10,6) DEFAULT NULL,
ownership tinyint(1) DEFAULT 0,
coowner varchar(255) DEFAULT '',
uip tinyint(1) DEFAULT 0,
miar tinyint(1) DEFAULT 0,
divisionid int(11) DEFAULT NULL,
PRIMARY KEY (id),
FOREIGN KEY (invprojectid) REFERENCES invprojects (id) ON DELETE SET NULL ON UPDATE CASCADE,
FOREIGN KEY (location_city) REFERENCES location_cities (id) ON DELETE SET NULL ON UPDATE CASCADE,
FOREIGN KEY (location_street) REFERENCES location_streets (id) ON DELETE SET NULL ON UPDATE CASCADE,
FOREIGN KEY (divisionid) REFERENCES divisions (id) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=INNODB;
# --------------------------------------------------------
#
# Structure of table netdeviceproducers
#
CREATE TABLE netdeviceproducers (
id int(11) NOT NULL auto_increment,
name varchar(255) NOT NULL,
alternative_name varchar(255),
PRIMARY KEY (id),
UNIQUE (name)
) ENGINE=INNODB;
# --------------------------------------------------------
#
# Structure of table netdevicemodels
#
CREATE TABLE netdevicemodels (
id int(11) NOT NULL auto_increment,
netdeviceproducerid int(11) NOT NULL,
name varchar(255) NOT NULL,
alternative_name varchar(255),
PRIMARY KEY (id),
FOREIGN KEY (netdeviceproducerid) REFERENCES netdeviceproducers (id) ON DELETE CASCADE ON UPDATE CASCADE,
UNIQUE (name, netdeviceproducerid)
) ENGINE=INNODB;
# --------------------------------------------------------
#
# Structure of table netdevices
#
CREATE TABLE netdevices (
id int(11) NOT NULL auto_increment,
name varchar(32) NOT NULL DEFAULT '',
location varchar(255) NOT NULL DEFAULT '',
location_city int(11) DEFAULT NULL,
location_street int(11) DEFAULT NULL,
location_house varchar(32) DEFAULT NULL,
location_flat varchar(32) DEFAULT NULL,
description text NOT NULL DEFAULT '',
producer varchar(64) NOT NULL DEFAULT '',
model varchar(32) NOT NULL DEFAULT '',
serialnumber varchar(32) NOT NULL DEFAULT '',
ports int(11) NOT NULL DEFAULT '0',
purchasetime int(11) NOT NULL DEFAULT '0',
guaranteeperiod tinyint unsigned DEFAULT '0',
shortname varchar(32) NOT NULL DEFAULT '',
nastype int(11) NOT NULL DEFAULT '0',
clients int(11) NOT NULL DEFAULT '0',
secret varchar(60) NOT NULL DEFAULT '',
community varchar(50) NOT NULL DEFAULT '',
channelid int(11) DEFAULT NULL,
longitude decimal(10, 6) DEFAULT NULL,
latitude decimal(10, 6) DEFAULT NULL,
netnodeid int(11) DEFAULT NULL,
invprojectid int(11) DEFAULT NULL,
status tinyint DEFAULT '0',
netdevicemodelid int(11) DEFAULT NULL,
PRIMARY KEY (id),
INDEX channelid (channelid),
INDEX location_city (location_city, location_street, location_house, location_flat),
INDEX location_street (location_street),
FOREIGN KEY (location_city) REFERENCES location_cities (id) ON DELETE SET NULL ON UPDATE CASCADE,
FOREIGN KEY (location_street) REFERENCES location_streets (id) ON DELETE SET NULL ON UPDATE CASCADE,
FOREIGN KEY (channelid) REFERENCES ewx_channels (id) ON DELETE SET NULL ON UPDATE CASCADE,
FOREIGN KEY (netnodeid) REFERENCES netnodes (id) ON DELETE SET NULL ON UPDATE CASCADE,
FOREIGN KEY (invprojectid) REFERENCES invprojects (id) ON DELETE SET NULL ON UPDATE CASCADE,
FOREIGN KEY (netdevicemodelid) REFERENCES netdevicemodels (id) ON UPDATE CASCADE ON DELETE SET NULL
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table netradiosectors
#
CREATE TABLE netradiosectors (
id int(11) NOT NULL auto_increment,
name varchar(64) NOT NULL,
azimuth decimal(9,2) DEFAULT 0 NOT NULL,
width decimal(9,2) DEFAULT 0 NOT NULL,
altitude smallint DEFAULT 0 NOT NULL,
rsrange int(11) DEFAULT 0 NOT NULL,
license varchar(64) DEFAULT NULL,
technology int(11) DEFAULT 0 NOT NULL,
frequency numeric(9,5) DEFAULT NULL,
frequency2 numeric(9,5) DEFAULT NULL,
bandwidth numeric(9,5) DEFAULT NULL,
netdev int(11) NOT NULL,
PRIMARY KEY (id),
INDEX netdev (netdev),
FOREIGN KEY (netdev) REFERENCES netdevices (id) ON DELETE CASCADE ON UPDATE CASCADE,
UNIQUE KEY name (name, netdev)
) ENGINE=INNODB;
# --------------------------------------------------------
#
# Structure of table netlinks
#
CREATE TABLE netlinks (
id int(11) NOT NULL auto_increment,
src int(11) NOT NULL DEFAULT '0',
dst int(11) NOT NULL DEFAULT '0',
type tinyint(1) NOT NULL DEFAULT '0',
speed int(11) NOT NULL DEFAULT '100000',
technology int(11) NOT NULL DEFAULT '0',
srcport smallint NOT NULL DEFAULT '0',
dstport smallint NOT NULL DEFAULT '0',
srcradiosector int(11) DEFAULT NULL,
dstradiosector int(11) DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY src (src,dst),
INDEX srcradiosector (srcradiosector),
INDEX dstradiosector (dstradiosector),
FOREIGN KEY (srcradiosector) REFERENCES netradiosectors (id) ON DELETE SET NULL ON UPDATE CASCADE,
FOREIGN KEY (dstradiosector) REFERENCES netradiosectors (id) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table hosts
#
CREATE TABLE hosts (
id int(11) NOT NULL auto_increment,
name varchar(255) DEFAULT '' NOT NULL,
description text DEFAULT '' NOT NULL,
lastreload int(11) DEFAULT '0' NOT NULL,
reload tinyint(1) DEFAULT '0' NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY name (name)
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table networks
#
CREATE TABLE networks (
id int(11) NOT NULL auto_increment,
name varchar(128) NOT NULL DEFAULT '',
address int(16) unsigned NOT NULL DEFAULT '0',
mask varchar(16) NOT NULL DEFAULT '',
gateway varchar(16) NOT NULL DEFAULT '',
interface varchar(16) NOT NULL DEFAULT '',
dns varchar(16) NOT NULL DEFAULT '',
dns2 varchar(16) NOT NULL DEFAULT '',
domain varchar(64) NOT NULL DEFAULT '',
wins varchar(16) NOT NULL DEFAULT '',
dhcpstart varchar(16) NOT NULL DEFAULT '',
dhcpend varchar(16) NOT NULL DEFAULT '',
disabled tinyint(1) NOT NULL DEFAULT '0',
notes text NOT NULL DEFAULT '',
hostid int(11) DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY name (name),
UNIQUE KEY address (address, hostid),
FOREIGN KEY (hostid) REFERENCES hosts (id) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table nodes
#
CREATE TABLE nodes (
id int(11) NOT NULL auto_increment,
name varchar(32) NOT NULL DEFAULT '',
ipaddr int(16) unsigned NOT NULL DEFAULT '0',
ipaddr_pub int(16) unsigned NOT NULL DEFAULT '0',
passwd varchar(32) NOT NULL DEFAULT '',
ownerid int(11) NOT NULL DEFAULT '0',
creationdate int(11) NOT NULL DEFAULT '0',
moddate int(11) NOT NULL DEFAULT '0',
creatorid int(11) NOT NULL DEFAULT '0',
modid int(11) NOT NULL DEFAULT '0',
netdev int(11) NOT NULL DEFAULT '0',
linktype tinyint(1) NOT NULL DEFAULT '0',
linkradiosector int(11) DEFAULT NULL,
linkspeed int(11) NOT NULL DEFAULT '100000',
linktechnology int(11) NOT NULL DEFAULT '0',
port smallint NOT NULL DEFAULT '0',
access tinyint(1) NOT NULL DEFAULT '1',
warning tinyint(1) NOT NULL DEFAULT '0',
authtype tinyint(1) NOT NULL DEFAULT '0',
chkmac tinyint(1) NOT NULL DEFAULT '1',
halfduplex tinyint(1) NOT NULL DEFAULT '0',
lastonline int(11) NOT NULL DEFAULT '0',
info text NOT NULL DEFAULT '',
location varchar(255) DEFAULT NULL,
location_city int(11) DEFAULT NULL,
location_street int(11) DEFAULT NULL,
location_house varchar(32) DEFAULT NULL,
location_flat varchar(32) DEFAULT NULL,
nas tinyint(1) NOT NULL DEFAULT '0',
longitude decimal(10, 6) DEFAULT NULL,
latitude decimal(10, 6) DEFAULT NULL,
netid int(11) NOT NULL DEFAULT '0',
invprojectid int(11) DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY name (name),
UNIQUE KEY ipaddr (ipaddr, netid),
INDEX netdev (netdev),
INDEX ownerid (ownerid),
INDEX ipaddr_pub (ipaddr_pub),
INDEX location_city (location_city, location_street, location_house, location_flat),
INDEX location_street (location_street),
INDEX linkradiosector (linkradiosector),
INDEX authtype (authtype),
FOREIGN KEY (location_city) REFERENCES location_cities (id) ON DELETE SET NULL ON UPDATE CASCADE,
FOREIGN KEY (location_street) REFERENCES location_streets (id) ON DELETE SET NULL ON UPDATE CASCADE,
FOREIGN KEY (netid) REFERENCES networks (id) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (invprojectid) REFERENCES invprojects(id) ON DELETE SET NULL ON UPDATE CASCADE,
FOREIGN KEY (linkradiosector) REFERENCES netradiosectors (id) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table nodelocks
#
CREATE TABLE nodelocks (
id int(11) NOT NULL auto_increment,
nodeid int(11) NOT NULL,
days smallint DEFAULT 0 NOT NULL,
fromsec int(11) DEFAULT 0 NOT NULL,
tosec int(11) DEFAULT 0 NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (nodeid) REFERENCES nodes (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=INNODB;
# --------------------------------------------------------
#
# Structure of table macs
#
CREATE TABLE macs (
id int(11) NOT NULL auto_increment,
mac varchar(17) NOT NULL DEFAULT '',
nodeid int(11) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY mac (mac, nodeid),
FOREIGN KEY (nodeid) REFERENCES nodes (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table nodegroups
#
CREATE TABLE nodegroups (
id int(11) NOT NULL auto_increment,
name varchar(255) NOT NULL DEFAULT '',
prio int(11) NOT NULL DEFAULT '0',
description text NOT NULL DEFAULT '',
PRIMARY KEY (id),
UNIQUE KEY name (name)
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table nodegroupassignments
#
CREATE TABLE nodegroupassignments (
id int(11) NOT NULL auto_increment,
nodegroupid int(11) NOT NULL DEFAULT 0,
nodeid int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (id),
UNIQUE KEY nodeid (nodeid, nodegroupid)
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table nodeassignments
#
CREATE TABLE nodeassignments (
id int(11) NOT NULL auto_increment,
nodeid int(11) NOT NULL,
assignmentid int(11) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY nodeid (nodeid, assignmentid),
INDEX assignmentid (assignmentid),
FOREIGN KEY (nodeid) REFERENCES nodes (id) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (assignmentid) REFERENCES assignments (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table payments
#
CREATE TABLE payments (
id int(11) NOT NULL auto_increment,
name varchar(255) NOT NULL DEFAULT '',
value decimal(9,2) NOT NULL DEFAULT '0',
creditor varchar(255) NOT NULL DEFAULT '',
period smallint NOT NULL DEFAULT '0',
at smallint NOT NULL DEFAULT '0',
description text NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table rtqueues
#
CREATE TABLE rtqueues (
id int(11) NOT NULL auto_increment,
name varchar(255) NOT NULL DEFAULT '',
email varchar(255) NOT NULL DEFAULT '',
description text NOT NULL DEFAULT '',
newticketsubject varchar(255) NOT NULL DEFAULT '',
newticketbody text NOT NULL DEFAULT '',
newmessagesubject varchar(255) NOT NULL DEFAULT '',
newmessagebody text NOT NULL DEFAULT '',
resolveticketsubject varchar(255) NOT NULL DEFAULT '',
resolveticketbody text NOT NULL DEFAULT '',
PRIMARY KEY (id),
UNIQUE KEY name (name)
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table rttickets
#
CREATE TABLE rttickets (
id int(11) NOT NULL auto_increment,
queueid int(11) NOT NULL,
requestor varchar(255) NOT NULL DEFAULT '',
subject varchar(255) NOT NULL DEFAULT '',
state tinyint(4) NOT NULL DEFAULT '0',
cause tinyint(4) NOT NULL DEFAULT '0',
owner int(11) NOT NULL DEFAULT '0',
customerid int(11) NOT NULL DEFAULT '0',
creatorid int(11) NOT NULL DEFAULT '0',
createtime int(11) NOT NULL DEFAULT '0',
resolvetime int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (id),
INDEX queueid (queueid),
INDEX customerid (customerid),
INDEX creatorid (creatorid),
INDEX createtime (createtime),
FOREIGN KEY (queueid) REFERENCES rtqueues (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
# --------------------------------------------------------
#
# Structure of table rtmessages
#
CREATE TABLE rtmessages (
id int(11) NOT NULL auto_increment,
ticketid int(11) NOT NULL,
userid int(11) NOT NULL DEFAULT '0',
customerid int(11) NOT NULL DEFAULT '0',
mailfrom varchar(255) NOT NULL DEFAULT '',
subject varchar(255) NOT NULL DEFAULT '',
messageid varchar(255) NOT NULL DEFAULT '',
inreplyto int(11) NOT NULL DEFAULT '0',
replyto text NOT NULL DEFAULT '',
headers text NOT NULL DEFAULT '',
body mediumtext NOT NULL DEFAULT '',
createtime int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (id),
INDEX ticketid (ticketid),