-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv1.0.sql
776 lines (719 loc) · 27.4 KB
/
v1.0.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
-- Database generated with pgModeler (PostgreSQL Database Modeler).
-- pgModeler version: 1.2.0-alpha
-- PostgreSQL version: 16.0
-- Project Site: pgmodeler.io
-- Model Author: ---
-- Database creation must be performed outside a multi lined SQL file.
-- These commands were put in this file only as a convenience.
--
-- -- object: riding | type: DATABASE --
-- -- DROP DATABASE IF EXISTS riding;
-- CREATE DATABASE riding;
-- -- ddl-end --
--
-- object: public.users | type: TABLE --
-- DROP TABLE IF EXISTS public.users CASCADE;
CREATE TABLE public.users (
id serial NOT NULL,
password varchar(255) NOT NULL,
email varchar(255),
user_name varchar(100) NOT NULL,
created_at timestamp NOT NULL,
login_fail_count smallint NOT NULL DEFAULT 0,
last_location point,
refresh_token varchar(255),
role varchar(10) NOT NULL,
fcm_token varchar(255),
id_user_type integer,
CONSTRAINT users_pk PRIMARY KEY (id)
);
-- ddl-end --
COMMENT ON COLUMN public.users.id IS E'primary key';
-- ddl-end --
COMMENT ON COLUMN public.users.password IS E'user password';
-- ddl-end --
COMMENT ON COLUMN public.users.login_fail_count IS E'user login fail count';
-- ddl-end --
COMMENT ON COLUMN public.users.last_location IS E'user last location coordinates';
-- ddl-end --
COMMENT ON COLUMN public.users.role IS E'유저 권한';
-- ddl-end --
COMMENT ON COLUMN public.users.fcm_token IS E'Firebase Cloud Messaging 토큰';
-- ddl-end --
ALTER TABLE public.users OWNER TO postgres;
-- ddl-end --
-- object: public.bedge | type: TABLE --
-- DROP TABLE IF EXISTS public.bedge CASCADE;
CREATE TABLE public.bedge (
id serial NOT NULL,
name varchar(100) NOT NULL,
decription text,
CONSTRAINT bedge_pk PRIMARY KEY (id)
);
-- ddl-end --
COMMENT ON COLUMN public.bedge.id IS E'user bedget list';
-- ddl-end --
COMMENT ON COLUMN public.bedge.decription IS E'user bedge description';
-- ddl-end --
ALTER TABLE public.bedge OWNER TO postgres;
-- ddl-end --
-- object: public.user_bedge | type: TABLE --
-- DROP TABLE IF EXISTS public.user_bedge CASCADE;
CREATE TABLE public.user_bedge (
fk_user_id bigint NOT NULL,
fk_bedge_id bigint NOT NULL,
id_users integer NOT NULL,
id_bedge integer,
CONSTRAINT user_bedge_pk PRIMARY KEY (fk_user_id,fk_bedge_id,id_users)
);
-- ddl-end --
ALTER TABLE public.user_bedge OWNER TO postgres;
-- ddl-end --
-- object: users_fk | type: CONSTRAINT --
-- ALTER TABLE public.user_bedge DROP CONSTRAINT IF EXISTS users_fk CASCADE;
ALTER TABLE public.user_bedge ADD CONSTRAINT users_fk FOREIGN KEY (id_users)
REFERENCES public.users (id) MATCH FULL
ON DELETE CASCADE ON UPDATE CASCADE;
-- ddl-end --
-- object: bedge_fk | type: CONSTRAINT --
-- ALTER TABLE public.user_bedge DROP CONSTRAINT IF EXISTS bedge_fk CASCADE;
ALTER TABLE public.user_bedge ADD CONSTRAINT bedge_fk FOREIGN KEY (id_bedge)
REFERENCES public.bedge (id) MATCH FULL
ON DELETE SET NULL ON UPDATE CASCADE;
-- ddl-end --
-- object: public.pharmacy_info | type: TABLE --
-- DROP TABLE IF EXISTS public.pharmacy_info CASCADE;
CREATE TABLE public.pharmacy_info (
id serial NOT NULL,
CONSTRAINT pharmacy_info_pk PRIMARY KEY (id)
);
-- ddl-end --
ALTER TABLE public.pharmacy_info OWNER TO postgres;
-- ddl-end --
-- object: public.restaurant_info | type: TABLE --
-- DROP TABLE IF EXISTS public.restaurant_info CASCADE;
CREATE TABLE public.restaurant_info (
id serial NOT NULL,
CONSTRAINT restaurant_info_pk PRIMARY KEY (id)
);
-- ddl-end --
ALTER TABLE public.restaurant_info OWNER TO postgres;
-- ddl-end --
-- object: public.bicycle_route | type: TABLE --
-- DROP TABLE IF EXISTS public.bicycle_route CASCADE;
CREATE TABLE public.bicycle_route (
id serial NOT NULL,
CONSTRAINT bicycle_route_pk PRIMARY KEY (id)
);
-- ddl-end --
ALTER TABLE public.bicycle_route OWNER TO postgres;
-- ddl-end --
-- object: public.standard_veh_link | type: TABLE --
-- DROP TABLE IF EXISTS public.standard_veh_link CASCADE;
CREATE TABLE public.standard_veh_link (
id serial NOT NULL,
geom geometry(MULTILINESTRING),
link_id varchar(10),
f_node varchar(10),
t_node varchar(10),
lanes int4,
road_rank varchar(3),
route_type varchar(3),
road_no varchar(5),
road_name varchar(30),
road_use varchar(1),
multi_link varchar(1),
connect varchar(3),
max_spd int4,
rest_veh varchar(3),
rest_w int4,
rest_h int4,
"c-its" varchar(1),
length float8,
updatedate varchar(8),
remark varchar(30),
hist_type varchar(8),
histremark varchar(30),
CONSTRAINT constraint_primary_key PRIMARY KEY (id)
);
-- ddl-end --
COMMENT ON TABLE public.standard_veh_link IS E'국토부 표준 차도 링크 테이블';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_link.geom IS E'geometry 정보';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_link.link_id IS E'링크 아이디';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_link.f_node IS E'시작 노드';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_link.t_node IS E'종료 노드';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_link.lanes IS E'차로 수';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_link.road_rank IS E'*도로 등급 코드\n\n- 101 : 고속 국도\n- 102 : 도시 고속 국도\n- 103 : 일반 국도\n- 104 : 특별.광역시도\n- 105 : 국가 지원 지방도\n- 106 : 지방도\n- 107 : 시.군도\n- 108 : 기타';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_link.route_type IS E'*도로 유형 코드\n\n- 000 : 일반 국도\n- 001 : 고가 차도\n- 002 : 지하차도\n- 003 : 교량\n- 004 : 터널';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_link.road_use IS E'*사용 여부\n\n- 0 : 사용\n- 1 : 미사용';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_link.multi_link IS E'*중용구간 여부\n\n- 0 : 독립구간\n- 1 : 중용구간';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_link.connect IS E'*연결로 코드\n\n- 000 : 연결로 아님\n- 101 : 고속국도 연결로\n- 102 : 도시고속국도 연결로\n- 103 : 일반국도 연결로\n- 104 : 특별.광역시도 연결로\n- 105 : 국가지원지방도 연결로\n- 106 : 지방도 연결로\n- 107 : 시.군도 연결로\n- 108 : 기타도로 연결로';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_link.max_spd IS E'속도 제한';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_link.rest_veh IS E'*통과 제한 차량\n\n- 0 : 모든 차량 통행 가능\n- 1 : 승용차\n- 2 : 승합차\n- 3 : 버스 \n- 4 : 트럭\n- 5 : 이륜차\n- 6 : 기타차량';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_link.rest_w IS E'통과 제한 하중';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_link.rest_h IS E'통과 제한 높이';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_link."c-its" IS E'*c-its 적용 여부\n\n- 0 : 미적용\n- 1 : 적용';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_link.length IS E'링크 길이 (m)';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_link.updatedate IS E'업데이트 날짜 yyyyMMdd';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_link.remark IS E'비고';
-- ddl-end --
ALTER TABLE public.standard_veh_link OWNER TO postgres;
-- ddl-end --
-- object: public.standard_veh_node | type: TABLE --
-- DROP TABLE IF EXISTS public.standard_veh_node CASCADE;
CREATE TABLE public.standard_veh_node (
id serial NOT NULL,
geom geometry(POINT),
node_id varchar(10),
node_type varchar(3),
node_name varchar(30),
turn_p varchar(1),
updatedate varchar(8),
remark varchar(30),
hist_type varchar(8),
histremark varchar(30),
CONSTRAINT standard_veh_node_pk PRIMARY KEY (id)
);
-- ddl-end --
COMMENT ON TABLE public.standard_veh_node IS E'국토부 표준 차량 노드 테이블';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_node.geom IS E'geometry 정보';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_node.node_id IS E'노드 아이디';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_node.node_type IS E'* 노드 종류\n\n- 101 : 교차로\n- 102 : 도로 시.종점\n- 103 : 속성 변화점\n- 104 : 도로시설물\n- 105 : 행정 경계 \n- 106 : 연결로 접속부\n- 107 : IC 및 JC';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_node.node_name IS E'노드 명칭';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_node.turn_p IS E'* 회전 제한 유무\n\n- 0 : 무\n- 1 : 유';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_node.updatedate IS E'업데이트 날짜 (yyyyMMdd)';
-- ddl-end --
COMMENT ON COLUMN public.standard_veh_node.remark IS E'비고';
-- ddl-end --
ALTER TABLE public.standard_veh_node OWNER TO postgres;
-- ddl-end --
-- object: public.bicycle_route_link | type: TABLE --
-- DROP TABLE IF EXISTS public.bicycle_route_link CASCADE;
CREATE TABLE public.bicycle_route_link (
id serial NOT NULL,
CONSTRAINT bicycle_route_link_pk PRIMARY KEY (id)
);
-- ddl-end --
ALTER TABLE public.bicycle_route_link OWNER TO postgres;
-- ddl-end --
-- object: public.bicycle_route_node | type: TABLE --
-- DROP TABLE IF EXISTS public.bicycle_route_node CASCADE;
CREATE TABLE public.bicycle_route_node (
id serial NOT NULL,
CONSTRAINT bicycle_route_node_pk PRIMARY KEY (id)
);
-- ddl-end --
ALTER TABLE public.bicycle_route_node OWNER TO postgres;
-- ddl-end --
-- object: public.bookmark_track | type: TABLE --
-- DROP TABLE IF EXISTS public.bookmark_track CASCADE;
CREATE TABLE public.bookmark_track (
id serial NOT NULL,
id_bicycle_track bigint,
id_users integer,
created_at timestamp NOT NULL,
CONSTRAINT route_bookmark_pk PRIMARY KEY (id)
);
-- ddl-end --
COMMENT ON TABLE public.bookmark_track IS E'자전거 길 북마크 테이블';
-- ddl-end --
COMMENT ON COLUMN public.bookmark_track.created_at IS E'생성 날짜';
-- ddl-end --
ALTER TABLE public.bookmark_track OWNER TO postgres;
-- ddl-end --
-- object: public.bicycle_track_points | type: TABLE --
-- DROP TABLE IF EXISTS public.bicycle_track_points CASCADE;
CREATE TABLE public.bicycle_track_points (
id serial NOT NULL,
geometry geometry(POINT) NOT NULL,
ele float4,
created_at timestamp NOT NULL,
id_bicycle_track bigint NOT NULL,
CONSTRAINT bicycle_track_points_pk PRIMARY KEY (id,id_bicycle_track)
);
-- ddl-end --
COMMENT ON TABLE public.bicycle_track_points IS E'자전거 종주길 경로를 생성하기 위한 좌표 테이블';
-- ddl-end --
COMMENT ON COLUMN public.bicycle_track_points.geometry IS E'종주길 경로 좌표';
-- ddl-end --
COMMENT ON COLUMN public.bicycle_track_points.ele IS E'해당 좌표점 고도';
-- ddl-end --
ALTER TABLE public.bicycle_track_points OWNER TO postgres;
-- ddl-end --
-- object: public.bicycle_track | type: TABLE --
-- DROP TABLE IF EXISTS public.bicycle_track CASCADE;
CREATE TABLE public.bicycle_track (
id bigserial NOT NULL,
name varchar(100),
length float4,
riding_time interval,
geom geometry(LINESTRING) NOT NULL,
id_users integer,
CONSTRAINT bicycle_track_pk PRIMARY KEY (id)
);
-- ddl-end --
COMMENT ON TABLE public.bicycle_track IS E'자전거 종주길 테이블';
-- ddl-end --
COMMENT ON COLUMN public.bicycle_track.name IS E'종주길 명칭';
-- ddl-end --
COMMENT ON COLUMN public.bicycle_track.length IS E'자전거 종주길 거리 (m)';
-- ddl-end --
COMMENT ON COLUMN public.bicycle_track.riding_time IS E'예상 이동 시간';
-- ddl-end --
ALTER TABLE public.bicycle_track OWNER TO postgres;
-- ddl-end --
-- object: public.bicycle_track_waypoint | type: TABLE --
-- DROP TABLE IF EXISTS public.bicycle_track_waypoint CASCADE;
CREATE TABLE public.bicycle_track_waypoint (
id serial NOT NULL,
CONSTRAINT bicycle_track_waypoint_pk PRIMARY KEY (id)
);
-- ddl-end --
COMMENT ON TABLE public.bicycle_track_waypoint IS E'자전거 종주길에 포함 웨이 포인트 매핑 테이블';
-- ddl-end --
ALTER TABLE public.bicycle_track_waypoint OWNER TO postgres;
-- ddl-end --
-- object: public.bicycle_waypoint | type: TABLE --
-- DROP TABLE IF EXISTS public.bicycle_waypoint CASCADE;
CREATE TABLE public.bicycle_waypoint (
id serial NOT NULL,
name varchar(100),
geometry geometry(POINT),
id_bicycle_track bigint NOT NULL,
CONSTRAINT bicycle_certification_center_pk PRIMARY KEY (id,id_bicycle_track)
);
-- ddl-end --
COMMENT ON TABLE public.bicycle_waypoint IS E'자전거길 웨이 포인트 ( 인증 센터 등 )';
-- ddl-end --
ALTER TABLE public.bicycle_waypoint OWNER TO postgres;
-- ddl-end --
-- object: public.friends | type: TABLE --
-- DROP TABLE IF EXISTS public.friends CASCADE;
CREATE TABLE public.friends (
id serial NOT NULL,
created_at timestamp,
from_user_id integer,
to_user_id integer,
id_users integer NOT NULL,
CONSTRAINT friends_pk PRIMARY KEY (id,id_users)
);
-- ddl-end --
COMMENT ON TABLE public.friends IS E'친구 테이블';
-- ddl-end --
COMMENT ON COLUMN public.friends.created_at IS E'생성일';
-- ddl-end --
ALTER TABLE public.friends OWNER TO postgres;
-- ddl-end --
-- object: public.riding_group | type: TABLE --
-- DROP TABLE IF EXISTS public.riding_group CASCADE;
CREATE TABLE public.riding_group (
id serial NOT NULL,
description text,
created_at timestamp,
CONSTRAINT riding_group_pk PRIMARY KEY (id)
);
-- ddl-end --
COMMENT ON TABLE public.riding_group IS E'라이딩 그룹 ( 동호회 등 ) 테이블';
-- ddl-end --
COMMENT ON COLUMN public.riding_group.description IS E'라이딩 그룹 소개글';
-- ddl-end --
COMMENT ON COLUMN public.riding_group.created_at IS E'생성일';
-- ddl-end --
ALTER TABLE public.riding_group OWNER TO postgres;
-- ddl-end --
-- object: public.riding | type: TABLE --
-- DROP TABLE IF EXISTS public.riding CASCADE;
CREATE TABLE public.riding (
id serial NOT NULL,
title varchar(100),
created_at timestamp NOT NULL,
start_dt date NOT NULL,
end_dt date NOT NULL,
max_people_num smallint,
description text,
visibility smallint NOT NULL,
CONSTRAINT riding_pk PRIMARY KEY (id)
);
-- ddl-end --
COMMENT ON TABLE public.riding IS E'라이딩 일정 테이블 -- track 테이블을 참조 해야 한다.';
-- ddl-end --
COMMENT ON COLUMN public.riding.title IS E'제목';
-- ddl-end --
COMMENT ON COLUMN public.riding.created_at IS E'생성일';
-- ddl-end --
COMMENT ON COLUMN public.riding.start_dt IS E'시작일';
-- ddl-end --
COMMENT ON COLUMN public.riding.end_dt IS E'종료일';
-- ddl-end --
COMMENT ON COLUMN public.riding.max_people_num IS E'최대 참여 인원';
-- ddl-end --
COMMENT ON COLUMN public.riding.description IS E'해당 라이딩 일정 설명';
-- ddl-end --
COMMENT ON COLUMN public.riding.visibility IS E'게시물 공개 범위';
-- ddl-end --
ALTER TABLE public.riding OWNER TO postgres;
-- ddl-end --
-- object: public.riding_participants | type: TABLE --
-- DROP TABLE IF EXISTS public.riding_participants CASCADE;
CREATE TABLE public.riding_participants (
id serial NOT NULL,
id_users integer,
id_riding integer,
CONSTRAINT riding_participant_pk PRIMARY KEY (id)
);
-- ddl-end --
COMMENT ON TABLE public.riding_participants IS E'라이딩 일정 참여자 테이블';
-- ddl-end --
ALTER TABLE public.riding_participants OWNER TO postgres;
-- ddl-end --
-- object: public.notification | type: TABLE --
-- DROP TABLE IF EXISTS public.notification CASCADE;
CREATE TABLE public.notification (
id_users integer NOT NULL,
created_at timestamp,
from_user_id integer,
to_user_id integer,
type smallint NOT NULL,
CONSTRAINT notification_pk PRIMARY KEY (id_users)
);
-- ddl-end --
COMMENT ON TABLE public.notification IS E'알람테이블';
-- ddl-end --
COMMENT ON COLUMN public.notification.created_at IS E'생성일';
-- ddl-end --
COMMENT ON COLUMN public.notification.from_user_id IS E'친구 요청 유저 아이디';
-- ddl-end --
COMMENT ON COLUMN public.notification.to_user_id IS E'친구 요청 대상 아이디';
-- ddl-end --
COMMENT ON COLUMN public.notification.type IS E'알람 타입\n- 0 : 공지\n- 1 : 프로모션 ( 광고 )\n- 2 : 라이딩 알람\n- 3 : 친구 신청';
-- ddl-end --
ALTER TABLE public.notification OWNER TO postgres;
-- ddl-end --
-- object: bicycle_track_fk | type: CONSTRAINT --
-- ALTER TABLE public.bicycle_track_points DROP CONSTRAINT IF EXISTS bicycle_track_fk CASCADE;
ALTER TABLE public.bicycle_track_points ADD CONSTRAINT bicycle_track_fk FOREIGN KEY (id_bicycle_track)
REFERENCES public.bicycle_track (id) MATCH FULL
ON DELETE CASCADE ON UPDATE CASCADE;
-- ddl-end --
-- object: bicycle_track_fk | type: CONSTRAINT --
-- ALTER TABLE public.bicycle_waypoint DROP CONSTRAINT IF EXISTS bicycle_track_fk CASCADE;
ALTER TABLE public.bicycle_waypoint ADD CONSTRAINT bicycle_track_fk FOREIGN KEY (id_bicycle_track)
REFERENCES public.bicycle_track (id) MATCH FULL
ON DELETE CASCADE ON UPDATE CASCADE;
-- ddl-end --
-- object: users_fk | type: CONSTRAINT --
-- ALTER TABLE public.bicycle_track DROP CONSTRAINT IF EXISTS users_fk CASCADE;
ALTER TABLE public.bicycle_track ADD CONSTRAINT users_fk FOREIGN KEY (id_users)
REFERENCES public.users (id) MATCH FULL
ON DELETE NO ACTION ON UPDATE CASCADE;
-- ddl-end --
-- object: bicycle_track_fk | type: CONSTRAINT --
-- ALTER TABLE public.bookmark_track DROP CONSTRAINT IF EXISTS bicycle_track_fk CASCADE;
ALTER TABLE public.bookmark_track ADD CONSTRAINT bicycle_track_fk FOREIGN KEY (id_bicycle_track)
REFERENCES public.bicycle_track (id) MATCH FULL
ON DELETE SET NULL ON UPDATE CASCADE;
-- ddl-end --
-- object: users_fk | type: CONSTRAINT --
-- ALTER TABLE public.riding_participants DROP CONSTRAINT IF EXISTS users_fk CASCADE;
ALTER TABLE public.riding_participants ADD CONSTRAINT users_fk FOREIGN KEY (id_users)
REFERENCES public.users (id) MATCH FULL
ON DELETE SET NULL ON UPDATE CASCADE;
-- ddl-end --
-- object: riding_fk | type: CONSTRAINT --
-- ALTER TABLE public.riding_participants DROP CONSTRAINT IF EXISTS riding_fk CASCADE;
ALTER TABLE public.riding_participants ADD CONSTRAINT riding_fk FOREIGN KEY (id_riding)
REFERENCES public.riding (id) MATCH FULL
ON DELETE SET NULL ON UPDATE CASCADE;
-- ddl-end --
-- object: users_fk | type: CONSTRAINT --
-- ALTER TABLE public.notification DROP CONSTRAINT IF EXISTS users_fk CASCADE;
ALTER TABLE public.notification ADD CONSTRAINT users_fk FOREIGN KEY (id_users)
REFERENCES public.users (id) MATCH FULL
ON DELETE CASCADE ON UPDATE CASCADE;
-- ddl-end --
-- object: public.notice | type: TABLE --
-- DROP TABLE IF EXISTS public.notice CASCADE;
CREATE TABLE public.notice (
id serial NOT NULL,
title varchar(100),
contents text,
created_at timestamp NOT NULL,
id_users integer,
CONSTRAINT notice_pk PRIMARY KEY (id)
);
-- ddl-end --
COMMENT ON TABLE public.notice IS E'공지사항 테이블';
-- ddl-end --
COMMENT ON COLUMN public.notice.title IS E'공지 제목';
-- ddl-end --
COMMENT ON COLUMN public.notice.contents IS E'내용';
-- ddl-end --
COMMENT ON COLUMN public.notice.created_at IS E'작성 날짜';
-- ddl-end --
ALTER TABLE public.notice OWNER TO postgres;
-- ddl-end --
-- object: public.faq | type: TABLE --
-- DROP TABLE IF EXISTS public.faq CASCADE;
CREATE TABLE public.faq (
id serial NOT NULL,
created_at timestamp,
question text,
answer text,
id_users integer,
CONSTRAINT faq_pk PRIMARY KEY (id)
);
-- ddl-end --
COMMENT ON TABLE public.faq IS E'faq 테이블';
-- ddl-end --
COMMENT ON COLUMN public.faq.created_at IS E'작성 날짜';
-- ddl-end --
COMMENT ON COLUMN public.faq.question IS E'질문';
-- ddl-end --
COMMENT ON COLUMN public.faq.answer IS E'답변';
-- ddl-end --
ALTER TABLE public.faq OWNER TO postgres;
-- ddl-end --
-- object: public.qna | type: TABLE --
-- DROP TABLE IF EXISTS public.qna CASCADE;
CREATE TABLE public.qna (
id serial NOT NULL,
title varchar(100),
contents text,
created_at timestamp NOT NULL,
id_users integer,
CONSTRAINT qna_pk PRIMARY KEY (id)
);
-- ddl-end --
COMMENT ON TABLE public.qna IS E'qna';
-- ddl-end --
COMMENT ON COLUMN public.qna.title IS E'제목';
-- ddl-end --
COMMENT ON COLUMN public.qna.contents IS E'내용';
-- ddl-end --
COMMENT ON COLUMN public.qna.created_at IS E'작성일';
-- ddl-end --
ALTER TABLE public.qna OWNER TO postgres;
-- ddl-end --
-- object: public.qna_answer | type: TABLE --
-- DROP TABLE IF EXISTS public.qna_answer CASCADE;
CREATE TABLE public.qna_answer (
id bigserial NOT NULL,
title varchar(100),
contents text,
id_qna integer NOT NULL,
id_users integer,
CONSTRAINT qna_answer_pk PRIMARY KEY (id,id_qna)
);
-- ddl-end --
COMMENT ON TABLE public.qna_answer IS E'qna 답변 테이블';
-- ddl-end --
COMMENT ON COLUMN public.qna_answer.contents IS E'내용';
-- ddl-end --
ALTER TABLE public.qna_answer OWNER TO postgres;
-- ddl-end --
-- object: public.purchase_info | type: TABLE --
-- DROP TABLE IF EXISTS public.purchase_info CASCADE;
CREATE TABLE public.purchase_info (
id bigserial NOT NULL,
CONSTRAINT purchase_info_pk PRIMARY KEY (id)
);
-- ddl-end --
COMMENT ON TABLE public.purchase_info IS E'상품 구매 정보';
-- ddl-end --
ALTER TABLE public.purchase_info OWNER TO postgres;
-- ddl-end --
-- object: users_fk | type: CONSTRAINT --
-- ALTER TABLE public.qna DROP CONSTRAINT IF EXISTS users_fk CASCADE;
ALTER TABLE public.qna ADD CONSTRAINT users_fk FOREIGN KEY (id_users)
REFERENCES public.users (id) MATCH FULL
ON DELETE SET NULL ON UPDATE CASCADE;
-- ddl-end --
-- object: users_fk | type: CONSTRAINT --
-- ALTER TABLE public.qna_answer DROP CONSTRAINT IF EXISTS users_fk CASCADE;
ALTER TABLE public.qna_answer ADD CONSTRAINT users_fk FOREIGN KEY (id_users)
REFERENCES public.users (id) MATCH FULL
ON DELETE SET NULL ON UPDATE CASCADE;
-- ddl-end --
-- object: users_fk | type: CONSTRAINT --
-- ALTER TABLE public.faq DROP CONSTRAINT IF EXISTS users_fk CASCADE;
ALTER TABLE public.faq ADD CONSTRAINT users_fk FOREIGN KEY (id_users)
REFERENCES public.users (id) MATCH FULL
ON DELETE SET NULL ON UPDATE CASCADE;
-- ddl-end --
-- object: users_fk | type: CONSTRAINT --
-- ALTER TABLE public.notice DROP CONSTRAINT IF EXISTS users_fk CASCADE;
ALTER TABLE public.notice ADD CONSTRAINT users_fk FOREIGN KEY (id_users)
REFERENCES public.users (id) MATCH FULL
ON DELETE SET NULL ON UPDATE CASCADE;
-- ddl-end --
-- object: public.payment_history | type: TABLE --
-- DROP TABLE IF EXISTS public.payment_history CASCADE;
CREATE TABLE public.payment_history (
id bigserial NOT NULL,
CONSTRAINT payment_history_pk PRIMARY KEY (id)
);
-- ddl-end --
ALTER TABLE public.payment_history OWNER TO postgres;
-- ddl-end --
-- object: public.promotion | type: TABLE --
-- DROP TABLE IF EXISTS public.promotion CASCADE;
CREATE TABLE public.promotion (
id bigserial NOT NULL,
CONSTRAINT promotion_pk PRIMARY KEY (id)
);
-- ddl-end --
ALTER TABLE public.promotion OWNER TO postgres;
-- ddl-end --
-- object: users_fk | type: CONSTRAINT --
-- ALTER TABLE public.friends DROP CONSTRAINT IF EXISTS users_fk CASCADE;
ALTER TABLE public.friends ADD CONSTRAINT users_fk FOREIGN KEY (id_users)
REFERENCES public.users (id) MATCH FULL
ON DELETE CASCADE ON UPDATE CASCADE;
-- ddl-end --
-- object: public.riding_history | type: TABLE --
-- DROP TABLE IF EXISTS public.riding_history CASCADE;
CREATE TABLE public.riding_history (
id bigserial NOT NULL,
created_at timestamp NOT NULL,
id_users integer NOT NULL,
CONSTRAINT riding_history_pk PRIMARY KEY (id,id_users)
);
-- ddl-end --
COMMENT ON TABLE public.riding_history IS E'자전거 라이딩 기록';
-- ddl-end --
ALTER TABLE public.riding_history OWNER TO postgres;
-- ddl-end --
-- object: public.riding_points_history | type: TABLE --
-- DROP TABLE IF EXISTS public.riding_points_history CASCADE;
CREATE TABLE public.riding_points_history (
id bigserial NOT NULL,
created_at timestamp NOT NULL,
geom geometry(POINT) NOT NULL,
id_riding_history bigint NOT NULL,
id_users_riding_history integer NOT NULL,
CONSTRAINT riding_points_history_pk PRIMARY KEY (id,id_riding_history,id_users_riding_history)
);
-- ddl-end --
COMMENT ON TABLE public.riding_points_history IS E'자전거 라이딩 기록';
-- ddl-end --
ALTER TABLE public.riding_points_history OWNER TO postgres;
-- ddl-end --
-- object: users_fk | type: CONSTRAINT --
-- ALTER TABLE public.riding_history DROP CONSTRAINT IF EXISTS users_fk CASCADE;
ALTER TABLE public.riding_history ADD CONSTRAINT users_fk FOREIGN KEY (id_users)
REFERENCES public.users (id) MATCH FULL
ON DELETE CASCADE ON UPDATE CASCADE;
-- ddl-end --
-- object: users_fk | type: CONSTRAINT --
-- ALTER TABLE public.bookmark_track DROP CONSTRAINT IF EXISTS users_fk CASCADE;
ALTER TABLE public.bookmark_track ADD CONSTRAINT users_fk FOREIGN KEY (id_users)
REFERENCES public.users (id) MATCH FULL
ON DELETE SET NULL ON UPDATE CASCADE;
-- ddl-end --
-- object: public.user_type | type: TABLE --
-- DROP TABLE IF EXISTS public.user_type CASCADE;
CREATE TABLE public.user_type (
id serial NOT NULL,
type smallint NOT NULL,
created_at timestamp NOT NULL,
CONSTRAINT user_type_pk PRIMARY KEY (id)
);
-- ddl-end --
COMMENT ON TABLE public.user_type IS E'유저 종류 테이블';
-- ddl-end --
COMMENT ON COLUMN public.user_type.type IS E'유저 타입\n\n- 0 : Admin\n- 1 : Manager\n- 2 : User\n- 3 : Guest';
-- ddl-end --
COMMENT ON COLUMN public.user_type.created_at IS E'생성일';
-- ddl-end --
ALTER TABLE public.user_type OWNER TO postgres;
-- ddl-end --
-- object: public.access_page | type: TABLE --
-- DROP TABLE IF EXISTS public.access_page CASCADE;
CREATE TABLE public.access_page (
id serial NOT NULL,
path text,
created_at timestamp,
CONSTRAINT access_page_pk PRIMARY KEY (id)
);
-- ddl-end --
COMMENT ON TABLE public.access_page IS E'접근 가능 프론트엔드 페이지 테이블';
-- ddl-end --
COMMENT ON COLUMN public.access_page.path IS E'페이지 경로';
-- ddl-end --
ALTER TABLE public.access_page OWNER TO postgres;
-- ddl-end --
-- object: user_type_fk | type: CONSTRAINT --
-- ALTER TABLE public.users DROP CONSTRAINT IF EXISTS user_type_fk CASCADE;
ALTER TABLE public.users ADD CONSTRAINT user_type_fk FOREIGN KEY (id_user_type)
REFERENCES public.user_type (id) MATCH FULL
ON DELETE SET NULL ON UPDATE CASCADE;
-- ddl-end --
-- object: public.user_type_access_page | type: TABLE --
-- DROP TABLE IF EXISTS public.user_type_access_page CASCADE;
CREATE TABLE public.user_type_access_page (
id serial NOT NULL,
created_at timestamp NOT NULL,
id_access_page integer,
id_user_type integer NOT NULL,
CONSTRAINT user_type_access_page_pk PRIMARY KEY (id,id_user_type)
);
-- ddl-end --
COMMENT ON COLUMN public.user_type_access_page.created_at IS E'생성일';
-- ddl-end --
ALTER TABLE public.user_type_access_page OWNER TO postgres;
-- ddl-end --
-- object: access_page_fk | type: CONSTRAINT --
-- ALTER TABLE public.user_type_access_page DROP CONSTRAINT IF EXISTS access_page_fk CASCADE;
ALTER TABLE public.user_type_access_page ADD CONSTRAINT access_page_fk FOREIGN KEY (id_access_page)
REFERENCES public.access_page (id) MATCH FULL
ON DELETE SET NULL ON UPDATE CASCADE;
-- ddl-end --
-- object: user_type_fk | type: CONSTRAINT --
-- ALTER TABLE public.user_type_access_page DROP CONSTRAINT IF EXISTS user_type_fk CASCADE;
ALTER TABLE public.user_type_access_page ADD CONSTRAINT user_type_fk FOREIGN KEY (id_user_type)
REFERENCES public.user_type (id) MATCH FULL
ON DELETE CASCADE ON UPDATE CASCADE;
-- ddl-end --
-- object: qna_fk | type: CONSTRAINT --
-- ALTER TABLE public.qna_answer DROP CONSTRAINT IF EXISTS qna_fk CASCADE;
ALTER TABLE public.qna_answer ADD CONSTRAINT qna_fk FOREIGN KEY (id_qna)
REFERENCES public.qna (id) MATCH FULL
ON DELETE CASCADE ON UPDATE CASCADE;
-- ddl-end --
-- object: riding_history_fk | type: CONSTRAINT --
-- ALTER TABLE public.riding_points_history DROP CONSTRAINT IF EXISTS riding_history_fk CASCADE;
ALTER TABLE public.riding_points_history ADD CONSTRAINT riding_history_fk FOREIGN KEY (id_riding_history,id_users_riding_history)
REFERENCES public.riding_history (id,id_users) MATCH FULL
ON DELETE CASCADE ON UPDATE CASCADE;
-- ddl-end --
-- object: postgis | type: EXTENSION --
-- DROP EXTENSION IF EXISTS postgis CASCADE;
CREATE EXTENSION postgis
WITH SCHEMA public;
-- ddl-end --
COMMENT ON EXTENSION postgis IS E'PostGIS geometry, geography, and raster spatial types and functions';
-- ddl-end --