/
dagaz-bot.sql
5133 lines (3712 loc) · 134 KB
/
dagaz-bot.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 dump
--
-- Dumped from database version 11.1
-- Dumped by pg_dump version 11.1
-- Started on 2024-01-10 11:14:57
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 client_min_messages = warning;
SET row_security = off;
--
-- TOC entry 272 (class 1255 OID 1813623)
-- Name: addcommand(integer, integer); Type: FUNCTION; Schema: public; Owner: lora_server
--
CREATE FUNCTION public.addcommand(pcontext integer, paction integer) RETURNS integer
LANGUAGE plpgsql
AS $$
declare
r integer;
begin
insert into command_queue(context_id, action_id)
values (pContext, pAction)
returning id into r;
return r;
end;
$$;
ALTER FUNCTION public.addcommand(pcontext integer, paction integer) OWNER TO lora_server;
--
-- TOC entry 287 (class 1255 OID 1810140)
-- Name: chooseaccount(integer, text, integer); Type: FUNCTION; Schema: public; Owner: dagaz
--
CREATE FUNCTION public.chooseaccount(puser integer, paccount text, pserver integer) RETURNS json
LANGUAGE plpgsql STABLE
AS $$
declare
r json;
x record;
lAccount text default null;
lPass text default null;
begin
select string_agg(b.value, ',') into lAccount
from account a
inner join user_param b on (b.account_id = a.id and b.type_id = 2)
where a.user_id = pUser and a.server_id = pServer and a.deleted is null
and coalesce(pAccount, b.value) = b.value;
if not lAccount is null then
select e.value as pass into lPass
from account c
inner join user_param d on (d.account_id = c.id and d.type_id = 2 and d.value = lAccount)
inner join user_param e on (e.account_id = c.id and e.type_id = 3);
end if;
for x in
select case
when lAccount is null then 0
when strpos(lAccount, ',') = 0 then 1
else 2
end as result, lAccount as login, lPass as password
loop
r := row_to_json(x);
end loop;
return r;
end;
$$;
ALTER FUNCTION public.chooseaccount(puser integer, paccount text, pserver integer) OWNER TO dagaz;
--
-- TOC entry 273 (class 1255 OID 1828710)
-- Name: clearactivity(integer); Type: FUNCTION; Schema: public; Owner: lora_server
--
CREATE FUNCTION public.clearactivity(pid integer) RETURNS integer
LANGUAGE plpgsql
AS $$
begin
delete from command_param
where command_id in ( select id from command_queue where context_id = pId );
delete from command_queue where context_id = pId;
update common_context set action_id = null, wait_for = null, scheduled = null, delete_message = null
where id = pId;
end;
$$;
ALTER FUNCTION public.clearactivity(pid integer) OWNER TO lora_server;
--
-- TOC entry 289 (class 1255 OID 1810141)
-- Name: createaccount(integer, integer); Type: FUNCTION; Schema: public; Owner: dagaz
--
CREATE FUNCTION public.createaccount(puser integer, pserver integer) RETURNS json
LANGUAGE plpgsql
AS $$
declare
pLogin text;
pAccount integer default null;
r json;
x record;
begin
select value into strict pLogin
from user_param
where user_id = pUser and type_id = 2;
select max(a.id) into pAccount
from account a
inner join user_param b on (b.account_id = a.id)
where a.user_id = pUser and b.value = pLogin;
if pAccount is null then
insert into account(user_id, server_id)
values (pUser, pServer)
returning id into pAccount;
else
delete from user_param
where account_id = pAccount and type_id in (2, 3, 4);
end if;
update user_param set account_id = pAccount, user_id = null
where user_id = pUser and type_id in (2, 3, 4);
for x in
select 1 result, pAccount as id
loop
r := row_to_json(x);
end loop;
return r;
end;
$$;
ALTER FUNCTION public.createaccount(puser integer, pserver integer) OWNER TO dagaz;
--
-- TOC entry 290 (class 1255 OID 1810142)
-- Name: createuser(text, bigint, text, text, text); Type: FUNCTION; Schema: public; Owner: dagaz
--
CREATE FUNCTION public.createuser(plogin text, pchatid bigint, pfirst text, plast text, plocale text) RETURNS integer
LANGUAGE plpgsql
AS $$
declare
lUser integer;
lCn integer;
lCtx integer default null;
begin
select max(id), max(context_id) into lUser, lCtx from users where username = pLogin;
if lCtx is null then
insert into common_context default values
returning id into lCtx;
end if;
if not lUser is null then
update users set updated = now(), firstname = pFirst, lastname = pLast, chat_id = pChatId
where id = lUser;
else
insert into users (username, firstname, lastname, chat_id, context_id)
values (pLogin, pFirst, pLast, pChatId, lCtx)
returning id into lUser;
end if;
update user_param set created = now(), value = pLocale where user_id = lUser and type_id = 7;
get diagnostics lCn = row_count;
if lCn = 0 then
insert into user_param(type_id, user_id, value)
values (7, lUser, pLocale);
end if;
insert into command_queue(context_id, action_id) values (lCtx, 201);
return lUser;
end;
$$;
ALTER FUNCTION public.createuser(plogin text, pchatid bigint, pfirst text, plast text, plocale text) OWNER TO dagaz;
--
-- TOC entry 291 (class 1255 OID 1810143)
-- Name: createuser(text, bigint, bigint, text, text, text); Type: FUNCTION; Schema: public; Owner: dagaz
--
CREATE FUNCTION public.createuser(plogin text, puserid bigint, pchatid bigint, pfirst text, plast text, plocale text) RETURNS integer
LANGUAGE plpgsql
AS $$
declare
lUser integer;
lCn integer;
lCtx integer default null;
begin
select max(id), max(context_id) into lUser, lCtx from users where username = pLogin;
if lCtx is null then
insert into common_context default values
returning id into lCtx;
end if;
if not lUser is null then
update users set updated = now(), firstname = pFirst, lastname = pLast, chat_id = pChatId, user_id = pUserId
where id = lUser;
else
insert into users (username, firstname, lastname, chat_id, user_id, context_id)
values (pLogin, pFirst, pLast, pChatId, pUserId, lCtx)
returning id into lUser;
end if;
update user_param set created = now(), value = pLocale where user_id = lUser and type_id = 7;
get diagnostics lCn = row_count;
if lCn = 0 then
insert into user_param(type_id, user_id, value)
values (7, lUser, pLocale);
end if;
insert into command_queue(context_id, action_id) values (lCtx, 201);
return lUser;
end;
$$;
ALTER FUNCTION public.createuser(plogin text, puserid bigint, pchatid bigint, pfirst text, plast text, plocale text) OWNER TO dagaz;
--
-- TOC entry 274 (class 1255 OID 1810144)
-- Name: enterurl(integer, integer); Type: FUNCTION; Schema: public; Owner: dagaz
--
CREATE FUNCTION public.enterurl(puser integer, pserver integer) RETURNS json
LANGUAGE plpgsql
AS $$
declare
lToken text default null;
lUrl text default null;
r json;
x record;
begin
select value into lToken
from user_param
where user_id = pUser and type_id = 11;
select url into lUrl
from server
where id = pServer;
for x in
select lUrl || '/redirect/' || lToken as url,
case
when lUrl is null or lToken is null then 0
else 1
end as result
loop
r := row_to_json(x);
end loop;
delete from user_param where user_id = pUser and type_id in (2, 3, 11);
return r;
end;
$$;
ALTER FUNCTION public.enterurl(puser integer, pserver integer) OWNER TO dagaz;
--
-- TOC entry 292 (class 1255 OID 1810145)
-- Name: gameurl(integer, integer); Type: FUNCTION; Schema: public; Owner: dagaz
--
CREATE FUNCTION public.gameurl(puser integer, pserver integer) RETURNS json
LANGUAGE plpgsql
AS $$
declare
lToken text default null;
lUrl text default null;
lData text;
lPlayer text;
r json;
x record;
begin
select value into lToken from user_param where user_id = pUser and type_id = 11;
select value into lData from user_param where user_id = pUser and type_id = 8;
select url into lUrl from server where id = pServer;
lPlayer := split_part(lData, ',', 2);
for x in
select lUrl || '/redirect/' || lToken || '/' || split_part(lData, ',', 3) || '/' || split_part(lData, ',', 4) as url,
lPlayer as player,
case
when lUrl is null or lToken is null then 0
else 1
end as result
loop
r := row_to_json(x);
end loop;
delete from user_param where user_id = pUser and type_id in (2, 3, 11);
return r;
end;
$$;
ALTER FUNCTION public.gameurl(puser integer, pserver integer) OWNER TO dagaz;
--
-- TOC entry 298 (class 1255 OID 1810146)
-- Name: getcommands(); Type: FUNCTION; Schema: public; Owner: dagaz
--
CREATE FUNCTION public.getcommands() RETURNS integer
LANGUAGE plpgsql
AS $$
declare
z record;
t record;
r integer default 0;
begin
for z in
select x.id, x.context_id, x.user_id, x.action_id, x.created, x.data
from ( select b.id, a.context_id, a.id as user_id, b.created, b.action_id, b.data,
row_number() over (partition by b.context_id order by b.created) as rn
from common_context c
inner join users a on (a.context_id = c.id)
inner join command_queue b on (b.context_id = c.id)
where c.action_id is null ) x
where x.rn = 1
order by x.created
loop
update common_context set action_id = z.action_id, scheduled = now()
where id = z.context_id;
delete from user_param where user_id = z.user_id
and type_id in ( select paramtype_id
from clear_params
where coalesce(action_id, z.action_id) = z.action_id);
if not z.data is null then
insert into user_param(type_id, user_id, value)
values (8, z.user_id, z.data);
end if;
for t in
select paramtype_id, value
from command_param
where command_id = z.id
loop
insert into user_param(user_id, type_id, value)
values (z.user_id, t.paramtype_id, t.value);
end loop;
delete from command_param where command_id = z.id;
delete from command_queue where id = z.id;
r := r + 1;
end loop;
return r;
end;
$$;
ALTER FUNCTION public.getcommands() OWNER TO dagaz;
--
-- TOC entry 293 (class 1255 OID 1810147)
-- Name: getnotify(integer, integer); Type: FUNCTION; Schema: public; Owner: dagaz
--
CREATE FUNCTION public.getnotify(pid integer, pserver integer) RETURNS integer
LANGUAGE plpgsql
AS $$
declare
x record;
z record;
s text;
u text;
c integer;
lCommand integer;
begin
select url into strict u from server where id = pServer;
for x in
select id, data->>'user' as username, data->>'sid' as sid,
data->>'url' as url, data->>'opponent' as player
from job_data
where job_id = pId and result_code = 200 and not data is null
and server_id = pServer
order by created
loop
for z in
select y.id as context_id, a.user_id, c.value as pass
from account a
inner join users u on (u.id = a.user_id)
inner join common_context y on (y.id = u.context_id)
inner join user_param b on (b.account_id = a.id and b.type_id = 2)
inner join user_param c on (c.account_id = a.id and c.type_id = 3)
where b.value = x.username and a.deleted is null
loop
s := u || ',' || x.player || ',' || x.url || ',' || x.sid;
insert into command_queue(context_id, action_id, data)
values (z.context_id, 101, s)
returning id into lCommand;
insert into command_param(command_id, paramtype_id, value)
values(lCommand, 2, x.username);
insert into command_param(command_id, paramtype_id, value)
values(lCommand, 3, z.pass);
end loop;
delete from job_data where id = x.id;
end loop;
return 1;
end;
$$;
ALTER FUNCTION public.getnotify(pid integer, pserver integer) OWNER TO dagaz;
--
-- TOC entry 294 (class 1255 OID 1810148)
-- Name: savemessage(text, bigint, text, bigint); Type: FUNCTION; Schema: public; Owner: dagaz
--
CREATE FUNCTION public.savemessage(plogin text, pid bigint, pdata text, preply bigint) RETURNS json
LANGUAGE plpgsql
AS $$
declare
z record;
c integer;
begin
for z in
select a.id, coalesce(b.value, 'en') as locale
from users a
left join user_param b on (b.user_id = a.id and type_id = 7)
where a.username = pLogin
loop
insert into message(user_id, locale, message_id, data, reply_for)
values (z.id, z.locale, pId, pData, pReply);
c := c + 1;
end loop;
return c;
end;
$$;
ALTER FUNCTION public.savemessage(plogin text, pid bigint, pdata text, preply bigint) OWNER TO dagaz;
--
-- TOC entry 297 (class 1255 OID 1811067)
-- Name: saveprofile(integer, text, integer); Type: FUNCTION; Schema: public; Owner: lora_server
--
CREATE FUNCTION public.saveprofile(puser integer, paccount text, pserver integer) RETURNS json
LANGUAGE plpgsql
AS $$
declare
lAccount integer;
r json;
x record;
begin
select a.id into strict lAccount
from account a
inner join user_param b on (b.account_id = a.id and b.type_id = 2)
where a.user_id = pUser and a.server_id = pServer and a.deleted is null
and pAccount = b.value;
delete from user_param where account_id = lAccount and type_id in (4, 3);
update user_param set account_id = lAccount, user_id = null where user_id = pUser and type_id = 4;
update user_param set account_id = lAccount, user_id = null, type_id = 3 where user_id = pUser and type_id = 12;
for x in
select 1 as result
loop
r := row_to_json(x);
end loop;
return r;
end;
$$;
ALTER FUNCTION public.saveprofile(puser integer, paccount text, pserver integer) OWNER TO lora_server;
--
-- TOC entry 295 (class 1255 OID 1810149)
-- Name: setactionbynum(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: dagaz
--
CREATE FUNCTION public.setactionbynum(puser integer, paction integer, pnum integer) RETURNS integer
LANGUAGE plpgsql
AS $$
declare
z record;
c integer;
lCtx integer;
begin
select context_id into strict lCtx
from users where id = pUser;
for z in
select a.id
from action a
where a.parent_id = pAction and a.order_num = pNum
loop
update common_context set scheduled = now(), updated = now(), action_id = z.id
where id = lCtx;
c := c + 1;
end loop;
return c;
end;
$$;
ALTER FUNCTION public.setactionbynum(puser integer, paction integer, pnum integer) OWNER TO dagaz;
--
-- TOC entry 288 (class 1255 OID 1810150)
-- Name: setparams(); Type: FUNCTION; Schema: public; Owner: dagaz
--
CREATE FUNCTION public.setparams() RETURNS integer
LANGUAGE plpgsql
AS $$
declare
z record;
q record;
c integer default 0;
p integer;
n integer;
a integer;
s timestamp;
begin
for z in
select a.id as user_id, b.id, b.paramtype_id, d.message,
x.id as context_id
from users a
inner join common_context x on (x.id = a.context_id)
inner join action b on (b.id = x.action_id and b.type_id = 5)
inner join localized_string d on (d.action_id = b.id and d.locale = 'en')
where x.scheduled < now()
order by x.scheduled
loop
update user_param set created = now(), value = z.message
where user_id = z.user_id and type_id = z.paramtype_id;
get diagnostics n = row_count;
if n = 0 then
insert into user_param(type_id, user_id, value)
values (z.paramtype_id, z.user_id, z.message);
end if;
a := null;
for q in
select a.script_id, coalesce(a.parent_id, 0) as parent_id, a.order_num
from action a
where a.id = z.id
loop
select max(t.id) into a
from ( select a.id, row_number() over (order by a.order_num) as rn
from action a
where a.script_id = q.script_id
and coalesce(a.parent_id, 0) = q.parent_id
and a.order_num > q.order_num ) t
where t.rn = 1;
if a is null then
select max(t.id) into a
from ( select a.id, row_number() over (order by a.order_num) as rn
from action a
where a.script_id = q.script_id
and coalesce(a.parent_id, 0) = z.id ) t
where t.rn = 1;
end if;
end loop;
s := now();
if a is null then
s := null;
end if;
update common_context set scheduled = s, updated = now(), action_id = a
where id = z.context_id;
c := c + 1;
end loop;
return c;
end;
$$;
ALTER FUNCTION public.setparams() OWNER TO dagaz;
--
-- TOC entry 296 (class 1255 OID 1810151)
-- Name: setparamvalue(integer, integer, text); Type: FUNCTION; Schema: public; Owner: dagaz
--
CREATE FUNCTION public.setparamvalue(puser integer, pcode integer, pvalue text) RETURNS integer
LANGUAGE plpgsql
AS $$
declare
n integer;
begin
update user_param set created = now(), value = pValue
where user_id = pUser and type_id = pCode;
get diagnostics n = row_count;
if n = 0 then
insert into user_param(type_id, user_id, value)
values (pCode, pUser, pValue);
end if;
return n;
end;
$$;
ALTER FUNCTION public.setparamvalue(puser integer, pcode integer, pvalue text) OWNER TO dagaz;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 196 (class 1259 OID 1810152)
-- Name: account; Type: TABLE; Schema: public; Owner: dagaz
--
CREATE TABLE public.account (
id integer NOT NULL,
server_id integer NOT NULL,
user_id integer NOT NULL,
created timestamp without time zone DEFAULT now() NOT NULL,
deleted timestamp without time zone,
context_id integer
);
ALTER TABLE public.account OWNER TO dagaz;
--
-- TOC entry 197 (class 1259 OID 1810156)
-- Name: account_id_seq; Type: SEQUENCE; Schema: public; Owner: dagaz
--
CREATE SEQUENCE public.account_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.account_id_seq OWNER TO dagaz;
--
-- TOC entry 4351 (class 0 OID 0)
-- Dependencies: 197
-- Name: account_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dagaz
--
ALTER SEQUENCE public.account_id_seq OWNED BY public.account.id;
--
-- TOC entry 198 (class 1259 OID 1810158)
-- Name: action; Type: TABLE; Schema: public; Owner: dagaz
--
CREATE TABLE public.action (
id integer NOT NULL,
type_id integer NOT NULL,
script_id integer NOT NULL,
parent_id integer,
order_num integer NOT NULL,
follow_to integer,
paramtype_id integer
);
ALTER TABLE public.action OWNER TO dagaz;
--
-- TOC entry 271 (class 1259 OID 1836315)
-- Name: action_param; Type: TABLE; Schema: public; Owner: dagaz
--
CREATE TABLE public.action_param (
id integer NOT NULL,
action_id integer NOT NULL,
type_id integer NOT NULL,
value integer NOT NULL,
paramtype_id integer
);
ALTER TABLE public.action_param OWNER TO dagaz;
--
-- TOC entry 199 (class 1259 OID 1810167)
-- Name: action_type; Type: TABLE; Schema: public; Owner: dagaz
--
CREATE TABLE public.action_type (
id integer NOT NULL,
name character varying(100) NOT NULL
);
ALTER TABLE public.action_type OWNER TO dagaz;
--
-- TOC entry 268 (class 1259 OID 1813504)
-- Name: clear_params; Type: TABLE; Schema: public; Owner: dagaz
--
CREATE TABLE public.clear_params (
id integer NOT NULL,
paramtype_id integer NOT NULL,
action_id integer
);
ALTER TABLE public.clear_params OWNER TO dagaz;
--
-- TOC entry 200 (class 1259 OID 1810170)
-- Name: client_message; Type: TABLE; Schema: public; Owner: dagaz
--
CREATE TABLE public.client_message (
id integer NOT NULL,
parent_id integer NOT NULL,
message_id bigint NOT NULL
);
ALTER TABLE public.client_message OWNER TO dagaz;
--
-- TOC entry 201 (class 1259 OID 1810173)
-- Name: client_message_id_seq; Type: SEQUENCE; Schema: public; Owner: dagaz
--
CREATE SEQUENCE public.client_message_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.client_message_id_seq OWNER TO dagaz;
--
-- TOC entry 4352 (class 0 OID 0)
-- Dependencies: 201
-- Name: client_message_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dagaz
--
ALTER SEQUENCE public.client_message_id_seq OWNED BY public.client_message.id;
--
-- TOC entry 270 (class 1259 OID 1813570)
-- Name: command_param; Type: TABLE; Schema: public; Owner: dagaz
--
CREATE TABLE public.command_param (
id integer NOT NULL,
command_id integer NOT NULL,
paramtype_id integer NOT NULL,
value text NOT NULL
);
ALTER TABLE public.command_param OWNER TO dagaz;
--
-- TOC entry 269 (class 1259 OID 1813568)
-- Name: command_param_id_seq; Type: SEQUENCE; Schema: public; Owner: dagaz
--
CREATE SEQUENCE public.command_param_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.command_param_id_seq OWNER TO dagaz;
--
-- TOC entry 4353 (class 0 OID 0)
-- Dependencies: 269
-- Name: command_param_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dagaz
--
ALTER SEQUENCE public.command_param_id_seq OWNED BY public.command_param.id;
--
-- TOC entry 202 (class 1259 OID 1810175)
-- Name: command_queue; Type: TABLE; Schema: public; Owner: dagaz
--
CREATE TABLE public.command_queue (
id integer NOT NULL,
context_id integer NOT NULL,
action_id integer NOT NULL,
created timestamp without time zone DEFAULT now() NOT NULL,
data text
);
ALTER TABLE public.command_queue OWNER TO dagaz;
--
-- TOC entry 203 (class 1259 OID 1810182)
-- Name: command_queue_id_seq; Type: SEQUENCE; Schema: public; Owner: dagaz
--
CREATE SEQUENCE public.command_queue_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.command_queue_id_seq OWNER TO dagaz;
--
-- TOC entry 4354 (class 0 OID 0)
-- Dependencies: 203
-- Name: command_queue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dagaz
--
ALTER SEQUENCE public.command_queue_id_seq OWNED BY public.command_queue.id;
--
-- TOC entry 204 (class 1259 OID 1810184)
-- Name: common_context; Type: TABLE; Schema: public; Owner: dagaz
--
CREATE TABLE public.common_context (
id integer NOT NULL,
action_id integer,
wait_for integer,
scheduled timestamp without time zone,
delete_message bigint,
updated timestamp without time zone DEFAULT now() NOT NULL
);
ALTER TABLE public.common_context OWNER TO dagaz;
--
-- TOC entry 205 (class 1259 OID 1810188)
-- Name: common_context_id_seq; Type: SEQUENCE; Schema: public; Owner: dagaz
--
CREATE SEQUENCE public.common_context_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.common_context_id_seq OWNER TO dagaz;
--
-- TOC entry 4355 (class 0 OID 0)
-- Dependencies: 205
-- Name: common_context_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dagaz
--
ALTER SEQUENCE public.common_context_id_seq OWNED BY public.common_context.id;
--
-- TOC entry 206 (class 1259 OID 1810190)
-- Name: db_action; Type: TABLE; Schema: public; Owner: dagaz
--
CREATE TABLE public.db_action (
id integer NOT NULL,
result_id integer NOT NULL,
result_value character varying(30) NOT NULL,
order_num integer NOT NULL,
action_id integer
);
ALTER TABLE public.db_action OWNER TO dagaz;
--
-- TOC entry 207 (class 1259 OID 1810193)
-- Name: db_param; Type: TABLE; Schema: public; Owner: dagaz
--
CREATE TABLE public.db_param (
id integer NOT NULL,
proc_id integer NOT NULL,
paramtype_id integer,
value character varying(30),
order_num integer NOT NULL
);
ALTER TABLE public.db_param OWNER TO dagaz;
--
-- TOC entry 208 (class 1259 OID 1810196)
-- Name: db_result; Type: TABLE; Schema: public; Owner: dagaz
--
CREATE TABLE public.db_result (
id integer NOT NULL,
proc_id integer NOT NULL,
name character varying(30),
paramtype_id integer
);
ALTER TABLE public.db_result OWNER TO dagaz;
--
-- TOC entry 209 (class 1259 OID 1810199)
-- Name: dbproc; Type: TABLE; Schema: public; Owner: dagaz
--
CREATE TABLE public.dbproc (
id integer NOT NULL,
actiontype_id integer,
name character varying(100) NOT NULL
);
ALTER TABLE public.dbproc OWNER TO dagaz;
--
-- TOC entry 210 (class 1259 OID 1810202)
-- Name: edge; Type: TABLE; Schema: public; Owner: dagaz
--
CREATE TABLE public.edge (
id integer NOT NULL,
quest_id integer NOT NULL,
from_id integer NOT NULL,
to_id integer NOT NULL,
en text,
ru text,
rule character varying(100),
max_cnt integer,
order_num integer NOT NULL
);
ALTER TABLE public.edge OWNER TO dagaz;
--
-- TOC entry 211 (class 1259 OID 1810208)
-- Name: edge_cnt; Type: TABLE; Schema: public; Owner: dagaz
--
CREATE TABLE public.edge_cnt (
id integer NOT NULL,
edge_id integer NOT NULL,
context_id integer NOT NULL,
max_cnt integer DEFAULT 0 NOT NULL
);
ALTER TABLE public.edge_cnt OWNER TO dagaz;
--
-- TOC entry 212 (class 1259 OID 1810212)
-- Name: edge_cnt_id_seq; Type: SEQUENCE; Schema: public; Owner: dagaz
--
CREATE SEQUENCE public.edge_cnt_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.edge_cnt_id_seq OWNER TO dagaz;
--
-- TOC entry 4356 (class 0 OID 0)
-- Dependencies: 212
-- Name: edge_cnt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dagaz
--
ALTER SEQUENCE public.edge_cnt_id_seq OWNED BY public.edge_cnt.id;
--
-- TOC entry 213 (class 1259 OID 1810214)
-- Name: edge_id_seq; Type: SEQUENCE; Schema: public; Owner: dagaz
--
CREATE SEQUENCE public.edge_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.edge_id_seq OWNER TO dagaz;