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
|
From 215a55e097c07b497747caf2a04c65cb11d783c6 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Thu, 26 May 2011 07:07:19 +0000
Subject: [PATCH] utils: add sqlite support to kamctl/kamdbctl
I basically copied the postgrersql scripts and simplified them a bit
---
utils/kamctl/kamctl | 6 +
utils/kamctl/kamctl.sqlite | 51 +++++++++
utils/kamctl/kamctlrc | 6 +-
utils/kamctl/kamdbctl | 13 ++
utils/kamctl/kamdbctl.sqlite | 152 ++++++++++++++++++++++++++
utils/kamctl/sqlite/acc-create.sql | 28 +++++
utils/kamctl/sqlite/alias_db-create.sql | 12 ++
utils/kamctl/sqlite/auth_db-create.sql | 15 +++
utils/kamctl/sqlite/avpops-create.sql | 15 +++
utils/kamctl/sqlite/carrierroute-create.sql | 42 +++++++
utils/kamctl/sqlite/cpl-create.sql | 10 ++
utils/kamctl/sqlite/dialog-create.sql | 29 +++++
utils/kamctl/sqlite/dialplan-create.sql | 13 ++
utils/kamctl/sqlite/dispatcher-create.sql | 11 ++
utils/kamctl/sqlite/domain-create.sql | 8 ++
utils/kamctl/sqlite/domainpolicy-create.sql | 13 ++
utils/kamctl/sqlite/drouting-create.sql | 39 +++++++
utils/kamctl/sqlite/group-create.sql | 19 +++
utils/kamctl/sqlite/htable-create.sql | 9 ++
utils/kamctl/sqlite/imc-create.sql | 19 +++
utils/kamctl/sqlite/lcr-create.sql | 43 +++++++
utils/kamctl/sqlite/matrix-create.sql | 9 ++
utils/kamctl/sqlite/msilo-create.sql | 16 +++
utils/kamctl/sqlite/mtree-create.sql | 8 ++
utils/kamctl/sqlite/pdt-create.sql | 9 ++
utils/kamctl/sqlite/permissions-create.sql | 21 ++++
utils/kamctl/sqlite/presence-create.sql | 92 ++++++++++++++++
utils/kamctl/sqlite/purple-create.sql | 9 ++
utils/kamctl/sqlite/registrar-create.sql | 22 ++++
utils/kamctl/sqlite/rls-create.sql | 42 +++++++
utils/kamctl/sqlite/siptrace-create.sql | 20 ++++
utils/kamctl/sqlite/speeddial-create.sql | 14 +++
utils/kamctl/sqlite/standard-create.sql | 5 +
utils/kamctl/sqlite/uac-create.sql | 16 +++
utils/kamctl/sqlite/uri_db-create.sql | 10 ++
utils/kamctl/sqlite/userblacklist-create.sql | 21 ++++
utils/kamctl/sqlite/usrloc-create.sql | 22 ++++
37 files changed, 887 insertions(+), 2 deletions(-)
create mode 100644 utils/kamctl/kamctl.sqlite
create mode 100644 utils/kamctl/kamdbctl.sqlite
create mode 100644 utils/kamctl/sqlite/acc-create.sql
create mode 100644 utils/kamctl/sqlite/alias_db-create.sql
create mode 100644 utils/kamctl/sqlite/auth_db-create.sql
create mode 100644 utils/kamctl/sqlite/avpops-create.sql
create mode 100644 utils/kamctl/sqlite/carrierroute-create.sql
create mode 100644 utils/kamctl/sqlite/cpl-create.sql
create mode 100644 utils/kamctl/sqlite/dialog-create.sql
create mode 100644 utils/kamctl/sqlite/dialplan-create.sql
create mode 100644 utils/kamctl/sqlite/dispatcher-create.sql
create mode 100644 utils/kamctl/sqlite/domain-create.sql
create mode 100644 utils/kamctl/sqlite/domainpolicy-create.sql
create mode 100644 utils/kamctl/sqlite/drouting-create.sql
create mode 100644 utils/kamctl/sqlite/group-create.sql
create mode 100644 utils/kamctl/sqlite/htable-create.sql
create mode 100644 utils/kamctl/sqlite/imc-create.sql
create mode 100644 utils/kamctl/sqlite/lcr-create.sql
create mode 100644 utils/kamctl/sqlite/matrix-create.sql
create mode 100644 utils/kamctl/sqlite/msilo-create.sql
create mode 100644 utils/kamctl/sqlite/mtree-create.sql
create mode 100644 utils/kamctl/sqlite/pdt-create.sql
create mode 100644 utils/kamctl/sqlite/permissions-create.sql
create mode 100644 utils/kamctl/sqlite/presence-create.sql
create mode 100644 utils/kamctl/sqlite/purple-create.sql
create mode 100644 utils/kamctl/sqlite/registrar-create.sql
create mode 100644 utils/kamctl/sqlite/rls-create.sql
create mode 100644 utils/kamctl/sqlite/siptrace-create.sql
create mode 100644 utils/kamctl/sqlite/speeddial-create.sql
create mode 100644 utils/kamctl/sqlite/standard-create.sql
create mode 100644 utils/kamctl/sqlite/uac-create.sql
create mode 100644 utils/kamctl/sqlite/uri_db-create.sql
create mode 100644 utils/kamctl/sqlite/userblacklist-create.sql
create mode 100644 utils/kamctl/sqlite/usrloc-create.sql
diff --git a/utils/kamctl/kamctl b/utils/kamctl/kamctl
index 2ec550a..c548849 100755
--- a/utils/kamctl/kamctl
+++ b/utils/kamctl/kamctl
@@ -124,6 +124,12 @@ case $DBENGINE in
DBENGINELOADED=1
fi
;;
+ SQLITE|sqlite)
+ if [ -f "$MYLIBDIR/kamctl.sqlite" ]; then
+ . "$MYLIBDIR/kamctl.sqlite"
+ DBENGINELOADED=1
+ fi
+ ;;
esac
diff --git a/utils/kamctl/kamctl.sqlite b/utils/kamctl/kamctl.sqlite
new file mode 100644
index 0000000..8c3eb21
--- /dev/null
+++ b/utils/kamctl/kamctl.sqlite
@@ -0,0 +1,51 @@
+#
+# $Id$
+#
+# control tool for maintaining Kamailio
+#
+#===================================================================
+
+##### ----------------------------------------------- #####
+### SQLITE specific variables and functions
+#
+
+##### ----------------------------------------------- #####
+### load SQL base
+#
+if [ -f "$MYLIBDIR/kamctl.sqlbase" ]; then
+ . "$MYLIBDIR/kamctl.sqlbase"
+else
+ echo "Cannot load SQL core functions '$MYLIBDIR/kamctl.sqlbase' - exiting ..."
+ exit -1
+fi
+
+DBNAME=$DB_PATH
+
+##### ----------------------------------------------- #####
+### binaries
+if [ -z "$SQLITE" ] ; then
+ locate_tool sqlite3
+ if [ -z "$TOOLPATH" ] ; then
+ echo "error: 'sqlite3' tool not found: set SQLITE variable to correct tool path"
+ exit
+ fi
+ SQLITE="$TOOLPATH"
+fi
+
+
+# input: sql query, optional sqlite3 command-line params
+sqlite_query() {
+ # if password not yet queried, query it now
+ mecho "sqlite_query: $SQLITE $2 $DBNAME $1"
+ $SQLITE $2 $DBNAME "$1"
+}
+
+# input: sql query, optional sqlite3 command-line params
+sqlite_ro_query() {
+ sqlite_query "$@"
+}
+
+DBCMD=sqlite_query
+DBROCMD=sqlite_ro_query
+DBRAWPARAMS=
+
diff --git a/utils/kamctl/kamctlrc b/utils/kamctl/kamctlrc
index 5e888bd..ceb6f54 100644
--- a/utils/kamctl/kamctlrc
+++ b/utils/kamctl/kamctlrc
@@ -12,7 +12,9 @@
## chrooted directory
# $CHROOT_DIR="/path/to/chrooted/directory"
-## database type: MYSQL, PGSQL, ORACLE, DB_BERKELEY, or DBTEXT, by default none is loaded
+## database type: MYSQL, PGSQL, ORACLE, DB_BERKELEY, DBTEXT, or SQLITE
+# by default none is loaded
+#
# If you want to setup a database with kamdbctl, you must at least specify
# this parameter.
# DBENGINE=MYSQL
@@ -23,7 +25,7 @@
## database name (for ORACLE this is TNS name)
# DBNAME=openser
-# database path used by dbtext or db_berkeley
+# database path used by dbtext, db_berkeley or sqlite
# DB_PATH="/usr/local/etc/kamailio/dbtext"
## database read/write user
diff --git a/utils/kamctl/kamdbctl b/utils/kamctl/kamdbctl
index c04bebd..d60f10f 100755
--- a/utils/kamctl/kamdbctl
+++ b/utils/kamctl/kamdbctl
@@ -108,6 +108,15 @@ case $DBENGINE in
merr "could not load the script in $MYLIBDIR/kamdbctl.db_berkeley for database engine $DBENGINE"
fi
;;
+ SQLITE|sqlite)
+ if [ -f "$MYLIBDIR/kamdbctl.sqlite" ]; then
+ . "$MYLIBDIR/kamdbctl.sqlite"
+ USED_DBENGINE="sqlite"
+ DBNAME=$DB_PATH
+ else
+ merr "could not load the script in $MYLIBDIR/kamdbctl.sqlite for database engine $DBENGINE"
+ fi
+ ;;
esac
if [ -z "$USED_DBENGINE" ] ; then
@@ -194,6 +203,10 @@ case $1 in
usage
exit 1
fi
+ if [ "$USED_DBENGINE" = "sqlite" ]; then
+ cp $DB_PATH $1
+ exit $?
+ fi
tmp_file=`mktemp /tmp/kamdbctl.XXXXXXXXXX` || exit 1
openser_dump $DBNAME $tmp_file
ret=$?
diff --git a/utils/kamctl/kamdbctl.sqlite b/utils/kamctl/kamdbctl.sqlite
new file mode 100644
index 0000000..ecb51aa
--- /dev/null
+++ b/utils/kamctl/kamdbctl.sqlite
@@ -0,0 +1,152 @@
+# $Id$
+#
+# Script for adding and dropping Kamailio sqlite tables
+#
+
+# path to the database schemas
+DATA_DIR="/usr/local/share/kamailio"
+if [ -d "$DATA_DIR/sqlite" ] ; then
+ DB_SCHEMA="$DATA_DIR/sqlite"
+else
+ DB_SCHEMA="./sqlite"
+fi
+
+#################################################################
+# config vars
+#################################################################
+
+CMD="sqlite3"
+DUMP_CMD="sql_dump"
+#################################################################
+
+sql_dump()
+{
+ $CMD ${1:-$DB_PATH} .dump
+}
+
+# execute sql command with optional db name
+sql_query()
+{
+ $CMD "$@"
+}
+
+
+openser_drop() # pars: <database name>
+{
+if [ $# -ne 1 ] ; then
+ merr "openser_drop function takes one param"
+ exit 1
+fi
+
+if ! rm $1; then
+ merr "Dropping database $1 failed!"
+ exit 1
+fi
+
+minfo "Database $1 dropped"
+} #openser_drop
+
+
+openser_create () # pars: <database name>
+{
+if [ $# -ne 1 ] ; then
+ merr "openser_create function takes one param"
+ exit 1
+fi
+
+minfo "creating database $1 ..."
+
+if [ $? -ne 0 ] ; then
+ merr "Creating database failed!"
+ exit 1
+fi
+
+#sql_query "$1" "CREATE FUNCTION "concat" (text,text) RETURNS text AS 'SELECT \$1 || \$2;' LANGUAGE 'sql';
+# CREATE FUNCTION "rand" () RETURNS double precision AS 'SELECT random();' LANGUAGE 'sql';"
+# emulate mysql proprietary functions used by the lcr module in postgresql
+
+#if [ $? -ne 0 ] ; then
+# merr "Creating mysql emulation functions failed!"
+# exit 1
+#fi
+
+for TABLE in $STANDARD_MODULES; do
+ mdbg "Creating core table: $TABLE"
+ sql_query "$1" < $DB_SCHEMA/$TABLE-create.sql
+ if [ $? -ne 0 ] ; then
+ merr "Creating core tables failed!"
+ exit 1
+ fi
+done
+
+if [ -e $DB_SCHEMA/extensions-create.sql ]
+then
+ minfo "Creating custom extensions tables"
+ sql_query $1 < $DB_SCHEMA/extensions-create.sql
+ if [ $? -ne 0 ] ; then
+ merr "Creating custom extensions tables failed!"
+ exit 1
+ fi
+fi
+
+minfo "Core Kamailio tables succesfully created."
+
+get_answer $INSTALL_PRESENCE_TABLES "Install presence related tables? (y/n): "
+if [ "$ANSWER" = "y" ]; then
+ presence_create $1
+fi
+
+get_answer $INSTALL_EXTRA_TABLES "Install tables for $EXTRA_MODULES? (y/n): "
+if [ "$ANSWER" = "y" ]; then
+ extra_create $1
+fi
+} # openser_create
+
+
+presence_create () # pars: <database name>
+{
+if [ $# -ne 1 ] ; then
+ merr "presence_create function takes one param"
+ exit 1
+fi
+
+minfo "creating presence tables into $1 ..."
+
+sql_query "$1" < $DB_SCHEMA/presence-create.sql
+
+if [ $? -ne 0 ] ; then
+ merr "Failed to create presence tables!"
+ exit 1
+fi
+
+sql_query "$1" < $DB_SCHEMA/rls-create.sql
+
+if [ $? -ne 0 ] ; then
+ merr "Failed to create rls-presence tables!"
+ exit 1
+fi
+
+minfo "Presence tables succesfully created."
+} # end presence_create
+
+
+extra_create () # pars: <database name>
+{
+if [ $# -ne 1 ] ; then
+ merr "extra_create function takes one param"
+ exit 1
+fi
+
+minfo "creating extra tables into $1 ..."
+
+for TABLE in $EXTRA_MODULES; do
+ mdbg "Creating extra table: $TABLE"
+ sql_query "$1" < $DB_SCHEMA/$TABLE-create.sql
+ if [ $? -ne 0 ] ; then
+ merr "Creating extra tables failed!"
+ exit 1
+ fi
+done
+
+minfo "Extra tables succesfully created."
+} # end extra_create
diff --git a/utils/kamctl/sqlite/acc-create.sql b/utils/kamctl/sqlite/acc-create.sql
new file mode 100644
index 0000000..4d23363
--- /dev/null
+++ b/utils/kamctl/sqlite/acc-create.sql
@@ -0,0 +1,28 @@
+INSERT INTO version (table_name, table_version) values ('acc','4');
+CREATE TABLE acc (
+ id INTEGER PRIMARY KEY NOT NULL,
+ method VARCHAR(16) DEFAULT '' NOT NULL,
+ from_tag VARCHAR(64) DEFAULT '' NOT NULL,
+ to_tag VARCHAR(64) DEFAULT '' NOT NULL,
+ callid VARCHAR(64) DEFAULT '' NOT NULL,
+ sip_code VARCHAR(3) DEFAULT '' NOT NULL,
+ sip_reason VARCHAR(32) DEFAULT '' NOT NULL,
+ time TIMESTAMP WITHOUT TIME ZONE NOT NULL
+);
+
+CREATE INDEX acc_callid_idx ON acc (callid);
+
+INSERT INTO version (table_name, table_version) values ('missed_calls','3');
+CREATE TABLE missed_calls (
+ id INTEGER PRIMARY KEY NOT NULL,
+ method VARCHAR(16) DEFAULT '' NOT NULL,
+ from_tag VARCHAR(64) DEFAULT '' NOT NULL,
+ to_tag VARCHAR(64) DEFAULT '' NOT NULL,
+ callid VARCHAR(64) DEFAULT '' NOT NULL,
+ sip_code VARCHAR(3) DEFAULT '' NOT NULL,
+ sip_reason VARCHAR(32) DEFAULT '' NOT NULL,
+ time TIMESTAMP WITHOUT TIME ZONE NOT NULL
+);
+
+CREATE INDEX missed_calls_callid_idx ON missed_calls (callid);
+
diff --git a/utils/kamctl/sqlite/alias_db-create.sql b/utils/kamctl/sqlite/alias_db-create.sql
new file mode 100644
index 0000000..90656e9
--- /dev/null
+++ b/utils/kamctl/sqlite/alias_db-create.sql
@@ -0,0 +1,12 @@
+INSERT INTO version (table_name, table_version) values ('dbaliases','1');
+CREATE TABLE dbaliases (
+ id INTEGER PRIMARY KEY NOT NULL,
+ alias_username VARCHAR(64) DEFAULT '' NOT NULL,
+ alias_domain VARCHAR(64) DEFAULT '' NOT NULL,
+ username VARCHAR(64) DEFAULT '' NOT NULL,
+ domain VARCHAR(64) DEFAULT '' NOT NULL,
+ CONSTRAINT dbaliases_alias_idx UNIQUE (alias_username, alias_domain)
+);
+
+CREATE INDEX dbaliases_target_idx ON dbaliases (username, domain);
+
diff --git a/utils/kamctl/sqlite/auth_db-create.sql b/utils/kamctl/sqlite/auth_db-create.sql
new file mode 100644
index 0000000..7d6d1f8
--- /dev/null
+++ b/utils/kamctl/sqlite/auth_db-create.sql
@@ -0,0 +1,15 @@
+INSERT INTO version (table_name, table_version) values ('subscriber','6');
+CREATE TABLE subscriber (
+ id INTEGER PRIMARY KEY NOT NULL,
+ username VARCHAR(64) DEFAULT '' NOT NULL,
+ domain VARCHAR(64) DEFAULT '' NOT NULL,
+ password VARCHAR(25) DEFAULT '' NOT NULL,
+ email_address VARCHAR(64) DEFAULT '' NOT NULL,
+ ha1 VARCHAR(64) DEFAULT '' NOT NULL,
+ ha1b VARCHAR(64) DEFAULT '' NOT NULL,
+ rpid VARCHAR(64) DEFAULT NULL,
+ CONSTRAINT subscriber_account_idx UNIQUE (username, domain)
+);
+
+CREATE INDEX subscriber_username_idx ON subscriber (username);
+
diff --git a/utils/kamctl/sqlite/avpops-create.sql b/utils/kamctl/sqlite/avpops-create.sql
new file mode 100644
index 0000000..007ecb5
--- /dev/null
+++ b/utils/kamctl/sqlite/avpops-create.sql
@@ -0,0 +1,15 @@
+INSERT INTO version (table_name, table_version) values ('usr_preferences','2');
+CREATE TABLE usr_preferences (
+ id INTEGER PRIMARY KEY NOT NULL,
+ uuid VARCHAR(64) DEFAULT '' NOT NULL,
+ username VARCHAR(128) DEFAULT 0 NOT NULL,
+ domain VARCHAR(64) DEFAULT '' NOT NULL,
+ attribute VARCHAR(32) DEFAULT '' NOT NULL,
+ type INTEGER DEFAULT 0 NOT NULL,
+ value VARCHAR(128) DEFAULT '' NOT NULL,
+ last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL
+);
+
+CREATE INDEX usr_preferences_ua_idx ON usr_preferences (uuid, attribute);
+CREATE INDEX usr_preferences_uda_idx ON usr_preferences (username, domain, attribute);
+
diff --git a/utils/kamctl/sqlite/carrierroute-create.sql b/utils/kamctl/sqlite/carrierroute-create.sql
new file mode 100644
index 0000000..baafbee
--- /dev/null
+++ b/utils/kamctl/sqlite/carrierroute-create.sql
@@ -0,0 +1,42 @@
+INSERT INTO version (table_name, table_version) values ('carrierroute','3');
+CREATE TABLE carrierroute (
+ id INTEGER PRIMARY KEY NOT NULL,
+ carrier INTEGER DEFAULT 0 NOT NULL,
+ domain INTEGER DEFAULT 0 NOT NULL,
+ scan_prefix VARCHAR(64) DEFAULT '' NOT NULL,
+ flags INTEGER DEFAULT 0 NOT NULL,
+ mask INTEGER DEFAULT 0 NOT NULL,
+ prob REAL DEFAULT 0 NOT NULL,
+ strip INTEGER DEFAULT 0 NOT NULL,
+ rewrite_host VARCHAR(128) DEFAULT '' NOT NULL,
+ rewrite_prefix VARCHAR(64) DEFAULT '' NOT NULL,
+ rewrite_suffix VARCHAR(64) DEFAULT '' NOT NULL,
+ description VARCHAR(255) DEFAULT NULL
+);
+
+INSERT INTO version (table_name, table_version) values ('carrierfailureroute','2');
+CREATE TABLE carrierfailureroute (
+ id INTEGER PRIMARY KEY NOT NULL,
+ carrier INTEGER DEFAULT 0 NOT NULL,
+ domain INTEGER DEFAULT 0 NOT NULL,
+ scan_prefix VARCHAR(64) DEFAULT '' NOT NULL,
+ host_name VARCHAR(128) DEFAULT '' NOT NULL,
+ reply_code VARCHAR(3) DEFAULT '' NOT NULL,
+ flags INTEGER DEFAULT 0 NOT NULL,
+ mask INTEGER DEFAULT 0 NOT NULL,
+ next_domain INTEGER DEFAULT 0 NOT NULL,
+ description VARCHAR(255) DEFAULT NULL
+);
+
+INSERT INTO version (table_name, table_version) values ('carrier_name','1');
+CREATE TABLE carrier_name (
+ id INTEGER PRIMARY KEY NOT NULL,
+ carrier VARCHAR(64) DEFAULT NULL
+);
+
+INSERT INTO version (table_name, table_version) values ('domain_name','1');
+CREATE TABLE domain_name (
+ id INTEGER PRIMARY KEY NOT NULL,
+ domain VARCHAR(64) DEFAULT NULL
+);
+
diff --git a/utils/kamctl/sqlite/cpl-create.sql b/utils/kamctl/sqlite/cpl-create.sql
new file mode 100644
index 0000000..8beedf5
--- /dev/null
+++ b/utils/kamctl/sqlite/cpl-create.sql
@@ -0,0 +1,10 @@
+INSERT INTO version (table_name, table_version) values ('cpl','1');
+CREATE TABLE cpl (
+ id INTEGER PRIMARY KEY NOT NULL,
+ username VARCHAR(64) NOT NULL,
+ domain VARCHAR(64) DEFAULT '' NOT NULL,
+ cpl_xml TEXT,
+ cpl_bin TEXT,
+ CONSTRAINT cpl_account_idx UNIQUE (username, domain)
+);
+
diff --git a/utils/kamctl/sqlite/dialog-create.sql b/utils/kamctl/sqlite/dialog-create.sql
new file mode 100644
index 0000000..bb086a5
--- /dev/null
+++ b/utils/kamctl/sqlite/dialog-create.sql
@@ -0,0 +1,29 @@
+INSERT INTO version (table_name, table_version) values ('dialog','5');
+CREATE TABLE dialog (
+ id INTEGER PRIMARY KEY NOT NULL,
+ hash_entry INTEGER NOT NULL,
+ hash_id INTEGER NOT NULL,
+ callid VARCHAR(255) NOT NULL,
+ from_uri VARCHAR(128) NOT NULL,
+ from_tag VARCHAR(64) NOT NULL,
+ to_uri VARCHAR(128) NOT NULL,
+ to_tag VARCHAR(64) NOT NULL,
+ caller_cseq VARCHAR(7) NOT NULL,
+ callee_cseq VARCHAR(7) NOT NULL,
+ caller_route_set VARCHAR(512),
+ callee_route_set VARCHAR(512),
+ caller_contact VARCHAR(128) NOT NULL,
+ callee_contact VARCHAR(128) NOT NULL,
+ caller_sock VARCHAR(64) NOT NULL,
+ callee_sock VARCHAR(64) NOT NULL,
+ state INTEGER NOT NULL,
+ start_time INTEGER NOT NULL,
+ timeout INTEGER DEFAULT 0 NOT NULL,
+ sflags INTEGER DEFAULT 0 NOT NULL,
+ toroute INTEGER DEFAULT 0 NOT NULL,
+ toroute_name VARCHAR(32),
+ req_uri VARCHAR(128) NOT NULL
+);
+
+CREATE INDEX dialog_hash_idx ON dialog (hash_entry, hash_id);
+
diff --git a/utils/kamctl/sqlite/dialplan-create.sql b/utils/kamctl/sqlite/dialplan-create.sql
new file mode 100644
index 0000000..1a85e50
--- /dev/null
+++ b/utils/kamctl/sqlite/dialplan-create.sql
@@ -0,0 +1,13 @@
+INSERT INTO version (table_name, table_version) values ('dialplan','1');
+CREATE TABLE dialplan (
+ id INTEGER PRIMARY KEY NOT NULL,
+ dpid INTEGER NOT NULL,
+ pr INTEGER NOT NULL,
+ match_op INTEGER NOT NULL,
+ match_exp VARCHAR(64) NOT NULL,
+ match_len INTEGER NOT NULL,
+ subst_exp VARCHAR(64) NOT NULL,
+ repl_exp VARCHAR(32) NOT NULL,
+ attrs VARCHAR(32) NOT NULL
+);
+
diff --git a/utils/kamctl/sqlite/dispatcher-create.sql b/utils/kamctl/sqlite/dispatcher-create.sql
new file mode 100644
index 0000000..ec37fc4
--- /dev/null
+++ b/utils/kamctl/sqlite/dispatcher-create.sql
@@ -0,0 +1,11 @@
+INSERT INTO version (table_name, table_version) values ('dispatcher','4');
+CREATE TABLE dispatcher (
+ id INTEGER PRIMARY KEY NOT NULL,
+ setid INTEGER DEFAULT 0 NOT NULL,
+ destination VARCHAR(192) DEFAULT '' NOT NULL,
+ flags INTEGER DEFAULT 0 NOT NULL,
+ priority INTEGER DEFAULT 0 NOT NULL,
+ attrs VARCHAR(128) DEFAULT '' NOT NULL,
+ description VARCHAR(64) DEFAULT '' NOT NULL
+);
+
diff --git a/utils/kamctl/sqlite/domain-create.sql b/utils/kamctl/sqlite/domain-create.sql
new file mode 100644
index 0000000..0b1fbe4
--- /dev/null
+++ b/utils/kamctl/sqlite/domain-create.sql
@@ -0,0 +1,8 @@
+INSERT INTO version (table_name, table_version) values ('domain','1');
+CREATE TABLE domain (
+ id INTEGER PRIMARY KEY NOT NULL,
+ domain VARCHAR(64) DEFAULT '' NOT NULL,
+ last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
+ CONSTRAINT domain_domain_idx UNIQUE (domain)
+);
+
diff --git a/utils/kamctl/sqlite/domainpolicy-create.sql b/utils/kamctl/sqlite/domainpolicy-create.sql
new file mode 100644
index 0000000..c7cb279
--- /dev/null
+++ b/utils/kamctl/sqlite/domainpolicy-create.sql
@@ -0,0 +1,13 @@
+INSERT INTO version (table_name, table_version) values ('domainpolicy','2');
+CREATE TABLE domainpolicy (
+ id INTEGER PRIMARY KEY NOT NULL,
+ rule VARCHAR(255) NOT NULL,
+ type VARCHAR(255) NOT NULL,
+ att VARCHAR(255),
+ val VARCHAR(128),
+ description VARCHAR(255) NOT NULL,
+ CONSTRAINT domainpolicy_rav_idx UNIQUE (rule, att, val)
+);
+
+CREATE INDEX domainpolicy_rule_idx ON domainpolicy (rule);
+
diff --git a/utils/kamctl/sqlite/drouting-create.sql b/utils/kamctl/sqlite/drouting-create.sql
new file mode 100644
index 0000000..9c962fa
--- /dev/null
+++ b/utils/kamctl/sqlite/drouting-create.sql
@@ -0,0 +1,39 @@
+INSERT INTO version (table_name, table_version) values ('dr_gateways','3');
+CREATE TABLE dr_gateways (
+ gwid INTEGER PRIMARY KEY NOT NULL,
+ type INTEGER DEFAULT 0 NOT NULL,
+ address VARCHAR(128) NOT NULL,
+ strip INTEGER DEFAULT 0 NOT NULL,
+ pri_prefix VARCHAR(64) DEFAULT NULL,
+ attrs VARCHAR(255) DEFAULT NULL,
+ description VARCHAR(128) DEFAULT '' NOT NULL
+);
+
+INSERT INTO version (table_name, table_version) values ('dr_rules','3');
+CREATE TABLE dr_rules (
+ ruleid INTEGER PRIMARY KEY NOT NULL,
+ groupid VARCHAR(255) NOT NULL,
+ prefix VARCHAR(64) NOT NULL,
+ timerec VARCHAR(255) NOT NULL,
+ priority INTEGER DEFAULT 0 NOT NULL,
+ routeid VARCHAR(64) NOT NULL,
+ gwlist VARCHAR(255) NOT NULL,
+ description VARCHAR(128) DEFAULT '' NOT NULL
+);
+
+INSERT INTO version (table_name, table_version) values ('dr_gw_lists','1');
+CREATE TABLE dr_gw_lists (
+ id INTEGER PRIMARY KEY NOT NULL,
+ gwlist VARCHAR(255) NOT NULL,
+ description VARCHAR(128) DEFAULT '' NOT NULL
+);
+
+INSERT INTO version (table_name, table_version) values ('dr_groups','2');
+CREATE TABLE dr_groups (
+ id INTEGER PRIMARY KEY NOT NULL,
+ username VARCHAR(64) NOT NULL,
+ domain VARCHAR(128) DEFAULT '' NOT NULL,
+ groupid INTEGER DEFAULT 0 NOT NULL,
+ description VARCHAR(128) DEFAULT '' NOT NULL
+);
+
diff --git a/utils/kamctl/sqlite/group-create.sql b/utils/kamctl/sqlite/group-create.sql
new file mode 100644
index 0000000..fbd91c5
--- /dev/null
+++ b/utils/kamctl/sqlite/group-create.sql
@@ -0,0 +1,19 @@
+INSERT INTO version (table_name, table_version) values ('grp','2');
+CREATE TABLE grp (
+ id INTEGER PRIMARY KEY NOT NULL,
+ username VARCHAR(64) DEFAULT '' NOT NULL,
+ domain VARCHAR(64) DEFAULT '' NOT NULL,
+ grp VARCHAR(64) DEFAULT '' NOT NULL,
+ last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
+ CONSTRAINT grp_account_group_idx UNIQUE (username, domain, grp)
+);
+
+INSERT INTO version (table_name, table_version) values ('re_grp','1');
+CREATE TABLE re_grp (
+ id INTEGER PRIMARY KEY NOT NULL,
+ reg_exp VARCHAR(128) DEFAULT '' NOT NULL,
+ group_id INTEGER DEFAULT 0 NOT NULL
+);
+
+CREATE INDEX re_grp_group_idx ON re_grp (group_id);
+
diff --git a/utils/kamctl/sqlite/htable-create.sql b/utils/kamctl/sqlite/htable-create.sql
new file mode 100644
index 0000000..59fa681
--- /dev/null
+++ b/utils/kamctl/sqlite/htable-create.sql
@@ -0,0 +1,9 @@
+INSERT INTO version (table_name, table_version) values ('htable','1');
+CREATE TABLE htable (
+ id INTEGER PRIMARY KEY NOT NULL,
+ key_name VARCHAR(64) DEFAULT '' NOT NULL,
+ key_type INTEGER DEFAULT 0 NOT NULL,
+ value_type INTEGER DEFAULT 0 NOT NULL,
+ key_value VARCHAR(128) DEFAULT '' NOT NULL
+);
+
diff --git a/utils/kamctl/sqlite/imc-create.sql b/utils/kamctl/sqlite/imc-create.sql
new file mode 100644
index 0000000..99d68c1
--- /dev/null
+++ b/utils/kamctl/sqlite/imc-create.sql
@@ -0,0 +1,19 @@
+INSERT INTO version (table_name, table_version) values ('imc_rooms','1');
+CREATE TABLE imc_rooms (
+ id INTEGER PRIMARY KEY NOT NULL,
+ name VARCHAR(64) NOT NULL,
+ domain VARCHAR(64) NOT NULL,
+ flag INTEGER NOT NULL,
+ CONSTRAINT imc_rooms_name_domain_idx UNIQUE (name, domain)
+);
+
+INSERT INTO version (table_name, table_version) values ('imc_members','1');
+CREATE TABLE imc_members (
+ id INTEGER PRIMARY KEY NOT NULL,
+ username VARCHAR(64) NOT NULL,
+ domain VARCHAR(64) NOT NULL,
+ room VARCHAR(64) NOT NULL,
+ flag INTEGER NOT NULL,
+ CONSTRAINT imc_members_account_room_idx UNIQUE (username, domain, room)
+);
+
diff --git a/utils/kamctl/sqlite/lcr-create.sql b/utils/kamctl/sqlite/lcr-create.sql
new file mode 100644
index 0000000..bf93141
--- /dev/null
+++ b/utils/kamctl/sqlite/lcr-create.sql
@@ -0,0 +1,43 @@
+INSERT INTO version (table_name, table_version) values ('lcr_gw','2');
+CREATE TABLE lcr_gw (
+ id INTEGER PRIMARY KEY NOT NULL,
+ lcr_id SMALLINT NOT NULL,
+ gw_name VARCHAR(128),
+ ip_addr VARCHAR(15),
+ hostname VARCHAR(64),
+ port SMALLINT,
+ params VARCHAR(64),
+ uri_scheme SMALLINT,
+ transport SMALLINT,
+ strip SMALLINT,
+ prefix VARCHAR(16) DEFAULT NULL,
+ tag VARCHAR(64) DEFAULT NULL,
+ flags INTEGER DEFAULT 0 NOT NULL,
+ defunct INTEGER DEFAULT NULL,
+ CONSTRAINT lcr_gw_lcr_id_ip_addr_port_hostname_idx UNIQUE (lcr_id, ip_addr, port, hostname)
+);
+
+INSERT INTO version (table_name, table_version) values ('lcr_rule_target','1');
+CREATE TABLE lcr_rule_target (
+ id INTEGER PRIMARY KEY NOT NULL,
+ lcr_id SMALLINT NOT NULL,
+ rule_id INTEGER NOT NULL,
+ gw_id INTEGER NOT NULL,
+ priority SMALLINT NOT NULL,
+ weight INTEGER DEFAULT 1 NOT NULL,
+ CONSTRAINT lcr_rule_target_rule_id_gw_id_idx UNIQUE (rule_id, gw_id)
+);
+
+CREATE INDEX lcr_rule_target_lcr_id_idx ON lcr_rule_target (lcr_id);
+
+INSERT INTO version (table_name, table_version) values ('lcr_rule','1');
+CREATE TABLE lcr_rule (
+ id INTEGER PRIMARY KEY NOT NULL,
+ lcr_id SMALLINT NOT NULL,
+ prefix VARCHAR(16) DEFAULT NULL,
+ from_uri VARCHAR(64) DEFAULT NULL,
+ stopper INTEGER DEFAULT 0 NOT NULL,
+ enabled INTEGER DEFAULT 1 NOT NULL,
+ CONSTRAINT lcr_rule_lcr_id_prefix_from_uri_idx UNIQUE (lcr_id, prefix, from_uri)
+);
+
diff --git a/utils/kamctl/sqlite/matrix-create.sql b/utils/kamctl/sqlite/matrix-create.sql
new file mode 100644
index 0000000..50f2ed8
--- /dev/null
+++ b/utils/kamctl/sqlite/matrix-create.sql
@@ -0,0 +1,9 @@
+INSERT INTO version (table_name, table_version) values ('matrix','1');
+CREATE TABLE matrix (
+ first INTEGER NOT NULL,
+ second SMALLINT NOT NULL,
+ res INTEGER NOT NULL
+);
+
+CREATE INDEX matrix_matrix_idx ON matrix (first, second);
+
diff --git a/utils/kamctl/sqlite/msilo-create.sql b/utils/kamctl/sqlite/msilo-create.sql
new file mode 100644
index 0000000..7234112
--- /dev/null
+++ b/utils/kamctl/sqlite/msilo-create.sql
@@ -0,0 +1,16 @@
+INSERT INTO version (table_name, table_version) values ('silo','5');
+CREATE TABLE silo (
+ id INTEGER PRIMARY KEY NOT NULL,
+ src_addr VARCHAR(128) DEFAULT '' NOT NULL,
+ dst_addr VARCHAR(128) DEFAULT '' NOT NULL,
+ username VARCHAR(64) DEFAULT '' NOT NULL,
+ domain VARCHAR(64) DEFAULT '' NOT NULL,
+ inc_time INTEGER DEFAULT 0 NOT NULL,
+ exp_time INTEGER DEFAULT 0 NOT NULL,
+ snd_time INTEGER DEFAULT 0 NOT NULL,
+ ctype VARCHAR(32) DEFAULT 'text/plain' NOT NULL,
+ body BYTEA DEFAULT '' NOT NULL
+);
+
+CREATE INDEX silo_account_idx ON silo (username, domain);
+
diff --git a/utils/kamctl/sqlite/mtree-create.sql b/utils/kamctl/sqlite/mtree-create.sql
new file mode 100644
index 0000000..9b6f56f
--- /dev/null
+++ b/utils/kamctl/sqlite/mtree-create.sql
@@ -0,0 +1,8 @@
+INSERT INTO version (table_name, table_version) values ('mtree','1');
+CREATE TABLE mtree (
+ id INTEGER PRIMARY KEY NOT NULL,
+ tprefix VARCHAR(32) DEFAULT '' NOT NULL,
+ tvalue VARCHAR(128) DEFAULT '' NOT NULL,
+ CONSTRAINT mtree_tprefix_idx UNIQUE (tprefix)
+);
+
diff --git a/utils/kamctl/sqlite/pdt-create.sql b/utils/kamctl/sqlite/pdt-create.sql
new file mode 100644
index 0000000..46b517a
--- /dev/null
+++ b/utils/kamctl/sqlite/pdt-create.sql
@@ -0,0 +1,9 @@
+INSERT INTO version (table_name, table_version) values ('pdt','1');
+CREATE TABLE pdt (
+ id INTEGER PRIMARY KEY NOT NULL,
+ sdomain VARCHAR(128) NOT NULL,
+ prefix VARCHAR(32) NOT NULL,
+ domain VARCHAR(128) DEFAULT '' NOT NULL,
+ CONSTRAINT pdt_sdomain_prefix_idx UNIQUE (sdomain, prefix)
+);
+
diff --git a/utils/kamctl/sqlite/permissions-create.sql b/utils/kamctl/sqlite/permissions-create.sql
new file mode 100644
index 0000000..ff3ac56
--- /dev/null
+++ b/utils/kamctl/sqlite/permissions-create.sql
@@ -0,0 +1,21 @@
+INSERT INTO version (table_name, table_version) values ('trusted','5');
+CREATE TABLE trusted (
+ id INTEGER PRIMARY KEY NOT NULL,
+ src_ip VARCHAR(50) NOT NULL,
+ proto VARCHAR(4) NOT NULL,
+ from_pattern VARCHAR(64) DEFAULT NULL,
+ tag VARCHAR(64)
+);
+
+CREATE INDEX trusted_peer_idx ON trusted (src_ip);
+
+INSERT INTO version (table_name, table_version) values ('address','4');
+CREATE TABLE address (
+ id INTEGER PRIMARY KEY NOT NULL,
+ grp SMALLINT DEFAULT 1 NOT NULL,
+ ip_addr VARCHAR(15) NOT NULL,
+ mask SMALLINT DEFAULT 32 NOT NULL,
+ port SMALLINT DEFAULT 0 NOT NULL,
+ tag VARCHAR(64)
+);
+
diff --git a/utils/kamctl/sqlite/presence-create.sql b/utils/kamctl/sqlite/presence-create.sql
new file mode 100644
index 0000000..fe89b36
--- /dev/null
+++ b/utils/kamctl/sqlite/presence-create.sql
@@ -0,0 +1,92 @@
+INSERT INTO version (table_name, table_version) values ('presentity','3');
+CREATE TABLE presentity (
+ id INTEGER PRIMARY KEY NOT NULL,
+ username VARCHAR(64) NOT NULL,
+ domain VARCHAR(64) NOT NULL,
+ event VARCHAR(64) NOT NULL,
+ etag VARCHAR(64) NOT NULL,
+ expires INTEGER NOT NULL,
+ received_time INTEGER NOT NULL,
+ body BYTEA NOT NULL,
+ sender VARCHAR(128) NOT NULL,
+ CONSTRAINT presentity_presentity_idx UNIQUE (username, domain, event, etag)
+);
+
+INSERT INTO version (table_name, table_version) values ('active_watchers','9');
+CREATE TABLE active_watchers (
+ id INTEGER PRIMARY KEY NOT NULL,
+ presentity_uri VARCHAR(128) NOT NULL,
+ watcher_username VARCHAR(64) NOT NULL,
+ watcher_domain VARCHAR(64) NOT NULL,
+ to_user VARCHAR(64) NOT NULL,
+ to_domain VARCHAR(64) NOT NULL,
+ event VARCHAR(64) DEFAULT 'presence' NOT NULL,
+ event_id VARCHAR(64),
+ to_tag VARCHAR(64) NOT NULL,
+ from_tag VARCHAR(64) NOT NULL,
+ callid VARCHAR(128) NOT NULL,
+ local_cseq INTEGER NOT NULL,
+ remote_cseq INTEGER NOT NULL,
+ contact VARCHAR(128) NOT NULL,
+ record_route TEXT,
+ expires INTEGER NOT NULL,
+ status INTEGER DEFAULT 2 NOT NULL,
+ reason VARCHAR(64) NOT NULL,
+ version INTEGER DEFAULT 0 NOT NULL,
+ socket_info VARCHAR(64) NOT NULL,
+ local_contact VARCHAR(128) NOT NULL,
+ CONSTRAINT active_watchers_active_watchers_idx UNIQUE (presentity_uri, callid, to_tag, from_tag)
+);
+
+INSERT INTO version (table_name, table_version) values ('watchers','3');
+CREATE TABLE watchers (
+ id INTEGER PRIMARY KEY NOT NULL,
+ presentity_uri VARCHAR(128) NOT NULL,
+ watcher_username VARCHAR(64) NOT NULL,
+ watcher_domain VARCHAR(64) NOT NULL,
+ event VARCHAR(64) DEFAULT 'presence' NOT NULL,
+ status INTEGER NOT NULL,
+ reason VARCHAR(64),
+ inserted_time INTEGER NOT NULL,
+ CONSTRAINT watchers_watcher_idx UNIQUE (presentity_uri, watcher_username, watcher_domain, event)
+);
+
+INSERT INTO version (table_name, table_version) values ('xcap','3');
+CREATE TABLE xcap (
+ id INTEGER PRIMARY KEY NOT NULL,
+ username VARCHAR(64) NOT NULL,
+ domain VARCHAR(64) NOT NULL,
+ doc BYTEA NOT NULL,
+ doc_type INTEGER NOT NULL,
+ etag VARCHAR(64) NOT NULL,
+ source INTEGER NOT NULL,
+ doc_uri VARCHAR(128) NOT NULL,
+ port INTEGER NOT NULL,
+ CONSTRAINT xcap_account_doc_type_idx UNIQUE (username, domain, doc_type, doc_uri)
+);
+
+CREATE INDEX xcap_source_idx ON xcap (source);
+
+INSERT INTO version (table_name, table_version) values ('pua','6');
+CREATE TABLE pua (
+ id INTEGER PRIMARY KEY NOT NULL,
+ pres_uri VARCHAR(128) NOT NULL,
+ pres_id VARCHAR(64) NOT NULL,
+ event INTEGER NOT NULL,
+ expires INTEGER NOT NULL,
+ desired_expires INTEGER NOT NULL,
+ flag INTEGER NOT NULL,
+ etag VARCHAR(64) NOT NULL,
+ tuple_id VARCHAR(64),
+ watcher_uri VARCHAR(128) NOT NULL,
+ call_id VARCHAR(128) NOT NULL,
+ to_tag VARCHAR(64) NOT NULL,
+ from_tag VARCHAR(64) NOT NULL,
+ cseq INTEGER NOT NULL,
+ record_route TEXT,
+ contact VARCHAR(128) NOT NULL,
+ remote_contact VARCHAR(128) NOT NULL,
+ version INTEGER NOT NULL,
+ extra_headers TEXT NOT NULL
+);
+
diff --git a/utils/kamctl/sqlite/purple-create.sql b/utils/kamctl/sqlite/purple-create.sql
new file mode 100644
index 0000000..b58c53e
--- /dev/null
+++ b/utils/kamctl/sqlite/purple-create.sql
@@ -0,0 +1,9 @@
+INSERT INTO version (table_name, table_version) values ('purplemap','1');
+CREATE TABLE purplemap (
+ id INTEGER PRIMARY KEY NOT NULL,
+ sip_user VARCHAR(128) NOT NULL,
+ ext_user VARCHAR(128) NOT NULL,
+ ext_prot VARCHAR(16) NOT NULL,
+ ext_pass VARCHAR(64)
+);
+
diff --git a/utils/kamctl/sqlite/registrar-create.sql b/utils/kamctl/sqlite/registrar-create.sql
new file mode 100644
index 0000000..68f2adc
--- /dev/null
+++ b/utils/kamctl/sqlite/registrar-create.sql
@@ -0,0 +1,22 @@
+INSERT INTO version (table_name, table_version) values ('aliases','1004');
+CREATE TABLE aliases (
+ id INTEGER PRIMARY KEY NOT NULL,
+ username VARCHAR(64) DEFAULT '' NOT NULL,
+ domain VARCHAR(64) DEFAULT NULL,
+ contact VARCHAR(255) DEFAULT '' NOT NULL,
+ received VARCHAR(128) DEFAULT NULL,
+ path VARCHAR(128) DEFAULT NULL,
+ expires TIMESTAMP WITHOUT TIME ZONE DEFAULT '2020-05-28 21:32:15' NOT NULL,
+ q REAL DEFAULT 1.0 NOT NULL,
+ callid VARCHAR(255) DEFAULT 'Default-Call-ID' NOT NULL,
+ cseq INTEGER DEFAULT 13 NOT NULL,
+ last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
+ flags INTEGER DEFAULT 0 NOT NULL,
+ cflags INTEGER DEFAULT 0 NOT NULL,
+ user_agent VARCHAR(255) DEFAULT '' NOT NULL,
+ socket VARCHAR(64) DEFAULT NULL,
+ methods INTEGER DEFAULT NULL
+);
+
+CREATE INDEX aliases_alias_idx ON aliases (username, domain, contact);
+
diff --git a/utils/kamctl/sqlite/rls-create.sql b/utils/kamctl/sqlite/rls-create.sql
new file mode 100644
index 0000000..b15120d
--- /dev/null
+++ b/utils/kamctl/sqlite/rls-create.sql
@@ -0,0 +1,42 @@
+INSERT INTO version (table_name, table_version) values ('rls_presentity','0');
+CREATE TABLE rls_presentity (
+ id INTEGER PRIMARY KEY NOT NULL,
+ rlsubs_did VARCHAR(255) NOT NULL,
+ resource_uri VARCHAR(128) NOT NULL,
+ content_type VARCHAR(64) NOT NULL,
+ presence_state BYTEA NOT NULL,
+ expires INTEGER NOT NULL,
+ updated INTEGER NOT NULL,
+ auth_state INTEGER NOT NULL,
+ reason VARCHAR(64) NOT NULL,
+ CONSTRAINT rls_presentity_rls_presentity_idx UNIQUE (rlsubs_did, resource_uri)
+);
+
+CREATE INDEX rls_presentity_updated_idx ON rls_presentity (updated);
+
+INSERT INTO version (table_name, table_version) values ('rls_watchers','1');
+CREATE TABLE rls_watchers (
+ id INTEGER PRIMARY KEY NOT NULL,
+ presentity_uri VARCHAR(128) NOT NULL,
+ to_user VARCHAR(64) NOT NULL,
+ to_domain VARCHAR(64) NOT NULL,
+ watcher_username VARCHAR(64) NOT NULL,
+ watcher_domain VARCHAR(64) NOT NULL,
+ event VARCHAR(64) DEFAULT 'presence' NOT NULL,
+ event_id VARCHAR(64),
+ to_tag VARCHAR(64) NOT NULL,
+ from_tag VARCHAR(64) NOT NULL,
+ callid VARCHAR(64) NOT NULL,
+ local_cseq INTEGER NOT NULL,
+ remote_cseq INTEGER NOT NULL,
+ contact VARCHAR(64) NOT NULL,
+ record_route TEXT,
+ expires INTEGER NOT NULL,
+ status INTEGER DEFAULT 2 NOT NULL,
+ reason VARCHAR(64) NOT NULL,
+ version INTEGER DEFAULT 0 NOT NULL,
+ socket_info VARCHAR(64) NOT NULL,
+ local_contact VARCHAR(128) NOT NULL,
+ CONSTRAINT rls_watchers_rls_watcher_idx UNIQUE (presentity_uri, callid, to_tag, from_tag)
+);
+
diff --git a/utils/kamctl/sqlite/siptrace-create.sql b/utils/kamctl/sqlite/siptrace-create.sql
new file mode 100644
index 0000000..a784d0b
--- /dev/null
+++ b/utils/kamctl/sqlite/siptrace-create.sql
@@ -0,0 +1,20 @@
+INSERT INTO version (table_name, table_version) values ('sip_trace','2');
+CREATE TABLE sip_trace (
+ id INTEGER PRIMARY KEY NOT NULL,
+ time_stamp TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
+ callid VARCHAR(255) DEFAULT '' NOT NULL,
+ traced_user VARCHAR(128) DEFAULT '' NOT NULL,
+ msg TEXT NOT NULL,
+ method VARCHAR(50) DEFAULT '' NOT NULL,
+ status VARCHAR(128) DEFAULT '' NOT NULL,
+ fromip VARCHAR(50) DEFAULT '' NOT NULL,
+ toip VARCHAR(50) DEFAULT '' NOT NULL,
+ fromtag VARCHAR(64) DEFAULT '' NOT NULL,
+ direction VARCHAR(4) DEFAULT '' NOT NULL
+);
+
+CREATE INDEX sip_trace_traced_user_idx ON sip_trace (traced_user);
+CREATE INDEX sip_trace_date_idx ON sip_trace (time_stamp);
+CREATE INDEX sip_trace_fromip_idx ON sip_trace (fromip);
+CREATE INDEX sip_trace_callid_idx ON sip_trace (callid);
+
diff --git a/utils/kamctl/sqlite/speeddial-create.sql b/utils/kamctl/sqlite/speeddial-create.sql
new file mode 100644
index 0000000..64e1ae6
--- /dev/null
+++ b/utils/kamctl/sqlite/speeddial-create.sql
@@ -0,0 +1,14 @@
+INSERT INTO version (table_name, table_version) values ('speed_dial','2');
+CREATE TABLE speed_dial (
+ id INTEGER PRIMARY KEY NOT NULL,
+ username VARCHAR(64) DEFAULT '' NOT NULL,
+ domain VARCHAR(64) DEFAULT '' NOT NULL,
+ sd_username VARCHAR(64) DEFAULT '' NOT NULL,
+ sd_domain VARCHAR(64) DEFAULT '' NOT NULL,
+ new_uri VARCHAR(128) DEFAULT '' NOT NULL,
+ fname VARCHAR(64) DEFAULT '' NOT NULL,
+ lname VARCHAR(64) DEFAULT '' NOT NULL,
+ description VARCHAR(64) DEFAULT '' NOT NULL,
+ CONSTRAINT speed_dial_speed_dial_idx UNIQUE (username, domain, sd_domain, sd_username)
+);
+
diff --git a/utils/kamctl/sqlite/standard-create.sql b/utils/kamctl/sqlite/standard-create.sql
new file mode 100644
index 0000000..0add99d
--- /dev/null
+++ b/utils/kamctl/sqlite/standard-create.sql
@@ -0,0 +1,5 @@
+CREATE TABLE version (
+ table_name VARCHAR(32) NOT NULL,
+ table_version INTEGER DEFAULT 0 NOT NULL
+);
+
diff --git a/utils/kamctl/sqlite/uac-create.sql b/utils/kamctl/sqlite/uac-create.sql
new file mode 100644
index 0000000..f0cf80d
--- /dev/null
+++ b/utils/kamctl/sqlite/uac-create.sql
@@ -0,0 +1,16 @@
+INSERT INTO version (table_name, table_version) values ('uacreg','1');
+CREATE TABLE uacreg (
+ id INTEGER PRIMARY KEY NOT NULL,
+ l_uuid VARCHAR(64) DEFAULT '' NOT NULL,
+ l_username VARCHAR(64) DEFAULT '' NOT NULL,
+ l_domain VARCHAR(128) DEFAULT '' NOT NULL,
+ r_username VARCHAR(64) DEFAULT '' NOT NULL,
+ r_domain VARCHAR(128) DEFAULT '' NOT NULL,
+ realm VARCHAR(64) DEFAULT '' NOT NULL,
+ auth_username VARCHAR(64) DEFAULT '' NOT NULL,
+ auth_password VARCHAR(64) DEFAULT '' NOT NULL,
+ auth_proxy VARCHAR(64) DEFAULT '' NOT NULL,
+ expires INTEGER DEFAULT 0 NOT NULL,
+ CONSTRAINT uacreg_l_uuid_idx UNIQUE (l_uuid)
+);
+
diff --git a/utils/kamctl/sqlite/uri_db-create.sql b/utils/kamctl/sqlite/uri_db-create.sql
new file mode 100644
index 0000000..8e291fc
--- /dev/null
+++ b/utils/kamctl/sqlite/uri_db-create.sql
@@ -0,0 +1,10 @@
+INSERT INTO version (table_name, table_version) values ('uri','1');
+CREATE TABLE uri (
+ id INTEGER PRIMARY KEY NOT NULL,
+ username VARCHAR(64) DEFAULT '' NOT NULL,
+ domain VARCHAR(64) DEFAULT '' NOT NULL,
+ uri_user VARCHAR(64) DEFAULT '' NOT NULL,
+ last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
+ CONSTRAINT uri_account_idx UNIQUE (username, domain, uri_user)
+);
+
diff --git a/utils/kamctl/sqlite/userblacklist-create.sql b/utils/kamctl/sqlite/userblacklist-create.sql
new file mode 100644
index 0000000..34d9eb1
--- /dev/null
+++ b/utils/kamctl/sqlite/userblacklist-create.sql
@@ -0,0 +1,21 @@
+INSERT INTO version (table_name, table_version) values ('userblacklist','1');
+CREATE TABLE userblacklist (
+ id INTEGER PRIMARY KEY NOT NULL,
+ username VARCHAR(64) DEFAULT '' NOT NULL,
+ domain VARCHAR(64) DEFAULT '' NOT NULL,
+ prefix VARCHAR(64) DEFAULT '' NOT NULL,
+ whitelist SMALLINT DEFAULT 0 NOT NULL
+);
+
+CREATE INDEX userblacklist_userblacklist_idx ON userblacklist (username, domain, prefix);
+
+INSERT INTO version (table_name, table_version) values ('globalblacklist','1');
+CREATE TABLE globalblacklist (
+ id INTEGER PRIMARY KEY NOT NULL,
+ prefix VARCHAR(64) DEFAULT '' NOT NULL,
+ whitelist SMALLINT DEFAULT 0 NOT NULL,
+ description VARCHAR(255) DEFAULT NULL
+);
+
+CREATE INDEX globalblacklist_globalblacklist_idx ON globalblacklist (prefix);
+
diff --git a/utils/kamctl/sqlite/usrloc-create.sql b/utils/kamctl/sqlite/usrloc-create.sql
new file mode 100644
index 0000000..6eb7d07
--- /dev/null
+++ b/utils/kamctl/sqlite/usrloc-create.sql
@@ -0,0 +1,22 @@
+INSERT INTO version (table_name, table_version) values ('location','1004');
+CREATE TABLE location (
+ id INTEGER PRIMARY KEY NOT NULL,
+ username VARCHAR(64) DEFAULT '' NOT NULL,
+ domain VARCHAR(64) DEFAULT NULL,
+ contact VARCHAR(255) DEFAULT '' NOT NULL,
+ received VARCHAR(128) DEFAULT NULL,
+ path VARCHAR(128) DEFAULT NULL,
+ expires TIMESTAMP WITHOUT TIME ZONE DEFAULT '2020-05-28 21:32:15' NOT NULL,
+ q REAL DEFAULT 1.0 NOT NULL,
+ callid VARCHAR(255) DEFAULT 'Default-Call-ID' NOT NULL,
+ cseq INTEGER DEFAULT 13 NOT NULL,
+ last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
+ flags INTEGER DEFAULT 0 NOT NULL,
+ cflags INTEGER DEFAULT 0 NOT NULL,
+ user_agent VARCHAR(255) DEFAULT '' NOT NULL,
+ socket VARCHAR(64) DEFAULT NULL,
+ methods INTEGER DEFAULT NULL
+);
+
+CREATE INDEX location_account_contact_idx ON location (username, domain, contact);
+
--
1.7.4.5
|