forked from chilek/lms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlms.pgsql
2649 lines (2508 loc) · 101 KB
/
lms.pgsql
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$ */
/* --------------------------------------------------------
Structure of table "users"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS users_id_seq;
CREATE SEQUENCE users_id_seq;
DROP TABLE IF EXISTS users CASCADE;
CREATE TABLE users (
id integer DEFAULT nextval('users_id_seq'::text) NOT NULL,
login varchar(32) DEFAULT '' NOT NULL,
name varchar(64) DEFAULT '' NOT NULL,
email varchar(255) DEFAULT '' NOT NULL,
phone varchar(32) DEFAULT NULL,
position varchar(255) DEFAULT '' NOT NULL,
rights text DEFAULT '' NOT NULL,
hosts varchar(255) DEFAULT '' NOT NULL,
passwd varchar(255) DEFAULT '' NOT NULL,
ntype smallint DEFAULT NULL,
lastlogindate integer DEFAULT 0 NOT NULL,
lastloginip varchar(16) DEFAULT '' NOT NULL,
failedlogindate integer DEFAULT 0 NOT NULL,
failedloginip varchar(16) DEFAULT '' NOT NULL,
deleted smallint DEFAULT 0 NOT NULL,
passwdexpiration integer DEFAULT 0 NOT NULL,
passwdlastchange integer DEFAULT 0 NOT NULL,
access smallint DEFAULT 1 NOT NULL,
accessfrom integer DEFAULT 0 NOT NULL,
accessto integer DEFAULT 0 NOT NULL,
swekey_id varchar(32) DEFAULT NULL,
settings text NOT NULL DEFAULT '',
PRIMARY KEY (id),
UNIQUE (login, swekey_id)
);
/* --------------------------------------------------------
Structure of table "customers" (customers)
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS customers_id_seq;
CREATE SEQUENCE customers_id_seq;
DROP TABLE IF EXISTS customers CASCADE;
CREATE TABLE customers (
id integer DEFAULT nextval('customers_id_seq'::text) NOT NULL,
extid varchar(32) DEFAULT '' NOT NULL,
lastname varchar(128) DEFAULT '' NOT NULL,
name varchar(128) DEFAULT '' NOT NULL,
status smallint DEFAULT 0 NOT NULL,
type smallint DEFAULT 0 NOT NULL,
street varchar(255) DEFAULT '' NOT NULL,
building varchar(20) DEFAULT NULL,
apartment varchar(20) DEFAULT NULL,
zip varchar(10) DEFAULT '' NOT NULL,
city varchar(32) DEFAULT '' NOT NULL,
countryid integer 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 integer DEFAULT NULL,
ten varchar(16) DEFAULT '' NOT NULL,
ssn varchar(11) DEFAULT '' NOT NULL,
regon varchar(255) DEFAULT '' NOT NULL,
rbe varchar(255) DEFAULT '' NOT NULL, -- EDG/KRS
icn varchar(255) DEFAULT '' NOT NULL, -- dow.os.
info text DEFAULT '' NOT NULL,
notes text DEFAULT '' NOT NULL,
creationdate integer DEFAULT 0 NOT NULL,
moddate integer DEFAULT 0 NOT NULL,
creatorid integer DEFAULT 0 NOT NULL,
modid integer DEFAULT 0 NOT NULL,
deleted smallint DEFAULT 0 NOT NULL,
message text DEFAULT '' NOT NULL,
pin varchar(6) DEFAULT 0 NOT NULL,
cutoffstop integer DEFAULT 0 NOT NULL,
consentdate integer DEFAULT 0 NOT NULL,
einvoice smallint DEFAULT NULL,
invoicenotice smallint DEFAULT NULL,
mailingnotice smallint DEFAULT NULL,
divisionid integer DEFAULT 0 NOT NULL,
paytime smallint DEFAULT -1 NOT NULL,
paytype smallint DEFAULT NULL,
PRIMARY KEY (id)
);
CREATE INDEX customers_zip_idx ON customers (zip);
CREATE INDEX customers_lastname_idx ON customers (lastname, name);
/* --------------------------------------------------------
Structure of table "numberplans"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS numberplans_id_seq;
CREATE SEQUENCE numberplans_id_seq;
DROP TABLE IF EXISTS numberplans CASCADE;
CREATE TABLE numberplans (
id integer DEFAULT nextval('numberplans_id_seq'::text) NOT NULL,
template varchar(255) DEFAULT '' NOT NULL,
period smallint DEFAULT 0 NOT NULL,
doctype integer DEFAULT 0 NOT NULL,
isdefault smallint DEFAULT 0 NOT NULL,
PRIMARY KEY (id)
);
/* ----------------------------------------------------
Structure of table "assignments"
---------------------------------------------------*/
DROP SEQUENCE IF EXISTS assignments_id_seq;
CREATE SEQUENCE assignments_id_seq;
DROP TABLE IF EXISTS assignments CASCADE;
CREATE TABLE assignments (
id integer default nextval('assignments_id_seq'::text) NOT NULL,
tariffid integer DEFAULT 0 NOT NULL,
liabilityid integer DEFAULT 0 NOT NULL,
customerid integer NOT NULL
REFERENCES customers (id) ON DELETE CASCADE ON UPDATE CASCADE,
period smallint DEFAULT 0 NOT NULL,
at integer DEFAULT 0 NOT NULL,
datefrom integer DEFAULT 0 NOT NULL,
dateto integer DEFAULT 0 NOT NULL,
invoice smallint DEFAULT 0 NOT NULL,
suspended smallint DEFAULT 0 NOT NULL,
settlement smallint DEFAULT 0 NOT NULL,
pdiscount numeric(4,2) DEFAULT 0 NOT NULL,
vdiscount numeric(9,2) DEFAULT 0 NOT NULL,
paytype smallint DEFAULT NULL,
numberplanid integer DEFAULT NULL
REFERENCES numberplans (id) ON DELETE SET NULL ON UPDATE CASCADE,
attribute varchar(255) DEFAULT NULL,
PRIMARY KEY (id)
);
CREATE INDEX assignments_tariffid_idx ON assignments (tariffid);
CREATE INDEX assignments_customerid_idx ON assignments (customerid);
CREATE INDEX assignments_numberplanid_idx ON assignments (numberplanid);
/* --------------------------------------------------------
Structure of table "cash"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS cash_id_seq;
CREATE SEQUENCE cash_id_seq;
DROP TABLE IF EXISTS cash CASCADE;
CREATE TABLE cash (
id integer DEFAULT nextval('cash_id_seq'::text) NOT NULL,
time integer DEFAULT 0 NOT NULL,
type smallint DEFAULT 0 NOT NULL,
userid integer DEFAULT 0 NOT NULL,
value numeric(9,2) DEFAULT 0 NOT NULL,
taxid integer DEFAULT 0 NOT NULL,
customerid integer DEFAULT 0 NOT NULL,
comment text DEFAULT '' NOT NULL,
docid integer DEFAULT 0 NOT NULL,
itemid smallint DEFAULT 0 NOT NULL,
importid integer DEFAULT NULL,
sourceid integer DEFAULT NULL,
PRIMARY KEY (id)
);
CREATE INDEX cash_customerid_idx ON cash (customerid);
CREATE INDEX cash_docid_idx ON cash (docid);
CREATE INDEX cash_importid_idx ON cash (importid);
CREATE INDEX cash_sourceid_idx ON cash (sourceid);
CREATE INDEX cash_time_idx ON cash (time);
/* --------------------------------------------------------
Structure of table "location_states"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS location_states_id_seq;
CREATE SEQUENCE location_states_id_seq;
DROP TABLE IF EXISTS location_states CASCADE;
CREATE TABLE location_states (
id integer DEFAULT nextval('location_states_id_seq'::text) NOT NULL,
ident varchar(8) NOT NULL, -- TERYT: WOJ
name varchar(64) NOT NULL, -- TERYT: NAZWA
PRIMARY KEY (id),
UNIQUE (name)
);
/* --------------------------------------------------------
Structure of table "location_districts"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS location_districts_id_seq;
CREATE SEQUENCE location_districts_id_seq;
DROP TABLE IF EXISTS location_districts CASCADE;
CREATE TABLE location_districts (
id integer DEFAULT nextval('location_districts_id_seq'::text) NOT NULL,
name varchar(64) NOT NULL, --TERYT: NAZWA
ident varchar(8) NOT NULL, --TERYT: POW
stateid integer NOT NULL --TERYT: WOJ
REFERENCES location_states (id) ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (id),
UNIQUE (stateid, name)
);
/* --------------------------------------------------------
Structure of table "location_boroughs"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS location_boroughs_id_seq;
CREATE SEQUENCE location_boroughs_id_seq;
DROP TABLE IF EXISTS location_boroughs CASCADE;
CREATE TABLE location_boroughs (
id integer DEFAULT nextval('location_boroughs_id_seq'::text) NOT NULL,
name varchar(64) NOT NULL, -- TERYT: NAZWA
ident varchar(8) NOT NULL, -- TERYT: GMI
districtid integer NOT NULL
REFERENCES location_districts (id) ON DELETE CASCADE ON UPDATE CASCADE,
type smallint NOT NULL, -- TERYT: RODZ
PRIMARY KEY (id),
UNIQUE (districtid, name, type)
);
/* --------------------------------------------------------
Structure of table "location_cities"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS location_cities_id_seq;
CREATE SEQUENCE location_cities_id_seq;
DROP TABLE IF EXISTS location_cities CASCADE;
CREATE TABLE location_cities (
id integer DEFAULT nextval('location_cities_id_seq'::text) NOT NULL,
ident varchar(8) NOT NULL, -- TERYT: SYM / SYMPOD
name varchar(64) NOT NULL, -- TERYT: NAZWA
cityid integer DEFAULT NULL,
boroughid integer DEFAULT NULL
REFERENCES location_boroughs (id) ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (id)
);
CREATE INDEX location_cities_cityid ON location_cities (cityid);
CREATE INDEX location_cities_boroughid ON location_cities (boroughid, name);
/* --------------------------------------------------------
Structure of table "location_street_types"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS location_street_types_id_seq;
CREATE SEQUENCE location_street_types_id_seq;
DROP TABLE IF EXISTS location_street_types CASCADE;
CREATE TABLE location_street_types (
id integer DEFAULT nextval('location_street_types_id_seq'::text) NOT NULL,
name varchar(8) NOT NULL, -- TERYT: CECHA
PRIMARY KEY (id)
);
/* --------------------------------------------------------
Structure of table "location_streets"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS location_streets_id_seq;
CREATE SEQUENCE location_streets_id_seq;
DROP TABLE IF EXISTS location_streets CASCADE;
CREATE TABLE location_streets (
id integer DEFAULT nextval('location_streets_id_seq'::text) NOT NULL,
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 integer DEFAULT NULL
REFERENCES location_street_types (id) ON DELETE SET NULL ON UPDATE CASCADE,
cityid integer NOT NULL
REFERENCES location_cities (id) ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (id),
UNIQUE (cityid, name, ident)
);
/* --------------------------------------------------------
Structure of table "pna"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS pna_id_seq;
CREATE SEQUENCE pna_id_seq;
DROP TABLE IF EXISTS pna CASCADE;
CREATE TABLE pna (
id integer DEFAULT nextval('pna_id_seq'::text) NOT NULL,
zip varchar(128) NOT NULL,
cityid integer NOT NULL
REFERENCES location_cities (id) ON DELETE CASCADE ON UPDATE CASCADE,
streetid integer DEFAULT NULL
REFERENCES location_streets (id) ON DELETE CASCADE ON UPDATE CASCADE,
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)
);
/* ---------------------------------------------------
Structure of table "ewx_stm_nodes" (EtherWerX(R))
------------------------------------------------------*/
DROP SEQUENCE IF EXISTS ewx_stm_nodes_id_seq;
CREATE SEQUENCE ewx_stm_nodes_id_seq;
DROP TABLE IF EXISTS ewx_stm_nodes CASCADE;
CREATE TABLE ewx_stm_nodes (
id integer DEFAULT nextval('ewx_stm_nodes_id_seq'::text) NOT NULL,
nodeid integer DEFAULT 0 NOT NULL,
mac varchar(20) DEFAULT '' NOT NULL,
ipaddr bigint DEFAULT 0 NOT NULL,
channelid integer DEFAULT 0 NOT NULL,
uprate integer DEFAULT 0 NOT NULL,
upceil integer DEFAULT 0 NOT NULL,
downrate integer DEFAULT 0 NOT NULL,
downceil integer DEFAULT 0 NOT NULL,
halfduplex smallint DEFAULT 0 NOT NULL,
PRIMARY KEY (id),
UNIQUE (nodeid)
);
/* ---------------------------------------------------
Structure of table "ewx_stm_channels" (EtherWerX(R))
------------------------------------------------------*/
DROP SEQUENCE IF EXISTS ewx_stm_channels_id_seq;
CREATE SEQUENCE ewx_stm_channels_id_seq;
DROP TABLE IF EXISTS ewx_stm_channels CASCADE;
CREATE TABLE ewx_stm_channels (
id integer DEFAULT nextval('ewx_stm_channels_id_seq'::text) NOT NULL,
cid integer DEFAULT 0 NOT NULL,
upceil integer DEFAULT 0 NOT NULL,
downceil integer DEFAULT 0 NOT NULL,
halfduplex smallint DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE (cid)
);
/* ---------------------------------------------------
Structure of table "ewx_channels" (EtherWerX(R))
------------------------------------------------------*/
DROP SEQUENCE IF EXISTS ewx_channels_id_seq;
CREATE SEQUENCE ewx_channels_id_seq;
DROP TABLE IF EXISTS ewx_channels CASCADE;
CREATE TABLE ewx_channels (
id integer DEFAULT nextval('ewx_channels_id_seq'::text) NOT NULL,
name varchar(32) DEFAULT '' NOT NULL,
upceil integer DEFAULT 0 NOT NULL,
downceil integer DEFAULT 0 NOT NULL,
upceil_n integer DEFAULT NULL,
downceil_n integer DEFAULT NULL,
halfduplex smallint DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE (name)
);
/* ---------------------------------------------------
Structure of table "hosts"
------------------------------------------------------*/
DROP SEQUENCE IF EXISTS hosts_id_seq;
CREATE SEQUENCE hosts_id_seq;
DROP TABLE IF EXISTS hosts CASCADE;
CREATE TABLE hosts (
id integer DEFAULT nextval('hosts_id_seq'::text) NOT NULL,
name varchar(255) DEFAULT '' NOT NULL,
description text DEFAULT '' NOT NULL,
lastreload integer DEFAULT 0 NOT NULL,
reload smallint DEFAULT 0 NOT NULL,
PRIMARY KEY (id),
UNIQUE (name)
);
/* --------------------------------------------------------
Structure of table "networks"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS networks_id_seq;
CREATE SEQUENCE networks_id_seq;
DROP TABLE IF EXISTS networks CASCADE;
CREATE TABLE networks (
id integer DEFAULT nextval('networks_id_seq'::text) NOT NULL,
name varchar(255) DEFAULT '' NOT NULL,
address bigint DEFAULT 0 NOT NULL,
mask varchar(16) DEFAULT '' NOT NULL,
interface varchar(16) DEFAULT '' NOT NULL,
gateway varchar(16) DEFAULT '' NOT NULL,
dns varchar(16) DEFAULT '' NOT NULL,
dns2 varchar(16) DEFAULT '' NOT NULL,
domain varchar(64) DEFAULT '' NOT NULL,
wins varchar(16) DEFAULT '' NOT NULL,
dhcpstart varchar(16) DEFAULT '' NOT NULL,
dhcpend varchar(16) DEFAULT '' NOT NULL,
disabled smallint DEFAULT 0 NOT NULL,
notes text DEFAULT '' NOT NULL,
hostid integer NULL
REFERENCES hosts (id) ON DELETE SET NULL ON UPDATE CASCADE,
PRIMARY KEY (id),
UNIQUE (name),
CONSTRAINT networks_address_key UNIQUE (address, hostid)
);
CREATE INDEX networks_hostid_idx ON networks (hostid);
/* ---------------------------------------------------
Structure of table "invprojects"
------------------------------------------------------*/
DROP SEQUENCE IF EXISTS invprojects_id_seq;
CREATE SEQUENCE invprojects_id_seq;
DROP TABLE IF EXISTS invprojects CASCADE;
CREATE TABLE invprojects (
id integer DEFAULT nextval('invprojects_id_seq'::text) NOT NULL,
name varchar(255) NOT NULL,
type smallint DEFAULT 0,
divisionid integer DEFAULT NULL
REFERENCES divisions (id) ON DELETE SET NULL ON UPDATE CASCADE,
PRIMARY KEY(id)
);
/* ---------------------------------------------------
Structure of table "netnodes"
------------------------------------------------------*/
DROP SEQUENCE IF EXISTS netnodes_id_seq;
CREATE SEQUENCE netnodes_id_seq;
DROP TABLE IF EXISTS netnodes CASCADE;
CREATE TABLE netnodes (
id integer DEFAULT nextval('netnodes_id_seq'::text) NOT NULL,
name varchar(255) NOT NULL,
type smallint DEFAULT 0,
invprojectid integer
REFERENCES invprojects (id) ON DELETE SET NULL ON UPDATE CASCADE,
status smallint DEFAULT 0,
location varchar(255) DEFAULT '',
location_city integer DEFAULT NULL
REFERENCES location_cities (id) ON DELETE SET NULL ON UPDATE CASCADE,
location_street integer DEFAULT NULL
REFERENCES location_streets (id) ON DELETE SET NULL ON UPDATE CASCADE,
location_house varchar(32) DEFAULT NULL,
location_flat varchar(32) DEFAULT NULL,
longitude numeric(10,6) DEFAULT NULL,
latitude numeric(10,6) DEFAULT NULL,
ownership smallint DEFAULT 0,
coowner varchar(255) DEFAULT '',
uip smallint DEFAULT 0,
miar smallint DEFAULT 0,
divisionid integer
REFERENCES divisions (id) ON DELETE SET NULL ON UPDATE CASCADE,
PRIMARY KEY(id)
);
/* ---------------------------------------------------
Structure of table "netdeviceproducers"
------------------------------------------------------*/
DROP SEQUENCE IF EXISTS netdeviceproducers_id_seq;
CREATE SEQUENCE netdeviceproducers_id_seq;
DROP TABLE IF EXISTS netdeviceproducers CASCADE;
CREATE TABLE netdeviceproducers (
id integer DEFAULT nextval('netdeviceproducers_id_seq'::text) NOT NULL,
name varchar(255) NOT NULL,
alternative_name VARCHAR(255),
PRIMARY KEY (id),
UNIQUE (name)
);
/* ---------------------------------------------------
Structure of table "netdevicemodels"
------------------------------------------------------*/
DROP SEQUENCE IF EXISTS netdevicemodels_id_seq;
CREATE SEQUENCE netdevicemodels_id_seq;
DROP TABLE IF EXISTS netdevicemodels CASCADE;
CREATE TABLE netdevicemodels (
id integer DEFAULT nextval('netdevicemodels_id_seq'::text) NOT NULL,
netdeviceproducerid integer 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)
);
/* ---------------------------------------------------
Structure of table "netdevices"
----------------------------------------------------*/
DROP SEQUENCE IF EXISTS netdevices_id_seq;
CREATE SEQUENCE netdevices_id_seq;
DROP TABLE IF EXISTS netdevices CASCADE;
CREATE TABLE netdevices (
id integer default nextval('netdevices_id_seq'::text) NOT NULL,
name varchar(32) DEFAULT '' NOT NULL,
location varchar(255) DEFAULT '' NOT NULL,
location_city integer DEFAULT NULL
REFERENCES location_cities (id) ON DELETE SET NULL ON UPDATE CASCADE,
location_street integer DEFAULT NULL
REFERENCES location_streets (id) ON DELETE SET NULL ON UPDATE CASCADE,
location_house varchar(32) DEFAULT NULL,
location_flat varchar(32) DEFAULT NULL,
description text DEFAULT '' NOT NULL,
producer varchar(64) DEFAULT '' NOT NULL,
model varchar(32) DEFAULT '' NOT NULL,
serialnumber varchar(32) DEFAULT '' NOT NULL,
ports integer DEFAULT 0 NOT NULL,
purchasetime integer DEFAULT 0 NOT NULL,
guaranteeperiod smallint DEFAULT 0,
shortname varchar(32) DEFAULT '' NOT NULL,
nastype integer DEFAULT 0 NOT NULL,
clients integer DEFAULT 0 NOT NULL,
secret varchar(60) DEFAULT '' NOT NULL,
community varchar(50) DEFAULT '' NOT NULL,
channelid integer DEFAULT NULL
REFERENCES ewx_channels (id) ON DELETE SET NULL ON UPDATE CASCADE,
longitude numeric(10, 6) DEFAULT NULL,
latitude numeric(10, 6) DEFAULT NULL,
netnodeid integer DEFAULT NULL
REFERENCES netnodes(id) ON DELETE SET NULL ON UPDATE CASCADE,
invprojectid integer DEFAULT NULL
REFERENCES invprojects(id) ON DELETE SET NULL ON UPDATE CASCADE,
status smallint DEFAULT 0,
netdevicemodelid integer DEFAULT NULL
REFERENCES netdevicemodels (id) ON UPDATE CASCADE ON DELETE SET NULL,
PRIMARY KEY (id)
);
CREATE INDEX netdevices_channelid_idx ON netdevices (channelid);
CREATE INDEX netdevices_location_street_idx ON netdevices (location_street);
CREATE INDEX netdevices_location_city_idx ON netdevices (location_city, location_street, location_house, location_flat);
/* ---------------------------------------------------
Structure of table "netradiosectors"
------------------------------------------------------*/
DROP SEQUENCE IF EXISTS netradiosectors_id_seq;
CREATE SEQUENCE netradiosectors_id_seq;
DROP TABLE IF EXISTS netradiosectors CASCADE;
CREATE TABLE netradiosectors (
id integer DEFAULT nextval('netradiosectors_id_seq'::text) NOT NULL,
name varchar(64) NOT NULL,
azimuth numeric(9,2) DEFAULT 0 NOT NULL,
width numeric(9,2) DEFAULT 0 NOT NULL,
altitude smallint DEFAULT 0 NOT NULL,
rsrange integer DEFAULT 0 NOT NULL,
license varchar(64) DEFAULT NULL,
technology integer DEFAULT 0 NOT NULL,
frequency numeric(9,5) DEFAULT NULL,
frequency2 numeric(9,5) DEFAULT NULL,
bandwidth numeric(9,5) DEFAULT NULL,
netdev integer NOT NULL
REFERENCES netdevices (id) ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (id),
UNIQUE (name, netdev)
);
/* --------------------------------------------------------
Structure of table "nodes"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS nodes_id_seq;
CREATE SEQUENCE nodes_id_seq;
DROP TABLE IF EXISTS nodes CASCADE;
CREATE TABLE nodes (
id integer DEFAULT nextval('nodes_id_seq'::text) NOT NULL,
name varchar(32) DEFAULT '' NOT NULL,
ipaddr bigint DEFAULT 0 NOT NULL,
ipaddr_pub bigint DEFAULT 0 NOT NULL,
passwd varchar(32) DEFAULT '' NOT NULL,
ownerid integer DEFAULT 0 NOT NULL,
netdev integer DEFAULT 0 NOT NULL,
linktype smallint DEFAULT 0 NOT NULL,
linkradiosector integer DEFAULT NULL
REFERENCES netradiosectors (id) ON DELETE SET NULL ON UPDATE CASCADE,
linkspeed integer DEFAULT 100000 NOT NULL,
linktechnology integer DEFAULT 0 NOT NULL,
port smallint DEFAULT 0 NOT NULL,
creationdate integer DEFAULT 0 NOT NULL,
moddate integer DEFAULT 0 NOT NULL,
creatorid integer DEFAULT 0 NOT NULL,
modid integer DEFAULT 0 NOT NULL,
access smallint DEFAULT 1 NOT NULL,
warning smallint DEFAULT 0 NOT NULL,
authtype smallint DEFAULT 0 NOT NULL,
chkmac smallint DEFAULT 1 NOT NULL,
halfduplex smallint DEFAULT 0 NOT NULL,
lastonline integer DEFAULT 0 NOT NULL,
info text DEFAULT '' NOT NULL,
location varchar(255) DEFAULT NULL,
location_city integer DEFAULT NULL
REFERENCES location_cities (id) ON DELETE SET NULL ON UPDATE CASCADE,
location_street integer DEFAULT NULL
REFERENCES location_streets (id) ON DELETE SET NULL ON UPDATE CASCADE,
location_house varchar(32) DEFAULT NULL,
location_flat varchar(32) DEFAULT NULL,
nas smallint DEFAULT 0 NOT NULL,
longitude numeric(10, 6) DEFAULT NULL,
latitude numeric(10, 6) DEFAULT NULL,
netid integer DEFAULT 0 NOT NULL
REFERENCES networks (id) ON DELETE CASCADE ON UPDATE CASCADE,
invprojectid integer DEFAULT NULL
REFERENCES invprojects(id) ON DELETE SET NULL ON UPDATE CASCADE,
PRIMARY KEY (id),
UNIQUE (name),
UNIQUE (ipaddr, netid)
);
CREATE INDEX nodes_netdev_idx ON nodes (netdev);
CREATE INDEX nodes_ownerid_idx ON nodes (ownerid);
CREATE INDEX nodes_ipaddr_pub_idx ON nodes (ipaddr_pub);
CREATE INDEX nodes_location_street_idx ON nodes (location_street);
CREATE INDEX nodes_location_city_idx ON nodes (location_city, location_street, location_house, location_flat);
CREATE INDEX nodes_linkradiosector_idx ON nodes (linkradiosector);
CREATE INDEX nodes_authtype_idx ON nodes (authtype);
/* ----------------------------------------------------
Structure of table "nodelocks"
---------------------------------------------------*/
DROP SEQUENCE IF EXISTS nodelocks_id_seq;
CREATE SEQUENCE nodelocks_id_seq;
DROP TABLE IF EXISTS nodelocks CASCADE;
CREATE TABLE nodelocks (
id integer DEFAULT nextval('nodelocks_id_seq'::text) NOT NULL,
nodeid integer NOT NULL
REFERENCES nodes (id) ON DELETE CASCADE ON UPDATE CASCADE,
days smallint DEFAULT 0 NOT NULL,
fromsec integer DEFAULT 0 NOT NULL,
tosec integer DEFAULT 0 NOT NULL,
PRIMARY KEY (id)
);
/* --------------------------------------------------------
Structure of table "macs"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS macs_id_seq;
CREATE SEQUENCE macs_id_seq;
DROP TABLE IF EXISTS macs CASCADE;
CREATE TABLE macs (
id integer DEFAULT nextval('macs_id_seq'::text) NOT NULL,
mac varchar(17) DEFAULT '' NOT NULL,
nodeid integer NOT NULL
REFERENCES nodes (id) ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (id),
CONSTRAINT macs_mac_key UNIQUE (mac, nodeid)
);
/* --------------------------------------------------------
Structure of table "nodegroups"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS nodegroups_id_seq;
CREATE SEQUENCE nodegroups_id_seq;
DROP TABLE IF EXISTS nodegroups CASCADE;
CREATE TABLE nodegroups (
id integer NOT NULL DEFAULT nextval('nodegroups_id_seq'::text),
name varchar(255) NOT NULL DEFAULT '',
prio integer NOT NULL DEFAULT 0,
description text NOT NULL DEFAULT '',
PRIMARY KEY (id),
UNIQUE (name)
);
/* --------------------------------------------------------
Structure of table "nodegroupassignments"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS nodegroupassignments_id_seq;
CREATE SEQUENCE nodegroupassignments_id_seq;
DROP TABLE IF EXISTS nodegroupassignments CASCADE;
CREATE TABLE nodegroupassignments (
id integer NOT NULL DEFAULT nextval('nodegroupassignments_id_seq'::text),
nodegroupid integer NOT NULL DEFAULT 0,
nodeid integer NOT NULL DEFAULT 0,
PRIMARY KEY (id),
CONSTRAINT nodegroupassignments_nodeid_key UNIQUE (nodeid, nodegroupid)
);
/* --------------------------------------------------------
Structure of table "nodeassignments"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS nodeassignments_id_seq;
CREATE SEQUENCE nodeassignments_id_seq;
DROP TABLE IF EXISTS nodeassignments CASCADE;
CREATE TABLE nodeassignments (
id integer DEFAULT nextval('nodeassignments_id_seq'::text) NOT NULL,
nodeid integer NOT NULL
REFERENCES nodes (id) ON DELETE CASCADE ON UPDATE CASCADE,
assignmentid integer NOT NULL
REFERENCES assignments (id) ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (id),
CONSTRAINT nodeassignments_nodeid_key UNIQUE (nodeid, assignmentid)
);
CREATE INDEX nodeassignments_assignmentid_idx ON nodeassignments (assignmentid);
/* --------------------------------------------------------
Structure of table "tariffs"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS tariffs_id_seq;
CREATE SEQUENCE tariffs_id_seq;
DROP TABLE IF EXISTS tariffs CASCADE;
CREATE TABLE tariffs (
id integer DEFAULT nextval('tariffs_id_seq'::text) NOT NULL,
name varchar(255) DEFAULT '' NOT NULL,
type smallint DEFAULT 1 NOT NULL,
value numeric(9,2) DEFAULT 0 NOT NULL,
period smallint DEFAULT NULL,
taxid integer DEFAULT 0 NOT NULL,
numberplanid integer DEFAULT NULL
REFERENCES numberplans (id) ON DELETE CASCADE ON UPDATE CASCADE,
prodid varchar(255) DEFAULT '' NOT NULL,
uprate integer DEFAULT 0 NOT NULL,
upceil integer DEFAULT 0 NOT NULL,
downrate integer DEFAULT 0 NOT NULL,
downceil integer DEFAULT 0 NOT NULL,
climit integer DEFAULT 0 NOT NULL,
plimit integer DEFAULT 0 NOT NULL,
dlimit integer DEFAULT 0 NOT NULL,
uprate_n integer DEFAULT NULL,
upceil_n integer DEFAULT NULL,
downrate_n integer DEFAULT NULL,
downceil_n integer DEFAULT NULL,
climit_n integer DEFAULT NULL,
plimit_n integer DEFAULT NULL,
domain_limit integer DEFAULT NULL,
alias_limit integer DEFAULT NULL,
sh_limit integer DEFAULT NULL,
www_limit integer DEFAULT NULL,
mail_limit integer DEFAULT NULL,
ftp_limit integer DEFAULT NULL,
sql_limit integer DEFAULT NULL,
quota_sh_limit integer DEFAULT NULL,
quota_www_limit integer DEFAULT NULL,
quota_mail_limit integer DEFAULT NULL,
quota_ftp_limit integer DEFAULT NULL,
quota_sql_limit integer DEFAULT NULL,
description text DEFAULT '' NOT NULL,
disabled smallint DEFAULT 0 NOT NULL,
PRIMARY KEY (id),
CONSTRAINT tariffs_name_key UNIQUE (name, value, period)
);
CREATE INDEX tariffs_type_idx ON tariffs (type);
/* --------------------------------------------------------
Structure of table "promotions"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS promotions_id_seq;
CREATE SEQUENCE promotions_id_seq;
DROP TABLE IF EXISTS promotions CASCADE;
CREATE TABLE promotions (
id integer DEFAULT nextval('promotions_id_seq'::text) NOT NULL,
name varchar(255) NOT NULL,
description text DEFAULT NULL,
disabled smallint DEFAULT 0 NOT NULL,
PRIMARY KEY (id),
UNIQUE (name)
);
/* --------------------------------------------------------
Structure of table "promotionschemas"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS promotionschemas_id_seq;
CREATE SEQUENCE promotionschemas_id_seq;
DROP TABLE IF EXISTS promotionschemas CASCADE;
CREATE TABLE promotionschemas (
id integer DEFAULT nextval('promotionschemas_id_seq'::text) NOT NULL,
name varchar(255) NOT NULL,
description text DEFAULT NULL,
data text DEFAULT NULL,
promotionid integer DEFAULT NULL
REFERENCES promotions (id) ON DELETE CASCADE ON UPDATE CASCADE,
disabled smallint DEFAULT 0 NOT NULL,
continuation smallint DEFAULT NULL,
ctariffid integer DEFAULT NULL
REFERENCES tariffs (id) ON DELETE RESTRICT ON UPDATE CASCADE,
PRIMARY KEY (id),
CONSTRAINT promotionschemas_promotionid_key UNIQUE (promotionid, name)
);
CREATE INDEX promotionschemas_ctariffid_idx ON promotionschemas (ctariffid);
/* --------------------------------------------------------
Structure of table "promotionassignments"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS promotionassignments_id_seq;
CREATE SEQUENCE promotionassignments_id_seq;
DROP TABLE IF EXISTS promotionassignments CASCADE;
CREATE TABLE promotionassignments (
id integer DEFAULT nextval('promotionassignments_id_seq'::text) NOT NULL,
promotionschemaid integer DEFAULT NULL
REFERENCES promotionschemas (id) ON DELETE CASCADE ON UPDATE CASCADE,
tariffid integer DEFAULT NULL
REFERENCES tariffs (id) ON DELETE CASCADE ON UPDATE CASCADE,
data text DEFAULT NULL,
optional smallint DEFAULT 0 NOT NULL,
selectionid smallint DEFAULT 0 NOT NULL,
PRIMARY KEY (id),
CONSTRAINT promotionassignments_promotionschemaid_key UNIQUE (promotionschemaid, tariffid)
);
CREATE INDEX promotionassignments_tariffid_idx ON promotionassignments (tariffid);
/* --------------------------------------------------------
Structure of table "liabilities"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS liabilities_id_seq;
CREATE SEQUENCE liabilities_id_seq;
DROP TABLE IF EXISTS liabilities CASCADE;
CREATE TABLE liabilities (
id integer DEFAULT nextval('liabilities_id_seq'::text) NOT NULL,
value numeric(9,2) DEFAULT 0 NOT NULL,
name text DEFAULT '' NOT NULL,
taxid integer DEFAULT 0 NOT NULL,
prodid varchar(255) DEFAULT '' NOT NULL,
PRIMARY KEY (id)
);
/* ---------------------------------------------------------
Structure of table "payments"
--------------------------------------------------------- */
DROP SEQUENCE IF EXISTS payments_id_seq;
CREATE SEQUENCE payments_id_seq;
DROP TABLE IF EXISTS payments CASCADE;
CREATE TABLE payments (
id integer DEFAULT nextval('payments_id_seq'::text) NOT NULL,
name varchar(255) DEFAULT '' NOT NULL,
value numeric(9,2) DEFAULT 0 NOT NULL,
creditor varchar(255) DEFAULT '' NOT NULL,
period smallint DEFAULT 0 NOT NULL,
at smallint DEFAULT 0 NOT NULL,
description text DEFAULT '' NOT NULL,
PRIMARY KEY (id)
);
/* --------------------------------------------------------
Structure of table "taxes"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS taxes_id_seq;
CREATE SEQUENCE taxes_id_seq;
DROP TABLE IF EXISTS taxes CASCADE;
CREATE TABLE taxes (
id integer DEFAULT nextval('taxes_id_seq'::text) NOT NULL,
value numeric(4,2) DEFAULT 0 NOT NULL,
taxed smallint DEFAULT 0 NOT NULL,
label varchar(16) DEFAULT '' NOT NULL,
validfrom integer DEFAULT 0 NOT NULL,
validto integer DEFAULT 0 NOT NULL,
PRIMARY KEY (id)
);
/* --------------------------------------------------------
Structure of table "documents"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS documents_id_seq;
CREATE SEQUENCE documents_id_seq;
DROP TABLE IF EXISTS documents CASCADE;
CREATE TABLE documents (
id integer DEFAULT nextval('documents_id_seq'::text) NOT NULL,
type smallint DEFAULT 0 NOT NULL,
number integer DEFAULT 0 NOT NULL,
numberplanid integer DEFAULT 0 NOT NULL,
extnumber varchar(255) DEFAULT '' NOT NULL,
cdate integer DEFAULT 0 NOT NULL,
sdate integer DEFAULT 0 NOT NULL,
customerid integer DEFAULT 0 NOT NULL,
userid integer DEFAULT 0 NOT NULL,
divisionid integer DEFAULT 0 NOT NULL,
name varchar(255) DEFAULT '' NOT NULL,
address varchar(255) DEFAULT '' NOT NULL,
zip varchar(10) DEFAULT '' NOT NULL,
city varchar(32) DEFAULT '' NOT NULL,
countryid integer DEFAULT 0 NOT NULL,
ten varchar(16) DEFAULT '' NOT NULL,
ssn varchar(11) DEFAULT '' NOT NULL,
paytime smallint DEFAULT 0 NOT NULL,
paytype smallint DEFAULT NULL,
closed smallint DEFAULT 0 NOT NULL,
reference integer DEFAULT 0 NOT NULL,
reason varchar(255) DEFAULT '' NOT NULL,
div_name text DEFAULT '' NOT NULL,
div_shortname text DEFAULT '' NOT NULL,
div_address varchar(255) DEFAULT '' NOT NULL,
div_city varchar(255) DEFAULT '' NOT NULL,
div_zip varchar(255) DEFAULT '' NOT NULL,
div_countryid integer DEFAULT 0 NOT NULL,
div_ten varchar(255) DEFAULT '' NOT NULL,
div_regon varchar(255) DEFAULT '' NOT NULL,
div_account varchar(48) DEFAULT '' NOT NULL,
div_inv_header text DEFAULT '' NOT NULL,
div_inv_footer text DEFAULT '' NOT NULL,
div_inv_author text DEFAULT '' NOT NULL,
div_inv_cplace text DEFAULT '' NOT NULL,
fullnumber varchar(50) DEFAULT NULL,
cancelled smallint DEFAULT 0 NOT NULL,
PRIMARY KEY (id)
);
CREATE INDEX documents_cdate_idx ON documents(cdate);
CREATE INDEX documents_numberplanid_idx ON documents(numberplanid);
CREATE INDEX documents_customerid_idx ON documents(customerid);
CREATE INDEX documents_closed_idx ON documents(closed);
CREATE INDEX documents_reference_idx ON documents(reference);
/* --------------------------------------------------------
Structure of table "documentcontents"
-------------------------------------------------------- */
DROP TABLE IF EXISTS documentcontents CASCADE;
CREATE TABLE documentcontents (
docid integer DEFAULT 0 NOT NULL,
title text DEFAULT '' NOT NULL,
fromdate integer DEFAULT 0 NOT NULL,
todate integer 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,
UNIQUE (docid)
);
CREATE INDEX documentcontents_md5sum_idx ON documentcontents (md5sum);
CREATE INDEX documentcontents_todate_idx ON documentcontents (todate);
CREATE INDEX documentcontents_fromdate_idx ON documentcontents (fromdate);
/* --------------------------------------------------------
Structure of table "receiptcontents"
-------------------------------------------------------- */
DROP TABLE IF EXISTS receiptcontents CASCADE;
CREATE TABLE receiptcontents (
docid integer DEFAULT 0 NOT NULL,
itemid smallint DEFAULT 0 NOT NULL,
value numeric(9,2) DEFAULT 0 NOT NULL,
regid integer DEFAULT 0 NOT NULL,
description text DEFAULT '' NOT NULL
);
CREATE INDEX receiptcontents_docid_idx ON receiptcontents(docid);
CREATE INDEX receiptcontents_regid_idx ON receiptcontents(regid);
/* --------------------------------------------------------
Structure of table "invoicecontents"
-------------------------------------------------------- */
DROP TABLE IF EXISTS invoicecontents CASCADE;
CREATE TABLE invoicecontents (
docid integer DEFAULT 0 NOT NULL,
itemid smallint DEFAULT 0 NOT NULL,
value numeric(12,5) DEFAULT 0 NOT NULL,
taxid integer DEFAULT 0 NOT NULL,
prodid varchar(255) DEFAULT '' NOT NULL,
content varchar(16) DEFAULT '' NOT NULL,
count numeric(9,2) DEFAULT 0 NOT NULL,
description text DEFAULT '' NOT NULL,
tariffid integer DEFAULT 0 NOT NULL,
pdiscount numeric(4,2) DEFAULT 0 NOT NULL,
vdiscount numeric(9,2) DEFAULT 0 NOT NULL
);
CREATE INDEX invoicecontents_docid_idx ON invoicecontents (docid);
/* --------------------------------------------------------
Structure of table "debitnotecontents"
-------------------------------------------------------- */
DROP TABLE IF EXISTS debitnotecontents CASCADE;
DROP SEQUENCE IF EXISTS debitnotecontents_id_seq;
CREATE SEQUENCE debitnotecontents_id_seq;
CREATE TABLE debitnotecontents (
id integer DEFAULT nextval('debitnotecontents_id_seq'::text) NOT NULL,
docid integer DEFAULT 0 NOT NULL,
itemid smallint DEFAULT 0 NOT NULL,
value numeric(9,2) DEFAULT 0 NOT NULL,
description text DEFAULT '' NOT NULL,
PRIMARY KEY (id),
CONSTRAINT debitnotecontents_docid_key UNIQUE (docid, itemid)
);
/* --------------------------------------------------------
Structure of table "numberplanassignments"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS numberplanassignments_id_seq;
CREATE SEQUENCE numberplanassignments_id_seq;
DROP TABLE IF EXISTS numberplanassignments CASCADE;
CREATE TABLE numberplanassignments (
id integer DEFAULT nextval('numberplanassignments_id_seq'::text) NOT NULL,
planid integer DEFAULT 0 NOT NULL,
divisionid integer DEFAULT 0 NOT NULL,
PRIMARY KEY (id),
CONSTRAINT numberplanassignments_planid_key UNIQUE (planid, divisionid)
);
CREATE INDEX numberplanassignments_divisionid_idx ON numberplanassignments (divisionid);
/* --------------------------------------------------------
Structure of table "customergroups"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS customergroups_id_seq;
CREATE SEQUENCE customergroups_id_seq;
DROP TABLE IF EXISTS customergroups CASCADE;
CREATE TABLE customergroups (
id integer DEFAULT nextval('customergroups_id_seq'::text) NOT NULL,
name varchar(255) DEFAULT '' NOT NULL,
description text DEFAULT '' NOT NULL,
PRIMARY KEY (id),
UNIQUE (name)
);
/* --------------------------------------------------------
Structure of table "customerassignments"
-------------------------------------------------------- */
DROP SEQUENCE IF EXISTS customerassignments_id_seq;
CREATE SEQUENCE customerassignments_id_seq;
DROP TABLE IF EXISTS customerassignments CASCADE;
CREATE TABLE customerassignments (
id integer DEFAULT nextval('customerassignments_id_seq'::text) NOT NULL,
customergroupid integer NOT NULL
REFERENCES customergroups (id) ON DELETE CASCADE ON UPDATE CASCADE,
customerid integer NOT NULL
REFERENCES customers (id) ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (id),
CONSTRAINT customerassignments_customergroupid_key UNIQUE (customergroupid, customerid)
);
CREATE INDEX customerassignments_customerid_idx ON customerassignments (customerid);
/* --------------------------------------------------------
Structure of table "stats"
-------------------------------------------------------- */
DROP TABLE IF EXISTS stats CASCADE;
CREATE TABLE stats (
nodeid integer DEFAULT 0 NOT NULL,
dt integer DEFAULT 0 NOT NULL,
upload bigint DEFAULT 0,
download bigint DEFAULT 0,
nodesessionid integer DEFAULT 0 NOT NULL,
PRIMARY KEY (nodeid, dt)
);
CREATE INDEX stats_dt_idx ON stats(dt);
CREATE INDEX stats_nodesessionid_idx ON stats(nodesessionid);
/* --------------------------------------------------------
Structure of table "nodesessions"
-------------------------------------------------------- */
CREATE SEQUENCE nodesessions_id_seq;
CREATE TABLE nodesessions (