forked from RAKWireless/ChirpStack_on_Ubuntu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit_sql.sql
2898 lines (1963 loc) · 94.7 KB
/
init_sql.sql
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
--
-- PostgreSQL database cluster dump
--
SET default_transaction_read_only = off;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
--
-- Roles
--
CREATE ROLE chirpstack_as;
ALTER ROLE chirpstack_as WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN NOREPLICATION NOBYPASSRLS PASSWORD 'md54eac16be2e6c5b418ce2bc7d2c05a635';
CREATE ROLE chirpstack_ns;
ALTER ROLE chirpstack_ns WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN NOREPLICATION NOBYPASSRLS PASSWORD 'md571269333057d9ebe969d61173b7ae2d9';
CREATE ROLE postgres;
ALTER ROLE postgres WITH SUPERUSER INHERIT CREATEROLE CREATEDB LOGIN REPLICATION BYPASSRLS;
\connect template1
--
-- PostgreSQL database dump
--
-- Dumped from database version 11.7 (Raspbian 11.7-0+deb10u1)
-- Dumped by pg_dump version 11.7 (Raspbian 11.7-0+deb10u1)
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- PostgreSQL database dump complete
--
--
-- PostgreSQL database dump
--
-- Dumped from database version 11.7 (Raspbian 11.7-0+deb10u1)
-- Dumped by pg_dump version 11.7 (Raspbian 11.7-0+deb10u1)
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: chirpstack_as; Type: DATABASE; Schema: -; Owner: chirpstack_as
--
CREATE DATABASE chirpstack_as WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'en_GB.UTF-8' LC_CTYPE = 'en_GB.UTF-8';
ALTER DATABASE chirpstack_as OWNER TO chirpstack_as;
\connect chirpstack_as
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: hstore; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public;
--
-- Name: EXTENSION hstore; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs';
--
-- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public;
--
-- Name: EXTENSION pg_trgm; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams';
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: application; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.application (
id bigint NOT NULL,
name character varying(100) NOT NULL,
description text NOT NULL,
organization_id bigint NOT NULL,
service_profile_id uuid NOT NULL,
payload_codec text DEFAULT ''::text NOT NULL,
payload_encoder_script text DEFAULT ''::text NOT NULL,
payload_decoder_script text DEFAULT ''::text NOT NULL
);
ALTER TABLE public.application OWNER TO chirpstack_as;
--
-- Name: application_id_seq; Type: SEQUENCE; Schema: public; Owner: chirpstack_as
--
CREATE SEQUENCE public.application_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.application_id_seq OWNER TO chirpstack_as;
--
-- Name: application_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: chirpstack_as
--
ALTER SEQUENCE public.application_id_seq OWNED BY public.application.id;
--
-- Name: code_migration; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.code_migration (
id text NOT NULL,
applied_at timestamp with time zone NOT NULL
);
ALTER TABLE public.code_migration OWNER TO chirpstack_as;
--
-- Name: device; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.device (
dev_eui bytea NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
application_id bigint NOT NULL,
device_profile_id uuid NOT NULL,
name character varying(100) NOT NULL,
description text NOT NULL,
last_seen_at timestamp with time zone,
device_status_battery numeric(5,2),
device_status_margin integer,
latitude double precision,
longitude double precision,
altitude double precision,
device_status_external_power_source boolean NOT NULL,
dr smallint,
variables public.hstore,
tags public.hstore,
dev_addr bytea NOT NULL,
app_s_key bytea NOT NULL
);
ALTER TABLE public.device OWNER TO chirpstack_as;
--
-- Name: device_keys; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.device_keys (
dev_eui bytea NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
nwk_key bytea NOT NULL,
join_nonce integer NOT NULL,
app_key bytea NOT NULL,
gen_app_key bytea NOT NULL
);
ALTER TABLE public.device_keys OWNER TO chirpstack_as;
--
-- Name: device_multicast_group; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.device_multicast_group (
dev_eui bytea NOT NULL,
multicast_group_id uuid NOT NULL,
created_at timestamp with time zone NOT NULL
);
ALTER TABLE public.device_multicast_group OWNER TO chirpstack_as;
--
-- Name: device_profile; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.device_profile (
device_profile_id uuid NOT NULL,
network_server_id bigint NOT NULL,
organization_id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
name character varying(100) NOT NULL,
payload_codec text NOT NULL,
payload_encoder_script text NOT NULL,
payload_decoder_script text NOT NULL,
tags public.hstore
);
ALTER TABLE public.device_profile OWNER TO chirpstack_as;
--
-- Name: fuota_deployment; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.fuota_deployment (
id uuid NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
name character varying(100) NOT NULL,
multicast_group_id uuid,
group_type character(1) NOT NULL,
dr smallint NOT NULL,
frequency integer NOT NULL,
ping_slot_period smallint NOT NULL,
fragmentation_matrix bytea NOT NULL,
descriptor bytea NOT NULL,
payload bytea NOT NULL,
frag_size smallint NOT NULL,
redundancy smallint NOT NULL,
multicast_timeout smallint NOT NULL,
block_ack_delay smallint NOT NULL,
state character varying(20) NOT NULL,
unicast_timeout bigint NOT NULL,
next_step_after timestamp with time zone NOT NULL
);
ALTER TABLE public.fuota_deployment OWNER TO chirpstack_as;
--
-- Name: fuota_deployment_device; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.fuota_deployment_device (
fuota_deployment_id uuid NOT NULL,
dev_eui bytea NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
state character varying(20) NOT NULL,
error_message text NOT NULL
);
ALTER TABLE public.fuota_deployment_device OWNER TO chirpstack_as;
--
-- Name: gateway; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.gateway (
mac bytea NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
name character varying(100) NOT NULL,
description text NOT NULL,
organization_id bigint NOT NULL,
ping boolean DEFAULT false NOT NULL,
last_ping_id bigint,
last_ping_sent_at timestamp with time zone,
network_server_id bigint NOT NULL,
gateway_profile_id uuid,
first_seen_at timestamp with time zone,
last_seen_at timestamp with time zone,
latitude double precision NOT NULL,
longitude double precision NOT NULL,
altitude double precision NOT NULL,
tags public.hstore,
metadata public.hstore
);
ALTER TABLE public.gateway OWNER TO chirpstack_as;
--
-- Name: gateway_ping; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.gateway_ping (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
gateway_mac bytea NOT NULL,
frequency integer NOT NULL,
dr integer NOT NULL
);
ALTER TABLE public.gateway_ping OWNER TO chirpstack_as;
--
-- Name: gateway_ping_id_seq; Type: SEQUENCE; Schema: public; Owner: chirpstack_as
--
CREATE SEQUENCE public.gateway_ping_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.gateway_ping_id_seq OWNER TO chirpstack_as;
--
-- Name: gateway_ping_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: chirpstack_as
--
ALTER SEQUENCE public.gateway_ping_id_seq OWNED BY public.gateway_ping.id;
--
-- Name: gateway_ping_rx; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.gateway_ping_rx (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
ping_id bigint NOT NULL,
gateway_mac bytea NOT NULL,
received_at timestamp with time zone,
rssi integer NOT NULL,
lora_snr numeric(3,1) NOT NULL,
location point,
altitude double precision
);
ALTER TABLE public.gateway_ping_rx OWNER TO chirpstack_as;
--
-- Name: gateway_ping_rx_id_seq; Type: SEQUENCE; Schema: public; Owner: chirpstack_as
--
CREATE SEQUENCE public.gateway_ping_rx_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.gateway_ping_rx_id_seq OWNER TO chirpstack_as;
--
-- Name: gateway_ping_rx_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: chirpstack_as
--
ALTER SEQUENCE public.gateway_ping_rx_id_seq OWNED BY public.gateway_ping_rx.id;
--
-- Name: gateway_profile; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.gateway_profile (
gateway_profile_id uuid NOT NULL,
network_server_id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
name character varying(100) NOT NULL
);
ALTER TABLE public.gateway_profile OWNER TO chirpstack_as;
--
-- Name: gorp_migrations; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.gorp_migrations (
id text NOT NULL,
applied_at timestamp with time zone
);
ALTER TABLE public.gorp_migrations OWNER TO chirpstack_as;
--
-- Name: integration; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.integration (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
application_id bigint NOT NULL,
kind character varying(20) NOT NULL,
settings jsonb
);
ALTER TABLE public.integration OWNER TO chirpstack_as;
--
-- Name: integration_id_seq; Type: SEQUENCE; Schema: public; Owner: chirpstack_as
--
CREATE SEQUENCE public.integration_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.integration_id_seq OWNER TO chirpstack_as;
--
-- Name: integration_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: chirpstack_as
--
ALTER SEQUENCE public.integration_id_seq OWNED BY public.integration.id;
--
-- Name: multicast_group; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.multicast_group (
id uuid NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
name character varying(100) NOT NULL,
service_profile_id uuid NOT NULL,
mc_app_s_key bytea,
mc_key bytea NOT NULL
);
ALTER TABLE public.multicast_group OWNER TO chirpstack_as;
--
-- Name: network_server; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.network_server (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
name character varying(100) NOT NULL,
server character varying(255) NOT NULL,
ca_cert text DEFAULT ''::text NOT NULL,
tls_cert text DEFAULT ''::text NOT NULL,
tls_key text DEFAULT ''::text NOT NULL,
routing_profile_ca_cert text DEFAULT ''::text NOT NULL,
routing_profile_tls_cert text DEFAULT ''::text NOT NULL,
routing_profile_tls_key text DEFAULT ''::text NOT NULL,
gateway_discovery_enabled boolean DEFAULT false NOT NULL,
gateway_discovery_interval integer DEFAULT 0 NOT NULL,
gateway_discovery_tx_frequency integer DEFAULT 0 NOT NULL,
gateway_discovery_dr smallint DEFAULT 0 NOT NULL
);
ALTER TABLE public.network_server OWNER TO chirpstack_as;
--
-- Name: network_server_id_seq; Type: SEQUENCE; Schema: public; Owner: chirpstack_as
--
CREATE SEQUENCE public.network_server_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.network_server_id_seq OWNER TO chirpstack_as;
--
-- Name: network_server_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: chirpstack_as
--
ALTER SEQUENCE public.network_server_id_seq OWNED BY public.network_server.id;
--
-- Name: organization; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.organization (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
name character varying(100) NOT NULL,
display_name character varying(100) NOT NULL,
can_have_gateways boolean NOT NULL
);
ALTER TABLE public.organization OWNER TO chirpstack_as;
--
-- Name: organization_id_seq; Type: SEQUENCE; Schema: public; Owner: chirpstack_as
--
CREATE SEQUENCE public.organization_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.organization_id_seq OWNER TO chirpstack_as;
--
-- Name: organization_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: chirpstack_as
--
ALTER SEQUENCE public.organization_id_seq OWNED BY public.organization.id;
--
-- Name: organization_user; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.organization_user (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
user_id bigint NOT NULL,
organization_id bigint NOT NULL,
is_admin boolean NOT NULL,
is_device_admin boolean NOT NULL,
is_gateway_admin boolean NOT NULL
);
ALTER TABLE public.organization_user OWNER TO chirpstack_as;
--
-- Name: organization_user_id_seq; Type: SEQUENCE; Schema: public; Owner: chirpstack_as
--
CREATE SEQUENCE public.organization_user_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.organization_user_id_seq OWNER TO chirpstack_as;
--
-- Name: organization_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: chirpstack_as
--
ALTER SEQUENCE public.organization_user_id_seq OWNED BY public.organization_user.id;
--
-- Name: remote_fragmentation_session; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.remote_fragmentation_session (
dev_eui bytea NOT NULL,
frag_index smallint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
mc_group_ids smallint[],
nb_frag integer NOT NULL,
frag_size smallint NOT NULL,
fragmentation_matrix bytea NOT NULL,
block_ack_delay smallint NOT NULL,
padding smallint NOT NULL,
descriptor bytea NOT NULL,
state character varying(20) NOT NULL,
state_provisioned boolean DEFAULT false NOT NULL,
retry_after timestamp with time zone NOT NULL,
retry_count smallint NOT NULL,
retry_interval bigint NOT NULL
);
ALTER TABLE public.remote_fragmentation_session OWNER TO chirpstack_as;
--
-- Name: remote_multicast_class_c_session; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.remote_multicast_class_c_session (
dev_eui bytea NOT NULL,
multicast_group_id uuid NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
mc_group_id smallint NOT NULL,
session_time timestamp with time zone NOT NULL,
session_time_out smallint NOT NULL,
dl_frequency integer NOT NULL,
dr smallint NOT NULL,
state_provisioned boolean DEFAULT false NOT NULL,
retry_after timestamp with time zone NOT NULL,
retry_count smallint NOT NULL,
retry_interval bigint NOT NULL
);
ALTER TABLE public.remote_multicast_class_c_session OWNER TO chirpstack_as;
--
-- Name: remote_multicast_setup; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.remote_multicast_setup (
dev_eui bytea NOT NULL,
multicast_group_id uuid NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
mc_group_id smallint NOT NULL,
mc_addr bytea NOT NULL,
mc_key_encrypted bytea NOT NULL,
min_mc_f_cnt bigint NOT NULL,
max_mc_f_cnt bigint NOT NULL,
state character varying(20) NOT NULL,
state_provisioned boolean DEFAULT false NOT NULL,
retry_after timestamp with time zone NOT NULL,
retry_count smallint NOT NULL,
retry_interval bigint NOT NULL
);
ALTER TABLE public.remote_multicast_setup OWNER TO chirpstack_as;
--
-- Name: service_profile; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public.service_profile (
service_profile_id uuid NOT NULL,
organization_id bigint NOT NULL,
network_server_id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
name character varying(100) NOT NULL
);
ALTER TABLE public.service_profile OWNER TO chirpstack_as;
--
-- Name: user; Type: TABLE; Schema: public; Owner: chirpstack_as
--
CREATE TABLE public."user" (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
username character varying(100) NOT NULL,
password_hash character varying(200) NOT NULL,
session_ttl bigint NOT NULL,
is_active boolean NOT NULL,
is_admin boolean NOT NULL,
email text DEFAULT ''::text NOT NULL,
note text DEFAULT ''::text NOT NULL
);
ALTER TABLE public."user" OWNER TO chirpstack_as;
--
-- Name: user_id_seq; Type: SEQUENCE; Schema: public; Owner: chirpstack_as
--
CREATE SEQUENCE public.user_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.user_id_seq OWNER TO chirpstack_as;
--
-- Name: user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: chirpstack_as
--
ALTER SEQUENCE public.user_id_seq OWNED BY public."user".id;
--
-- Name: application id; Type: DEFAULT; Schema: public; Owner: chirpstack_as
--
ALTER TABLE ONLY public.application ALTER COLUMN id SET DEFAULT nextval('public.application_id_seq'::regclass);
--
-- Name: gateway_ping id; Type: DEFAULT; Schema: public; Owner: chirpstack_as
--
ALTER TABLE ONLY public.gateway_ping ALTER COLUMN id SET DEFAULT nextval('public.gateway_ping_id_seq'::regclass);
--
-- Name: gateway_ping_rx id; Type: DEFAULT; Schema: public; Owner: chirpstack_as
--
ALTER TABLE ONLY public.gateway_ping_rx ALTER COLUMN id SET DEFAULT nextval('public.gateway_ping_rx_id_seq'::regclass);
--
-- Name: integration id; Type: DEFAULT; Schema: public; Owner: chirpstack_as
--
ALTER TABLE ONLY public.integration ALTER COLUMN id SET DEFAULT nextval('public.integration_id_seq'::regclass);
--
-- Name: network_server id; Type: DEFAULT; Schema: public; Owner: chirpstack_as
--
ALTER TABLE ONLY public.network_server ALTER COLUMN id SET DEFAULT nextval('public.network_server_id_seq'::regclass);
--
-- Name: organization id; Type: DEFAULT; Schema: public; Owner: chirpstack_as
--
ALTER TABLE ONLY public.organization ALTER COLUMN id SET DEFAULT nextval('public.organization_id_seq'::regclass);
--
-- Name: organization_user id; Type: DEFAULT; Schema: public; Owner: chirpstack_as
--
ALTER TABLE ONLY public.organization_user ALTER COLUMN id SET DEFAULT nextval('public.organization_user_id_seq'::regclass);
--
-- Name: user id; Type: DEFAULT; Schema: public; Owner: chirpstack_as
--
ALTER TABLE ONLY public."user" ALTER COLUMN id SET DEFAULT nextval('public.user_id_seq'::regclass);
--
-- Data for Name: application; Type: TABLE DATA; Schema: public; Owner: chirpstack_as
--
COPY public.application (id, name, description, organization_id, service_profile_id, payload_codec, payload_encoder_script, payload_decoder_script) FROM stdin;
\.
--
-- Data for Name: code_migration; Type: TABLE DATA; Schema: public; Owner: chirpstack_as
--
COPY public.code_migration (id, applied_at) FROM stdin;
migrate_gw_stats 2020-03-12 03:51:20.870664+00
\.
--
-- Data for Name: device; Type: TABLE DATA; Schema: public; Owner: chirpstack_as
--
COPY public.device (dev_eui, created_at, updated_at, application_id, device_profile_id, name, description, last_seen_at, device_status_battery, device_status_margin, latitude, longitude, altitude, device_status_external_power_source, dr, variables, tags, dev_addr, app_s_key) FROM stdin;
\.
--
-- Data for Name: device_keys; Type: TABLE DATA; Schema: public; Owner: chirpstack_as
--
COPY public.device_keys (dev_eui, created_at, updated_at, nwk_key, join_nonce, app_key, gen_app_key) FROM stdin;
\.
--
-- Data for Name: device_multicast_group; Type: TABLE DATA; Schema: public; Owner: chirpstack_as
--
COPY public.device_multicast_group (dev_eui, multicast_group_id, created_at) FROM stdin;
\.
--
-- Data for Name: device_profile; Type: TABLE DATA; Schema: public; Owner: chirpstack_as
--
COPY public.device_profile (device_profile_id, network_server_id, organization_id, created_at, updated_at, name, payload_codec, payload_encoder_script, payload_decoder_script, tags) FROM stdin;
d6741e98-4230-4d99-a760-244725679e45 1 1 2020-03-12 03:53:07.714166+00 2020-03-12 04:21:24.47568+00 device_profile_abp CUSTOM_JS // ttn application function to decode uplink data.\n// Decode decodes an array of bytes into an object.\n// - port contains the LoRaWAN fPort number\n// - bytes is an array of bytes, e.g. [225, 230, 255, 0]\n// The function must return an object\n// for RAK, return {\n// "DecodeDataHex": {} // RAK5205 sensor data in Hex format\n// "DecodeDataObj": {} // RAK5205 sensor data object.\n// }\n// The function prototype cannot be modified.\nfunction Decoder(bytes, port) {\n var decoded = {"DecodeDataHex": {}, "DecodeDataObj": {}};\n var hexString=bin2HexStr(bytes);\n decoded.DecodeDataHex = hexString;\n decoded.DecodeDataObj = rakSensorDataDecode(hexString);\n\n return decoded;\n}\n\n// convert array of bytes to hex string.\n// e.g: 0188053797109D5900DC140802017A0768580673256D0267011D040214AF0371FFFFFFDDFC2E\nfunction bin2HexStr(bytesArr) {\n var str = "";\n for(var i=0; i<bytesArr.length; i++) {\n var tmp = (bytesArr[i] & 0xff).toString(16);\n if(tmp.length == 1) {\n tmp = "0" + tmp;\n }\n str += tmp;\n }\n return str;\n}\n\n// convert string to short integer\nfunction parseShort(str, base) {\n var n = parseInt(str, base);\n return (n << 16) >> 16;\n}\n\n// convert string to triple bytes integer\nfunction parseTriple(str, base) {\n var n = parseInt(str, base);\n return (n << 8) >> 8;\n}\n\n// decode Hex sensor string data to object\nfunction rakSensorDataDecode(hexStr) {\n var str = hexStr;\n var myObj = {};\n var environment = {};\n\n while (str.length > 4) {\n var flag = parseInt(str.substring(0, 4), 16);\n switch (flag) {\n case 0x0768:// Humidity\n environment.humidity = ((parseShort(str.substring(4, 6), 16) * 0.01 / 2) * 100).toFixed(1) + '% RH';\n str = str.substring(6);\n break;\n case 0x0673:// Atmospheric pressure\n environment.barometer = (parseShort(str.substring(4, 8), 16) * 0.1).toFixed(2) + "hPa";\n str = str.substring(8);\n break;\n case 0x0267:// Temperature\n environment.temperature = (parseShort(str.substring(4, 8), 16) * 0.1).toFixed(2) + "°C";\n str = str.substring(8);\n break;\n case 0x0188:// GPS\n var gps = {};\n gps.latitude = (parseTriple(str.substring(4, 10), 16) * 0.0001).toFixed(4) + "°";\n gps.longitude = (parseTriple(str.substring(10, 16), 16) * 0.0001).toFixed(4) + "°";\n gps.altitude = (parseTriple(str.substring(16, 22), 16) * 0.01).toFixed(1) + "m";\n myObj.gps = gps;\n str = str.substring(22);\n break;\n case 0x0371:// Triaxial acceleration\n var acceleration = {};\n acceleration.x = (parseShort(str.substring(4, 8), 16) * 0.001).toFixed(3) + "g";\n acceleration.y = (parseShort(str.substring(8, 12), 16) * 0.001).toFixed(3) + "g";\n acceleration.z = (parseShort(str.substring(12, 16), 16) * 0.001).toFixed(3) + "g";\n myObj.acceleration = acceleration;\n str = str.substring(16);\n break;\n case 0x0402:// air resistance\n environment.gasResistance = (parseShort(str.substring(4, 8), 16) * 0.01).toFixed(2) + "KΩ";\n str = str.substring(8);\n break;\n case 0x0802:// Battery Voltage\n myObj.battery = (parseShort(str.substring(4, 8), 16) * 0.01).toFixed(2) + "V";\n str = str.substring(8);\n break;\n case 0x0586:// gyroscope\n var gyroscope = {};\n gyroscope.x = (parseShort(str.substring(4, 8), 16) * 0.01).toFixed(2) + "°/s";\n gyroscope.y = (parseShort(str.substring(8, 12), 16) * 0.01).toFixed(2) + "°/s";\n gyroscope.z = (parseShort(str.substring(12, 16), 16) * 0.01).toFixed(2) + "°/s";\n myObj.gyroscope = gyroscope;\n str = str.substring(16);\n break;\n case 0x0902:// magnetometer x\n var magnetometer = {};\n magnetometer.x = (parseShort(str.substring(4, 8), 16) * 0.01).toFixed(2) + "μT";\n magnetometer.y = (parseShort(str.substring(12, 16), 16) * 0.01).toFixed(2) + "μT";\n magnetometer.z = (parseShort(str.substring(20, 24), 16) * 0.01).toFixed(2) + "μT";\n myObj.magnetometer = magnetometer;\n str = str.substring(24);\n break;\n default:\n str = str.substring(7);\n break;\n }\n }\n if(Object.getOwnPropertyNames(environment).length > 0) {\n myObj.environment = environment;\n }\n\n return myObj;\n}
70298761-1bf9-4a6c-bda1-69a0eb04aaaf 1 1 2020-03-12 03:52:48.337365+00 2020-03-12 04:21:37.038328+00 device_profile_otaa CUSTOM_JS // ttn application function to decode uplink data.\n// Decode decodes an array of bytes into an object.\n// - port contains the LoRaWAN fPort number\n// - bytes is an array of bytes, e.g. [225, 230, 255, 0]\n// The function must return an object\n// for RAK, return {\n// "DecodeDataHex": {} // RAK5205 sensor data in Hex format\n// "DecodeDataObj": {} // RAK5205 sensor data object.\n// }\n// The function prototype cannot be modified.\nfunction Decoder(bytes, port) {\n var decoded = {"DecodeDataHex": {}, "DecodeDataObj": {}};\n var hexString=bin2HexStr(bytes);\n decoded.DecodeDataHex = hexString;\n decoded.DecodeDataObj = rakSensorDataDecode(hexString);\n\n return decoded;\n}\n\n// convert array of bytes to hex string.\n// e.g: 0188053797109D5900DC140802017A0768580673256D0267011D040214AF0371FFFFFFDDFC2E\nfunction bin2HexStr(bytesArr) {\n var str = "";\n for(var i=0; i<bytesArr.length; i++) {\n var tmp = (bytesArr[i] & 0xff).toString(16);\n if(tmp.length == 1) {\n tmp = "0" + tmp;\n }\n str += tmp;\n }\n return str;\n}\n\n// convert string to short integer\nfunction parseShort(str, base) {\n var n = parseInt(str, base);\n return (n << 16) >> 16;\n}\n\n// convert string to triple bytes integer\nfunction parseTriple(str, base) {\n var n = parseInt(str, base);\n return (n << 8) >> 8;\n}\n\n// decode Hex sensor string data to object\nfunction rakSensorDataDecode(hexStr) {\n var str = hexStr;\n var myObj = {};\n var environment = {};\n\n while (str.length > 4) {\n var flag = parseInt(str.substring(0, 4), 16);\n switch (flag) {\n case 0x0768:// Humidity\n environment.humidity = ((parseShort(str.substring(4, 6), 16) * 0.01 / 2) * 100).toFixed(1) + '% RH';\n str = str.substring(6);\n break;\n case 0x0673:// Atmospheric pressure\n environment.barometer = (parseShort(str.substring(4, 8), 16) * 0.1).toFixed(2) + "hPa";\n str = str.substring(8);\n break;\n case 0x0267:// Temperature\n environment.temperature = (parseShort(str.substring(4, 8), 16) * 0.1).toFixed(2) + "°C";\n str = str.substring(8);\n break;\n case 0x0188:// GPS\n var gps = {};\n gps.latitude = (parseTriple(str.substring(4, 10), 16) * 0.0001).toFixed(4) + "°";\n gps.longitude = (parseTriple(str.substring(10, 16), 16) * 0.0001).toFixed(4) + "°";\n gps.altitude = (parseTriple(str.substring(16, 22), 16) * 0.01).toFixed(1) + "m";\n myObj.gps = gps;\n str = str.substring(22);\n break;\n case 0x0371:// Triaxial acceleration\n var acceleration = {};\n acceleration.x = (parseShort(str.substring(4, 8), 16) * 0.001).toFixed(3) + "g";\n acceleration.y = (parseShort(str.substring(8, 12), 16) * 0.001).toFixed(3) + "g";\n acceleration.z = (parseShort(str.substring(12, 16), 16) * 0.001).toFixed(3) + "g";\n myObj.acceleration = acceleration;\n str = str.substring(16);\n break;\n case 0x0402:// air resistance\n environment.gasResistance = (parseShort(str.substring(4, 8), 16) * 0.01).toFixed(2) + "KΩ";\n str = str.substring(8);\n break;\n case 0x0802:// Battery Voltage\n myObj.battery = (parseShort(str.substring(4, 8), 16) * 0.01).toFixed(2) + "V";\n str = str.substring(8);\n break;\n case 0x0586:// gyroscope\n var gyroscope = {};\n gyroscope.x = (parseShort(str.substring(4, 8), 16) * 0.01).toFixed(2) + "°/s";\n gyroscope.y = (parseShort(str.substring(8, 12), 16) * 0.01).toFixed(2) + "°/s";\n gyroscope.z = (parseShort(str.substring(12, 16), 16) * 0.01).toFixed(2) + "°/s";\n myObj.gyroscope = gyroscope;\n str = str.substring(16);\n break;\n case 0x0902:// magnetometer x\n var magnetometer = {};\n magnetometer.x = (parseShort(str.substring(4, 8), 16) * 0.01).toFixed(2) + "μT";\n magnetometer.y = (parseShort(str.substring(12, 16), 16) * 0.01).toFixed(2) + "μT";\n magnetometer.z = (parseShort(str.substring(20, 24), 16) * 0.01).toFixed(2) + "μT";\n myObj.magnetometer = magnetometer;\n str = str.substring(24);\n break;\n default:\n str = str.substring(7);\n break;\n }\n }\n if(Object.getOwnPropertyNames(environment).length > 0) {\n myObj.environment = environment;\n }\n\n return myObj;\n}
\.
--
-- Data for Name: fuota_deployment; Type: TABLE DATA; Schema: public; Owner: chirpstack_as
--
COPY public.fuota_deployment (id, created_at, updated_at, name, multicast_group_id, group_type, dr, frequency, ping_slot_period, fragmentation_matrix, descriptor, payload, frag_size, redundancy, multicast_timeout, block_ack_delay, state, unicast_timeout, next_step_after) FROM stdin;
\.
--
-- Data for Name: fuota_deployment_device; Type: TABLE DATA; Schema: public; Owner: chirpstack_as
--
COPY public.fuota_deployment_device (fuota_deployment_id, dev_eui, created_at, updated_at, state, error_message) FROM stdin;
\.
--
-- Data for Name: gateway; Type: TABLE DATA; Schema: public; Owner: chirpstack_as
--
COPY public.gateway (mac, created_at, updated_at, name, description, organization_id, ping, last_ping_id, last_ping_sent_at, network_server_id, gateway_profile_id, first_seen_at, last_seen_at, latitude, longitude, altitude, tags, metadata) FROM stdin;
\\x0000000000088888 2020-03-12 04:01:31.055712+00 2020-03-12 04:01:31.055712+00 rak-gateway rak-gateway 1 f \N \N 1 \N \N \N 0 0 0 \N
\.
--
-- Data for Name: gateway_ping; Type: TABLE DATA; Schema: public; Owner: chirpstack_as
--
COPY public.gateway_ping (id, created_at, gateway_mac, frequency, dr) FROM stdin;
\.
--
-- Data for Name: gateway_ping_rx; Type: TABLE DATA; Schema: public; Owner: chirpstack_as
--
COPY public.gateway_ping_rx (id, created_at, ping_id, gateway_mac, received_at, rssi, lora_snr, location, altitude) FROM stdin;
\.
--
-- Data for Name: gateway_profile; Type: TABLE DATA; Schema: public; Owner: chirpstack_as
--
COPY public.gateway_profile (gateway_profile_id, network_server_id, created_at, updated_at, name) FROM stdin;
\.
--
-- Data for Name: gorp_migrations; Type: TABLE DATA; Schema: public; Owner: chirpstack_as
--
COPY public.gorp_migrations (id, applied_at) FROM stdin;
0001_initial.sql 2020-03-12 03:51:16.768903+00
0002_join_accept_params.sql 2020-03-12 03:51:16.903019+00
0003_rx_window_and_rx2_dr.sql 2020-03-12 03:51:16.91646+00
0004_add_node_apps_nwks_key_name_devaddr.sql 2020-03-12 03:51:16.931897+00
0005_add_queue.sql 2020-03-12 03:51:17.022968+00
0006_remove_application_table.sql 2020-03-12 03:51:17.03712+00
0007_migrate_channels_to_channel_list.sql 2020-03-12 03:51:17.118142+00
0008_relax_fcnt.sql 2020-03-12 03:51:17.131956+00
0009_adr_interval_and_install_margin.sql 2020-03-12 03:51:17.140658+00
0010_recreate_application_table.sql 2020-03-12 03:51:17.311901+00
0011_node_description_and_is_abp.sql 2020-03-12 03:51:17.40017+00
0012_class_c_node.sql 2020-03-12 03:51:17.411283+00
0013_application_settings.sql 2020-03-12 03:51:17.445094+00
0014_users_and_application_users.sql 2020-03-12 03:51:18.012414+00
0015_organizations.sql 2020-03-12 03:51:18.317272+00
0016_delete_channel_list.sql 2020-03-12 03:51:18.344541+00
0017_integrations.sql 2020-03-12 03:51:18.447343+00
0018_gateway_ping.sql 2020-03-12 03:51:18.696466+00
0019_node_prefix_search.sql 2020-03-12 03:51:18.756188+00
0020_backend_interfaces.sql 2020-03-12 03:51:19.379006+00
0021_user_email_and_note.sql 2020-03-12 03:51:19.408395+00
0022_add_device_queue_mapping.sql 2020-03-12 03:51:19.483125+00
0023_payload_decoder.sql 2020-03-12 03:51:19.495443+00
0024_network_server_certs.sql 2020-03-12 03:51:19.520545+00
0025_device_status.sql 2020-03-12 03:51:19.529102+00
0026_network_server_gw_discovery.sql 2020-03-12 03:51:19.536941+00
0027_global_search.sql 2020-03-12 03:51:19.564497+00
0028_gateway_profile.sql 2020-03-12 03:51:19.680509+00
0029_cleanup_old_tables.sql 2020-03-12 03:51:19.755246+00
0030_lorawan_11_keys.sql 2020-03-12 03:51:19.776813+00
0031_cleanup_indices.sql 2020-03-12 03:51:19.794491+00
0032_fix_table_constraints.sql 2020-03-12 03:51:19.853668+00
0033_drop_device_queue_mapping.sql 2020-03-12 03:51:19.866709+00
0034_drop_nwk_session_keys.sql 2020-03-12 03:51:19.877711+00
0035_multicast.sql 2020-03-12 03:51:19.989885+00
0036_device_location.sql 2020-03-12 03:51:20.005838+00
0037_fix_device_status.sql 2020-03-12 03:51:20.127132+00
0038_device_profile_payload_codec.sql 2020-03-12 03:51:20.165374+00
0039_application_add_dr.sql 2020-03-12 03:51:20.172284+00
0040_fuota.sql 2020-03-12 03:51:20.621757+00
0041_device_variables.sql 2020-03-12 03:51:20.665709+00
0042_drop_multicast_f_cnt.sql 2020-03-12 03:51:20.676353+00
0043_extend_org_user_permissions.sql 2020-03-12 03:51:20.690788+00
0044_gateway_location_first_and_last_seen.sql 2020-03-12 03:51:20.709885+00
0045_code_migrations.sql 2020-03-12 03:51:20.767952+00
0046_devaddr_appskey_to_device.sql 2020-03-12 03:51:20.794563+00
0047_cleanup_device_activation.sql 2020-03-12 03:51:20.814716+00
0048_change_device_tags_index.sql 2020-03-12 03:51:20.833118+00
0049_gateway_tags_metadata.sql 2020-03-12 03:51:20.849362+00
0050_device_profile_tags.sql 2020-03-12 03:51:20.862966+00
\.
--
-- Data for Name: integration; Type: TABLE DATA; Schema: public; Owner: chirpstack_as
--
COPY public.integration (id, created_at, updated_at, application_id, kind, settings) FROM stdin;
\.
--
-- Data for Name: multicast_group; Type: TABLE DATA; Schema: public; Owner: chirpstack_as
--
COPY public.multicast_group (id, created_at, updated_at, name, service_profile_id, mc_app_s_key, mc_key) FROM stdin;
\.
--
-- Data for Name: network_server; Type: TABLE DATA; Schema: public; Owner: chirpstack_as
--
COPY public.network_server (id, created_at, updated_at, name, server, ca_cert, tls_cert, tls_key, routing_profile_ca_cert, routing_profile_tls_cert, routing_profile_tls_key, gateway_discovery_enabled, gateway_discovery_interval, gateway_discovery_tx_frequency, gateway_discovery_dr) FROM stdin;
1 2020-03-12 03:51:55.851734+00 2020-03-12 03:51:55.851734+00 build_in_ns 127.0.0.1:8000 f 0 0 0
\.
--
-- Data for Name: organization; Type: TABLE DATA; Schema: public; Owner: chirpstack_as
--
COPY public.organization (id, created_at, updated_at, name, display_name, can_have_gateways) FROM stdin;
1 2020-03-12 03:51:18.018387+00 2020-03-12 03:51:18.018387+00 chirpstack ChirpStack t
\.
--
-- Data for Name: organization_user; Type: TABLE DATA; Schema: public; Owner: chirpstack_as
--
COPY public.organization_user (id, created_at, updated_at, user_id, organization_id, is_admin, is_device_admin, is_gateway_admin) FROM stdin;
1 2020-03-12 03:51:18.018387+00 2020-03-12 03:51:18.018387+00 1 1 t f f
\.
--
-- Data for Name: remote_fragmentation_session; Type: TABLE DATA; Schema: public; Owner: chirpstack_as
--
COPY public.remote_fragmentation_session (dev_eui, frag_index, created_at, updated_at, mc_group_ids, nb_frag, frag_size, fragmentation_matrix, block_ack_delay, padding, descriptor, state, state_provisioned, retry_after, retry_count, retry_interval) FROM stdin;
\.
--
-- Data for Name: remote_multicast_class_c_session; Type: TABLE DATA; Schema: public; Owner: chirpstack_as