-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathschema.prisma
4207 lines (3625 loc) · 131 KB
/
schema.prisma
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
datasource db {
provider = "postgresql"
url = env("SHOPPING_POSTGRES_URL")
extensions = [pg_trgm]
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["postgresqlExtensions"]
}
generator markdown {
provider = "node ./lib/executable/markdown"
title = "Shopping Mall"
}
//-----------------------------------------------------------
// ARTICLES
//-----------------------------------------------------------
/// Attachment File.
///
/// Every attachment files that are managed in this shopping mall system.
///
/// For reference, it is possible to omit one of file name or extension like
/// `.gitignore` or `README` case, but not possible to omit both of them,
///
/// @namespace Articles
/// @author Samchon
model attachment_files {
//----
// COLUMNS
//----
/// Primary Key.
///
/// @format uuid
id String @id @db.Uuid
/// File name, except extension.
///
/// If there's file `.gitignore`, then its name is an empty string.
///
/// @maxLength 255
name String @db.VarChar
//-----------------------------------------------------------
// ARTICLES
//-----------------------------------------------------------
/// Extension.
///
/// Possible to omit like `README` case.
///
/// @minLength 1
/// @maxLength 8
extension String? @db.VarChar
/// URL path of the real file.
///
/// @format url
url String @db.VarChar
/// Creation time of record.
created_at DateTime @db.Timestamptz
//----
// RELATIONS
//----
bbs_article_snapshot_files bbs_article_snapshot_files[]
bbs_article_comment_snapshots_files bbs_article_comment_snapshot_files[]
shopping_sale_snapshot_content_files shopping_sale_snapshot_content_files[]
shopping_sale_snapshot_content_thumbnails shopping_sale_snapshot_content_thumbnails[]
@@index([url])
}
/// Article entity.
///
/// `bbs_articles` is a super-type entity of all kinds of articles in the
/// current shopping mall system, literally shaping individual articles of
/// the bulletin board.
///
/// And, as you can see, the elements that must inevitably exist in the
/// article, such as the title or the body, do not exist in the `bbs_articles`,
/// but exist in the subsidiary entity, {@link bbs_article_snapshots}, as a
/// 1: N relationship, which is because a new snapshot record is published
/// every time the article is modified.
///
/// The reason why a new snapshot record is published every time the article
/// is modified is to preserve the evidence. Due to the nature of e-commerce,
/// there is always a threat of dispute among the participants. And it can
/// happen that disputes arise through articles or comments, and to prevent
/// such things as modifying existing articles to manipulate the situation,
/// the article is designed in this structure.
///
/// In other words, to keep evidence, and prevent fraud.
///
/// @namespace Articles
/// @erd Inquiries
/// @author Samchon
model bbs_articles {
/// Primary Key.
///
/// @format uuid
id String @id @db.Uuid
/// Creation time of article.
created_at DateTime @db.Timestamptz
/// Deletion time of article.
///
/// To keep evidence, do not delete the article, but just mark it as
/// deleted.
deleted_at DateTime? @db.Timestamptz
//----
// RELATIONS
//----
/// List of snapshots.
///
/// It is created for the first time when an article is created, and is
/// accumulated every time the article is modified.
///
/// @minItems 1
snapshots bbs_article_snapshots[]
/// List of comments.
comments bbs_article_comments[]
of_inquiry shopping_sale_snapshot_inquiries?
of_inquiry_answer shopping_sale_snapshot_inquiry_answers?
@@index([created_at])
}
/// Snapshot of article.
///
/// `bbs_article_snapshots` is a snapshot entity that contains the contents of
/// the article, as mentioned in {@link bbs_articles}, the contents of the
/// article are separated from the article record to keep evidence and prevent
/// fraud.
///
/// @namespace Articles
/// @erd Inquiries
/// @author Samchon
model bbs_article_snapshots {
//----
// COLUMNS
//----
/// Primary Key.
///
/// @format uuid
id String @id @db.Uuid
/// Belong article's {@link bbs_articles.id}
///
/// @format uuid
bbs_article_id String @db.Uuid
/// Format of body.
///
/// Same meaning with extension like `html`, `md`, `txt`.
format String @db.VarChar
/// Title of article.
title String @db.VarChar
/// Content body of article.
body String
/// Creation time of record.
///
/// It means creation time or update time or article.
created_at DateTime @db.Timestamptz
//----
// RELATIONS
//----
/// Belong article info.
article bbs_articles @relation(fields: [bbs_article_id], references: [id], onDelete: Cascade)
/// List of wrappers of attachment files.
to_files bbs_article_snapshot_files[]
of_review shopping_sale_snapshot_review_snapshots?
shopping_sale_snapshot_inquiry_favorites shopping_sale_snapshot_inquiry_favorites[]
@@index([bbs_article_id, created_at])
@@index([title(ops: raw("gin_trgm_ops"))], type: Gin)
@@index([body(ops: raw("gin_trgm_ops"))], type: Gin)
}
/// Attachment file of article snapshot.
///
/// `bbs_article_snapshot_files` is an entity that shapes the attached files of
/// the article snapshot.
///
/// `bbs_article_snapshot_files` is a typical pair relationship table to
/// resolve the M: N relationship between {@link bbs_article_snapshots} and
/// {@link attachment_files} tables. Also, to ensure the order of the attached
/// files, it has an additional `sequence` attribute, which we will continue to
/// see in this documents.
///
/// @namespace Articles
/// @author Samchon
model bbs_article_snapshot_files {
//----
// COLUMNS
//----
/// Primary Key.
///
/// @format uuid
id String @id @db.Uuid
/// Belonged snapshot's {@link bbs_article_snapshots.id}
///
/// @format uuid
bbs_article_snapshot_id String @db.Uuid
/// Belonged file's {@link attachment_files.id}
///
/// @format uuid
attachment_file_id String @db.Uuid
/// Sequence of attachment file in the snapshot.
///
/// @format int
sequence Int @db.Integer
//----
// RELATIONS
//----
/// Belonged article.
snapshot bbs_article_snapshots @relation(fields: [bbs_article_snapshot_id], references: [id], onDelete: Cascade)
/// Belonged file.
file attachment_files @relation(fields: [attachment_file_id], references: [id], onDelete: Cascade)
@@index([bbs_article_snapshot_id])
@@index([attachment_file_id])
}
/// Comment written on an article.
///
/// `bbs_article_comments` is an entity that shapes the comments written on an
/// article.
///
/// And for this comment, as in the previous relationship between
/// {@link bbs_articles} and {@link bbs_article_snapshots}, the content body
/// of the comment is stored in the sub {@link bbs_article_comment_snapshots}
/// table for evidentialism, and a new snapshot record is issued every time
/// the comment is modified.
///
/// Also, `bbs_article_comments} is expressing the relationship of the
/// hierarchical reply structure through the `parent_id` attribute.
///
/// @namespace Articles
/// @erd Inquiries
/// @author Samchon
model bbs_article_comments {
//----
// COLUMNS
//----
/// Primary Key.
///
/// @format uuid
id String @id @db.Uuid
/// Belonged article's {@link bbs_articles.id}
///
/// @format uuid
bbs_article_id String @db.Uuid
/// Parent comment's {@link bbs_article_comments.id}
///
/// Used to express the hierarchical reply structure.
///
/// @format uuid
parent_id String? @db.Uuid
/// Creation time of comment.
created_at DateTime @db.Timestamptz
/// Deletion time of comment.
///
/// Do not allow to delete the comment, but just mark it as deleted,
/// to keep evidence.
deleted_at DateTime? @db.Timestamptz
//----
// RELATIONS
//----
/// Belonged article.
article bbs_articles @relation(fields: [bbs_article_id], references: [id], onDelete: Cascade)
/// Parent comment.
///
/// Only when reply case.
parent bbs_article_comments? @relation("bbs_article_comments_reply", fields: [parent_id], references: [id], onDelete: Cascade)
/// List of children comments.
///
/// Reply comments of current.
children bbs_article_comments[] @relation("bbs_article_comments_reply")
/// List of snapshots.
///
/// It is created for the first time when a comment is created, and is
/// accumulated every time the comment is modified.
///
/// @minItems 1
snapshots bbs_article_comment_snapshots[]
of_inquiry shopping_sale_snapshot_inquiry_comments?
@@index([bbs_article_id, parent_id, created_at])
}
/// Snapshot of comment.
///
/// `bbs_article_comment_snapshots` is a snapshot entity that contains the
/// contents of the comment.
///
/// As mentioned in {@link bbs_article_comments}, designed to keep evidence
/// and prevent fraud.
///
/// @namespace Articles
/// @author Samchon
model bbs_article_comment_snapshots {
//----
// COLUMNS
//----
/// Primary Key.
///
/// @format uuid
id String @id @db.Uuid
/// Belonged article's {@link bbs_article_comments.id}
///
/// @format uuid
bbs_article_comment_id String @db.Uuid
/// Format of content body.
///
/// Same meaning with extension like `html`, `md`, `txt`.
format String @db.VarChar
/// Content body of comment.
body String
/// Creation time of record.
///
/// It means creation time or update time or comment.
created_at DateTime @db.Timestamptz
//----
// RELATIONS
//----
/// Belong comment info.
comment bbs_article_comments @relation(fields: [bbs_article_comment_id], references: [id], onDelete: Cascade)
/// List of wrappers of attachment files.
files bbs_article_comment_snapshot_files[]
@@index([bbs_article_comment_id, created_at])
@@index([body(ops: raw("gin_trgm_ops"))], type: Gin)
}
/// Attachment file of comment snapshot.
///
/// `bbs_article_comment_snapshot_files` is an entity resolving the M:N
/// relationship between {@link bbs_article_comment_snapshots} and
/// {@link attachment_files} tables.
///
/// @namespace Articles
/// @author Samchon
model bbs_article_comment_snapshot_files {
//----
// COLUMNS
//----
/// Primary Key.
///
/// @format uuid
id String @id @db.Uuid
/// Belonged snapshot's {@link bbs_article_comment_snapshots.id}
///
/// @format uuid
bbs_article_comment_snapshot_id String @db.Uuid
/// Belonged file's {@link attachment_files.id}
///
/// @format uuid
attachment_file_id String @db.Uuid
/// Sequence order.
///
/// Sequence order of the attached file in the belonged snapshot.
///
/// @type int
sequence Int @db.Integer
//----
// RELATIONS
//----
/// Belonged article.
snapshot bbs_article_comment_snapshots @relation(fields: [bbs_article_comment_snapshot_id], references: [id], onDelete: Cascade)
/// Belonged file.
file attachment_files @relation(fields: [attachment_file_id], references: [id], onDelete: Cascade)
@@index([bbs_article_comment_snapshot_id])
@@index([attachment_file_id])
}
//-----------------------------------------------------------
// SYSTEMATIC
//-----------------------------------------------------------
/// Channel information.
///
/// `shopping_channels` is a concept that shapes the distribution channel in
/// the market. Therefore, the difference in the channel in this e-commerce
/// system means that it is another site or application.
///
/// By the way, if your shopping mall system requires only one channel, then
/// just use only one. This concept is designed to be expandable in the future.
///
/// @namespace Systematic
/// @erd Sales
/// @author Samchon
model shopping_channels {
//----
// COLUMNS
//----
/// Primary Key.
///
/// @format uuid
id String @id @db.Uuid
/// Identifier code.
code String @db.VarChar
/// Name of channel.
name String @db.VarChar
/// Creation time of record.
created_at DateTime @db.Timestamptz
/// Update time of record.
updated_at DateTime @db.Timestamptz
/// Deletion time of record.
deleted_at DateTime? @db.Timestamptz
//----
// RELATIONS
//----
shopping_channel_categories shopping_channel_categories[]
shopping_customers shopping_customers[]
shopping_citizens shopping_citizens[]
shopping_members shopping_members[]
shopping_member_emails shopping_member_emails[]
shopping_sale_snapshot_channels shopping_sale_snapshot_channels[]
shopping_coupon_channel_criterias shopping_coupon_channel_criterias[]
shopping_external_users shopping_external_users[]
@@unique([code])
@@unique([name])
@@index([created_at])
}
/// Category of channel.
///
/// `shopping_channel_categories` is a concept that refers to classification
/// categories within a specific channel, and is exactly the same as the concept
/// commonly referred to as "category" in shopping malls.
///
/// And `shopping_channel_categories` is different with
/// {@link shopping_sections}. {@link shopping_sections} refers to a "corner"
/// that is independent spatial information in the offline market, which cannot
/// simultaneously classified in a {@link shopping_sales sale}. Besides,
/// `shopping_channel_categories` can be classified into multiple categories
/// in a {@link shopping_sales sale} simultaneously.
///
/// Product | Section (corner) | Categories
/// --------|------------------|--------------------------------------
/// Beef | Butcher corner | Frozen food, Meat, **Favorite food**
/// Grape | Fruit corner | Fresh food, **Favorite food**
///
/// In addition, as `shopping_channel_categories` has 1:N self recursive
/// relationship, it is possible to express below hierarchical structures.
/// Thus, each channel can set their own category classification as they want.
///
/// - Food > Meat > Frozen
/// - Electronics > Notebook > 15 inches
/// - Miscellaneous > Wallet
///
/// Furthermore, `shopping_channel_categories` is designed to merge between
/// themselves, so there is no burden to edit the category at any time.
///
/// @namespace Systematic
/// @erd Sales
/// @author Samchon
model shopping_channel_categories {
//----
// COLUMNS
//----
/// Primary Key.
///
/// @format uuid
id String @id @db.Uuid
/// Belonged channel's {@link shopping_channels.id}.
///
/// @format uuid
shopping_channel_id String @db.Uuid
/// Parent category's {@link shopping_channel_categories.id}.
///
/// Only when the category is a subcategory of another one.
///
/// @format uuid
parent_id String? @db.Uuid
/// Name of category.
name String @db.VarChar
/// Creation time of record.
created_at DateTime @db.Timestamptz
/// Updadte time of record.
updated_at DateTime @db.Timestamptz
/// Deletion time of record.
deleted_at DateTime? @db.Timestamptz
//----
// RELATIONS
//----
channel shopping_channels @relation(fields: [shopping_channel_id], references: [id], onDelete: Cascade)
parent shopping_channel_categories? @relation("shopping_channel_categories_children", fields: [parent_id], references: [id], onDelete: Cascade)
children shopping_channel_categories[] @relation("shopping_channel_categories_children")
shopping_sale_snapshot_channel_categories shopping_sale_snapshot_channel_categories[]
shopping_coupon_channel_criterias shopping_coupon_channel_criterias[]
@@unique([shopping_channel_id, parent_id, name])
@@index([parent_id])
}
/// Section information.
///
/// `shopping_sections` is a concept that refers to the spatial information
/// of the market.
///
/// If we compare the section mentioned here to the offline market, it means
/// a spatially separated area within the store, such as the "fruit corner"
/// or "butcher corner". Therefore, in the {@link shopping_sales sale} entity,
/// it is not possible to classify multiple sections simultaneously, but only
/// one section can be classified.
///
/// By the way, if your shopping mall system requires only one section, then
/// just use only one. This concept is designed to be expandable in the future.
///
/// @namespace Systematic
/// @erd Sales
/// @author Samchon
model shopping_sections {
//----
// COLUMNS
//----
/// Primary Key.
///
/// @format uuid
id String @id @db.Uuid
/// Identifier code.
code String @db.VarChar
/// Name of section.
name String @db.VarChar
/// Creation time of record.
created_at DateTime @db.Timestamptz
/// Update time of record.
updated_at DateTime @db.Timestamptz
/// Deletion time of record.
deleted_at DateTime? @db.Timestamptz
//----
// RELATIONS
//----
shopping_sales shopping_sales[]
shopping_coupon_section_criterias shopping_coupon_section_criterias[]
@@unique([code])
@@unique([name])
@@index([created_at])
}
//-----------------------------------------------------------
// ACTORS
//-----------------------------------------------------------
/// Customer information, but not a person but a **connection** basis.
///
/// `shopping_customers` is an entity that literally embodies the information
/// of those who participated in the market as customers. By the way, the
/// `shopping_Customers` does not mean a person, but a **connection** basis.
/// Therefore, even if the same person connects to the shopping mall multiple,
/// multiple records are created in `shopping_customers`.
///
/// The first purpose of this is to track the customer's inflow path in detail, and
/// it is for cases where the same person enters as a non-member, puts items in the
/// {@link shopping_cart_commodities shopping cart} in advance, and only authenticates
/// their real name or registers/logs in at the moment of
/// {@link shopping_order_publishes payment}. It is the second. Lastly, it is
/// to accurately track the activities that a person performs at the
/// shopping mall in various ways like below.
///
/// - Same person comes from an {@link shopping_external_users external service}
/// - Same person creates multiple {@link shopping_members accounts}
/// - Same person makes a purchase as a non-member with only {@link shopping_citizens real name authentication}
/// - Same person acts both {@link shopping_sellers seller} and {@link shopping_administrators admin} at the same time
///
/// Therefore, `shopping_customers` can have multiple records with the same
/// {@link shopping_citizens}, {@link shopping_members}, and
/// {@link shopping_external_users}. Additionally, if a customer signs up for
/// membership after verifying their real name or signs up for our service
/// after being a user of an external service, all related records are changed
/// at once. Therefore, identification and tracking of customers can be done
/// very systematically.
///
/// @namespace Actors
/// @erd Coins
/// @erd Favorites
/// @author Samchon
model shopping_customers {
//----
// COLUMNS
//----
/// Primary Key.
///
/// @format uuid
id String @id @db.Uuid
/// Belonged channel's {@link shopping_channels.id}
///
/// @format uuid
shopping_channel_id String @db.Uuid /// @format uuid
/// Belonged member's {@link shopping_members.id}
///
/// @format uuid
shopping_member_id String? @db.Uuid /// @format uuid
/// Belonged external service user's {@link shopping_external_users.id}
///
/// @format uuid
shopping_external_user_id String? @db.Uuid /// @format uuid
/// Belonged citizen's {@link shopping_citizens.id}
///
/// @format uuid
shopping_citizen_id String? @db.Uuid /// @format uuid
/// Connection URL.
///
/// {@link window.location.href}
///
/// @format url
href String @db.VarChar /// @format url
/// Referrer URL.
///
/// {@link window.document.referrer}
///
/// @format url
referrer String? @db.VarChar /// @format url
/// IP address,
///
/// @pattern ((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$))
ip String @db.VarChar
/// Creation time of record.
///
/// It means the time when the customer connected to the shopping mall.
created_at DateTime @db.Timestamptz
//----
// RELATIONS
//----
/// Belonged channel.
channel shopping_channels @relation(fields: [shopping_channel_id], references: [id], onDelete: Cascade)
/// Belonged member.
member shopping_members? @relation(fields: [shopping_member_id], references: [id], onDelete: Cascade)
/// Belonged external user.
external_user shopping_external_users? @relation(fields: [shopping_external_user_id], references: [id], onDelete: Cascade)
/// Belonged citizen.
citizen shopping_citizens? @relation(fields: [shopping_citizen_id], references: [id], onDelete: Cascade)
shopping_carts shopping_carts[]
shopping_coupons shopping_coupons[]
shopping_coupon_tickets shopping_coupon_tickets[]
shopping_deliveries shopping_deliveries[]
shopping_deposit_charges shopping_deposit_charges[]
shopping_orders shopping_orders[]
shopping_sales shopping_sales[]
shopping_sale_snapshot_inquiries shopping_sale_snapshot_inquiries[]
shopping_sale_snapshot_inquiry_answers shopping_sale_snapshot_inquiry_answers[]
shopping_sale_snapshot_inquiry_comments shopping_sale_snapshot_inquiry_comments[]
shopping_sale_favorites shopping_sale_favorites[]
shopping_sale_snapshot_inquiry_favorites shopping_sale_snapshot_inquiry_favorites[]
shopping_address_favorites shopping_address_favorites[]
shopping_mileage_donations shopping_mileage_donations[]
@@index([shopping_channel_id, created_at])
@@index([shopping_citizen_id, created_at])
@@index([shopping_external_user_id, created_at])
@@index([shopping_member_id, created_at])
@@index([href])
@@index([referrer])
@@index([ip])
@@index([created_at])
}
/// External user information.
///
/// `shopping_external_users` is an entity dsigned for when this system needs
/// to connect with external services and welcome their users as customers of
/// this service.
///
/// For reference, customers who connect from an external service must have
/// this record, and the external service user is identified through the two
/// attributes `application` and `uid`. If a customer connected from an
/// external service completes {@link shopping_citizens real-name authentication}
/// from this service, each time the external service user reconnects to this
/// service and issues a new {@link shopping_customers customer} authentication
/// token, {@link shopping_citizens real-name authentication} begins with
/// completed.
///
/// And `password` is the password issued to the user by the external service
/// system (the so-called permanent user authentication token), and is never
/// the actual user password. However, for customers who entered the same
/// `application` and `uid` as the current external system user, this is to
/// determine whether to view this as a correct external system user or a
/// violation.
///
/// In addition, additional information received from external services can
/// be recorded in the `data` field in JSON format.
///
/// @namespace Actors
/// @author Samchon
model shopping_external_users {
//----
// COLUMNS
//----
/// Primary Key.
///
/// @format uuid
id String @id @db.Uuid
/// Belonged channel's {@link shopping_channels.id}
shopping_channel_id String @db.Uuid
/// Belonged citizen's {@link shopping_citizens.id}
shopping_citizen_id String? @db.Uuid
/// Identifier code of the external service.
///
/// It can be same with {@link shopping_channels.code} in common.
application String @db.VarChar
/// Identifier key of external user from the external system.
uid String @db.VarChar
/// Nickname of external user in the external system.
nickname String @db.VarChar
/// Additional information about external user from the external system.
data String?
/// Password of external user from the external system.
///
/// This is a password issued to the user by an external service, and is
/// by no means the actual user password. However, for customers who
/// entered the same application and code as the current external system
/// user, this is to determine whether to view this as a correct external
/// system user or a violation.
password String @db.VarChar
/// Creation time of record.
///
/// Another word, first time when the external user connected.
created_at DateTime
//----
// RELATIONS
//----
channel shopping_channels @relation(fields: [shopping_channel_id], references: [id], onDelete: Cascade)
citizen shopping_citizens? @relation(fields: [shopping_citizen_id], references: [id], onDelete: Cascade)
/// @minItems 1
customers shopping_customers[]
@@unique([shopping_channel_id, application, uid])
@@unique([shopping_channel_id, application, nickname])
@@index([shopping_citizen_id])
@@index([application, created_at])
@@index([created_at])
@@index([nickname(ops: raw("gin_trgm_ops"))], type: Gin)
}
/// Citizen verification information.
///
/// `shopping_citizens` is an entity that records the user's real name and
/// mobile input information.
///
/// For reference, in South Korea, real name authentication is required for
/// e-commerce participants, so the `name` attribute is important. However,
/// the situation is different overseas, so in reality, `mobile` attributes
/// are the most important, and identification of individual users is also
/// done based on this mobile.
///
/// Of course, real name and mobile phone authentication information are
/// encrypted and stored.
///
/// @namespace Actors
/// @erd Coins
/// @author Samchon
model shopping_citizens {
//----
// COLUMNS
//----
/// Primary Key.
///
/// @format uuid
id String @id @db.Uuid
/// Belonged channel's {@link shopping_channels.id}
///
/// This is to manage personal information separately for each channel,
/// and also to recognize cases where the same citizen is authenticated
/// through different channels.
///
/// @format uuid
shopping_channel_id String? @db.Uuid
/// Mobile phone number.
///
/// @pattern ^[0-9]*$
mobile String @db.VarChar
/// Real name, or equivalent name identifiable.
name String @db.VarChar
/// Creation time of record.
///
/// In other words, the 1st time of citizen activation.
created_at DateTime @db.Timestamptz
/// Deletion time of record.
deleted_at DateTime? @db.Timestamptz
//----
// RELATIONS
//----
channel shopping_channels? @relation(fields: [shopping_channel_id], references: [id], onDelete: Cascade)
/// @minItems 1
customers shopping_customers[]
members shopping_members[]
deposit_histories shopping_deposit_histories[]
mileage_histories shopping_mileage_histories[]
shopping_external_users shopping_external_users[]
shopping_mileage_donations shopping_mileage_donations[]
@@unique([shopping_channel_id, mobile])
@@index([mobile])
@@index([name])
@@index([created_at])
}
/// Member Account.
///
/// `shopping_members` is an entity that symbolizes the case when a user
/// signs up as a member of this system.
///
/// In addition, `shopping_members` itself is a supertype entity, forming
/// and managing subtypes for various types of members. However,
/// {@link shopping_customers} are an exception, and due to the nature of
/// their records being created on a per-connection basis, they are not
/// divided into separate subtype entities when they sign up for membership.
///
/// For reference, `shopping_members` allows multiple subtypes. Therefore,
/// it is also possible for a {@link shopping_citizens citizen} to be sometimes
/// a {@link shopping_customers customer}, sometimes a
/// {@link shopping_sellers seller}, sometimes an
/// {@link shopping_administrators administrator}, and so on.
///
/// Of course, this is according to system theory, and it is unclear what
/// the planning will be like.
///
/// @namespace Actors
/// @author Samchon
model shopping_members {
//----
// COLUMNS
//----
/// Primary Key.
///
/// @format uuid
id String @id @db.Uuid
/// Belonged channel's {@link shopping_channels.id}
///
/// @format uuid
shopping_channel_id String @db.Uuid
/// Belonged citizen's {@link shopping_citizens.id}
///
/// @format uuid
shopping_citizen_id String? @db.Uuid
/// Nickname.
nickname String @db.VarChar
/// Password for log-in.
password String @db.VarChar
/// Creation time of record.
///
/// In other words, the joining time.
created_at DateTime @db.Timestamptz
/// Update time of record.
updated_at DateTime @db.Timestamptz
/// Deletion time of record.
withdrawn_at DateTime? @db.Timestamptz
//----
// RELATIONS
//----
/// Belonged channel.
channel shopping_channels @relation(fields: [shopping_channel_id], references: [id], onDelete: Cascade)
/// Belonged citizen.
citizen shopping_citizens? @relation(fields: [shopping_citizen_id], references: [id], onDelete: Cascade)
/// List of customer records (connections).
///
/// @minItems 1
customers shopping_customers[]
/// List of email addresses.
///
/// @minItems 1
emails shopping_member_emails[]
of_seller shopping_sellers?
of_admin shopping_administrators?
@@unique([shopping_channel_id, nickname])
@@unique([shopping_channel_id, shopping_citizen_id])
@@index([shopping_citizen_id])
@@index([nickname(ops: raw("gin_trgm_ops"))], type: Gin)
@@index([created_at])
}
/// Email address of member.
///
/// This system allows multiple email addresses to be registered for one
/// {@link shopping_members member}. If you don't have to plan such multiple
/// email addresses, just use only one.
///
/// @namespace Actors
/// @author Samchon
model shopping_member_emails {
//----
// COLUMNS
//----
/// @format uuid
id String @id @db.Uuid
/// Belonged channel's {@link shopping_channels.id}
///
/// Duplicated attribute with {@link shopping_members.channel_id}, but
/// just denormalized for composing unique constraint.
///
/// @format uuid
/// @hidden
shopping_channel_id String @db.Uuid
/// Belonged member's {@link shopping_members.id}
///
/// @format uuid
shopping_member_id String @db.Uuid