-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.prisma
More file actions
1525 lines (1310 loc) · 57.5 KB
/
Copy pathschema.prisma
File metadata and controls
1525 lines (1310 loc) · 57.5 KB
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
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator typegraphql {
provider = "typegraphql-prisma"
}
// data types
enum WithdrawalState {
UNPROCESSED
PENDING
CONFIRMED
ERROR
@@map("withdrawal_state")
}
enum DepositState {
UNPROCESSED
PENDING
CONFIRMED
INVALIDATED
@@map("deposit_state")
}
enum CurrencyType {
AKIR
AKV
USDC
@@map("currency_type")
}
enum NftType {
ARCADE_PART
ARCADE_MACHINE
GAME_CENTER
@@map("nft_type")
}
enum NftState {
IN_AKIVERSE
MOVING_TO_WALLET
IN_WALLET
MOVING_TO_AKIVERSE
BURNING
BURNED
@@map("nft_state")
}
enum BlockScanState {
MISSED
WATCHED
SCANNED
@@map("block_scan_state")
}
enum BlockState {
CONFIRMED
PENDING
INVALIDATED
@@map("block_state")
}
enum TransferState {
CONFIRMED
PENDING
INVALIDATED
FROZEN
@@map("transfer_state")
}
enum GameCenterSize {
SMALL
MEDIUM
LARGE
@@map("game_center_size")
}
enum GameCenterArea {
AKIHABARA
SHIBUYA
@@map("game_center_area")
}
enum ArcadePartCategory {
ROM
ACCUMULATOR
UPPER_CABINET
LOWER_CABINET
@@map("arcade_part_category")
}
enum PlaySessionState {
READY
PLAYING
FINISHED
@@map("play_session_state")
}
enum PlayResult {
WIN
LOSS
DISCONNECTED
@@map("play_result")
}
enum WithdrawalType {
MINT
TRANSFER
}
enum CollectState {
UNPROCESSED
COLLECTED
UNINSTALLED
@@map("collect_state")
}
enum PaymentState {
UNPROCESSED
PAID
@@map("payment_state")
}
enum NotificationType {
ACTIVITY
INFORMATION
@@map("notification_type")
}
enum RewardItemType {
TERAS
TICKET
ARCADE_PART
JUNK_PART
COLLECTIBLE_ITEM
@@map("reward_item_type")
}
enum RewardCategory {
ROM
ACCUMULATOR
UPPER_CABINET
LOWER_CABINET
TERAS
TICKET
ICON
TITLE
FRAME
@@map("reward_category")
}
enum IconType {
IN_WORLD
NFT
@@map("icon_type")
}
enum FrontEndType {
WM
GP
@@map("front_end_type")
}
enum BurnState {
UNPROCESSED
PENDING
CONFIRMED
ERROR
@@map("burn_state")
}
// models
model User {
// common fields
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
name String
email String @unique
walletAddress String? @unique @map("wallet_address") // case-insensitive
akirBalance Decimal @default(0) @map("akir_balance") @db.Decimal(78, 0)
akvBalance Decimal @default(0) @map("akv_balance") @db.Decimal(78, 0)
terasBalance Decimal @default(0) @map("teras_balance") @db.Decimal(78, 0)
iconType IconType @default(IN_WORLD) @map("icon_type")
iconSubCategory String @default("DEFAULT") @map("icon_sub_category")
frameSubCategory String @default("DEFAULT") @map("frame_sub_category")
titleSubCategory String @default("DEFAULT") @map("title_sub_category")
lockedAt DateTime? @map("locked_at")
tickets Int @default(0)
receiveBulkEmail Boolean @default(true) @map("receive_bulk_email")
unsubscribeToken String @unique @default(dbgenerated("gen_random_uuid()")) @map("unsubscribe_token") @db.Uuid
admin Boolean @default(false)
// relation fields
arcadeMachines ArcadeMachine[]
arcadeParts ArcadePart[]
gameCenters GameCenter[]
/// @TypeGraphQL.omit(output: true, input: true)
withdrawals Withdrawal[]
playSessions PlaySession[] @relation("player")
ownedGameCenterPlaySessions PlaySession[] @relation("gameCenterOwner")
ownedArcadeMachinePlaySessions PlaySession[] @relation("arcadeMachineOwner")
/// @TypeGraphQL.omit(output: true, input: true)
magicSessions MagicSession[]
/// @TypeGraphQL.omit(output: true, input: true)
currencyWithdrawals CurrencyWithdrawal[]
deposits Deposit[]
notifications Notification[]
// Check constraints:
// 20230227144550_add_user_constraint
// akirBalance:akir_balance_over_zero CHECK ( akir_balance >= 0 )
// akvBalance:akv_balance_over_zero CHECK ( akv_balance >= 0)
// 20230329001523_add_teras_balance_and_rename_akir_reward_to_teras_reward
// terasBalance:teras_balance_over_zero CHECK (teras_balance >= 0)
crafts Craft[]
/// @TypeGraphQL.omit(output: true, input: true)
refreshTokens RefreshToken[]
junks Junk[]
extracts Extract[]
rewards Reward[]
collectibleItem CollectibleItem[]
questChains QuestChain[]
currencyDeposits CurrencyDeposit[]
Dismantle Dismantle[]
Burn Burn[]
/// @TypeGraphQL.omit(output: true, input: true)
googleOneTimePurchases GoogleOneTimePurchase[]
appleOneTimePurchases AppleOneTimePurchase[]
paidTournamentEntries PaidTournamentEntry[]
/// @TypeGraphQL.omit(output: true, input: true)
ticketTransactions TicketTransaction[]
activeBoosters ActiveBooster[]
activeBoosterForTournaments ActiveBoosterForTournament[]
paidTournamentPrizeClaimIgnoreUser PaidTournamentPrizeClaimIgnoreUser?
@@map("users")
}
model MoralisSession {
// challenge request response contents
challengeId String @id @map("challenge_id")
message String
profileId String @map("profile_id")
// challenge verify response contents
version String?
nonce String?
// provided by user
walletAddress String @map("wallet_address") // case-insensitive
network String
chain String
// generated in backend
tokenHash String @unique @map("token_hash")
verified Boolean @default(false)
// timestamps
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
expiresAt DateTime @map("expires_at")
@@map("moralis_sessions")
}
model MagicSession {
issuer String @id
userId String? @map("user_id") @db.Uuid
user User? @relation(fields: [userId], references: [id])
lastLoginAt DateTime @map("last_login_at")
@@map("magic_sessions")
}
model RefreshToken {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
userId String @map("user_id") @db.Uuid
tokenHash String? @unique @map("token_hash")
expiresAt DateTime @map("expires_at")
user User @relation(fields: [userId], references: [id])
@@map("refresh_tokens")
}
model ArcadeMachine {
// common fields
// ランダムに生成されます。生成する方法が雑なので要調整。
// 1048576 = 2^20
// 8388608 = 2^23
// このコードの省略は要注意。例えば、::double precisionのキャストを削除すると
// postgres側で生成されます。意味が変わらないが、スキーマ側の文章と異なる文章
// になるので、prismaから見てスキーマとDBの差として検知されてしまい、また新しい
// migrationが自動生成されます。
id String @id @default(dbgenerated("((((floor((random() * (1048576)::double precision)))::bigint + ((floor((random() * (1048576)::double precision)))::bigint << 20)) + ((floor((random() * (8388608)::double precision)))::bigint << 40)))::text"))
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
userId String? @map("user_id") @db.Uuid
user User? @relation(fields: [userId], references: [id])
// token fields
/// @TypeGraphQL.omit(output: true)
ownerWalletAddress String? @map("owner_wallet_address") // case-insensitive
/// @TypeGraphQL.omit(output: true, input: true)
physicalWalletAddress String? @map("physical_wallet_address") // case-insensitive
state NftState @default(IN_AKIVERSE)
/// @TypeGraphQL.omit(output: true)
lastBlock Int @default(0) @map("last_block")
/// @TypeGraphQL.omit(output: true)
lastTransactionIndex Int @default(0) @map("last_transaction_index")
// arcade machine fields
game String
energy Int @default(0)
maxEnergy Int @default(0) @map("max_energy")
extractedEnergy Int @default(0) @map("extracted_energy")
boost Float @default(1)
autoRenewLease Boolean @default(false) @map("auto_renew_lease")
// game center fields
gameCenterId String? @map("game_center_id")
position Int? // 1 based indexing. Check Constraint exist
installedAt DateTime? @map("installed_at")
// relation fields
gameCenter GameCenter? @relation(fields: [gameCenterId], references: [id])
playSessions PlaySession[]
// Check constraints:
// 20221012021851_add_positon_value_check_constraint:
// position >= 1
// 20221013061342_create_withdrawals:
// game_center_id is null and position is null or state = 'IN_AKIVERSE'
accumulatorSubCategory String @map("accumulator_sub_category")
upperCabinetSubCategory String @default("PLAIN") @map("upper_cabinet_sub_category")
lowerCabinetSubCategory String @default("PLAIN") @map("lower_cabinet_sub_category")
craft Craft?
extracts Extract[]
feverSparkRemain Int? @map("fever_spark_remain") // null or 0 <= n <=30
destroyedAt DateTime? @map("destroyed_at")
dismantle Dismantle?
@@unique([gameCenterId, position])
@@index([userId])
@@index([gameCenterId])
@@map("arcade_machines")
}
model ArcadePart {
// common fields
id String @id @default(dbgenerated("((((floor((random() * (1048576)::double precision)))::bigint + ((floor((random() * (1048576)::double precision)))::bigint << 20)) + ((floor((random() * (8388608)::double precision)))::bigint << 40)))::text"))
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
userId String? @map("user_id") @db.Uuid
user User? @relation(fields: [userId], references: [id])
// token fields
/// @TypeGraphQL.omit(output: true)
ownerWalletAddress String? @map("owner_wallet_address") // case-insensitive
/// @TypeGraphQL.omit(output: true, input: true)
physicalWalletAddress String? @map("physical_wallet_address") // case-insensitive
state NftState @default(IN_AKIVERSE)
/// @TypeGraphQL.omit(output: true)
lastBlock Int @default(0) @map("last_block")
/// @TypeGraphQL.omit(output: true)
lastTransactionIndex Int @default(0) @map("last_transaction_index")
// arcade part fields
category ArcadePartCategory
subCategory String @map("sub_category")
destroyedAt DateTime? @map("destroyed_at")
craftId String? @map("craft_id") @db.Uuid
craft Craft? @relation(fields: [craftId], references: [id])
usedJunks Int? @map("used_junks")
createDismantle Dismantle? @relation(fields: [createDismantleId], references: [id])
createDismantleId String? @map("create_dismantle_id") @db.Uuid
@@index([userId])
@@index([craftId])
@@map("arcade_parts")
}
model GameCenter {
// common fields
id String @id
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
userId String? @map("user_id") @db.Uuid
// token fields
/// @TypeGraphQL.omit(output: true)
ownerWalletAddress String? @map("owner_wallet_address") // case-insensitive
/// @TypeGraphQL.omit(output: true, input: true)
physicalWalletAddress String? @map("physical_wallet_address") // case-insensitive
state NftState @default(IN_AKIVERSE)
name String
/// @TypeGraphQL.omit(output: true)
lastBlock Int @default(0) @map("last_block")
/// @TypeGraphQL.omit(output: true)
lastTransactionIndex Int @default(0) @map("last_transaction_index")
// game center fields
xCoordinate Int @map("x_coordinate")
yCoordinate Int @map("y_coordinate")
area GameCenterArea
size GameCenterSize
placementAllowed Boolean @default(false) @map("placement_allowed")
// relation fields
user User? @relation(fields: [userId], references: [id])
arcadeMachines ArcadeMachine[]
playSessions PlaySession[]
// Check constraints:
// 20221013061342_create_withdrawals:
// placement_allowed = false or state = 'IN_AKIVERSE'
@@index([userId])
@@map("game_centers")
}
model Withdrawal {
// common fields
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
// Token reference
tokenId String @map("token_id")
nftType NftType @map("nft_type")
// Withdrawal fields
userId String? @map("user_id") @db.Uuid
user User? @relation(fields: [userId], references: [id])
walletAddress String @map("wallet_address") // case-insensitive
state WithdrawalState @default(UNPROCESSED) @map("withdrawal_state")
type WithdrawalType?
hash String?
nonce Int?
response String?
signerAddress String? @map("signer_address") // case-insensitive
errorMessage String?
@@index([userId])
@@map("withdrawals")
}
model CurrencyWithdrawal {
// common fields
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
// Currency and amount
currencyType CurrencyType @map("currency_type")
amount Decimal @default(0) @db.Decimal(78, 0) // ルール付けたい 必ず0以上
// CurrencyWithdrawal fields
userId String? @map("user_id") @db.Uuid
user User? @relation(fields: [userId], references: [id])
walletAddress String @map("wallet_address") // case-insensitive
state WithdrawalState @default(UNPROCESSED) @map("withdrawal_state")
type WithdrawalType?
hash String?
nonce Int?
response String?
signerAddress String? @map("signer_address") // case-insensitive
errorMessage String? @map("error_message")
@@map("currency_withdrawals")
}
model Deposit {
// common fields
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
// Token reference
tokenId String @map("token_id")
nftType NftType @map("nft_type")
// Deposit fields
userId String? @map("user_id") @db.Uuid
user User? @relation(fields: [userId], references: [id])
walletAddress String? @map("wallet_address") // case-insensitive
state DepositState @default(UNPROCESSED) @map("deposit_state")
hash String?
@@index([userId])
@@map("deposits")
}
model Burn {
// common fields
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
// Token reference
tokenId String @map("token_id")
nftType NftType @map("nft_type")
// burn fields
userId String? @map("user_id") @db.Uuid
user User? @relation(fields: [userId], references: [id])
state BurnState @default(UNPROCESSED) @map("burn_state")
hash String?
nonce Int?
response String?
signerAddress String? @map("signer_address") // case-insensitive
errorMessage String?
@@index([userId])
@@map("burns")
}
model CurrencyDeposit {
// common fields
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
// Currency and amount
currencyType CurrencyType @map("currency_type")
amount Decimal @default(0) @db.Decimal(78, 0)
// Deposit fields
userId String @map("user_id") @db.Uuid
user User @relation(fields: [userId], references: [id])
walletAddress String @map("wallet_address") // case-insensitive
state DepositState @default(UNPROCESSED) @map("deposit_state")
hash String
@@index([userId])
@@index([hash, walletAddress])
@@map("currency_deposits")
}
model Transfer {
// common fields
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
// transaction fields
blockNumber Int @map("block_number")
blockHash String @map("block_hash")
transactionIndex Int @map("transaction_index")
transactionHash String @map("transaction_hash")
state TransferState @default(PENDING)
// transfer fields
nftType NftType @map("nft_type")
from String
to String
tokenId String @map("token_id")
@@unique([blockHash, transactionIndex, from, to, tokenId])
@@index([blockHash])
@@index([state])
@@index([tokenId])
@@map("transfers")
}
model CurrencyTransfer {
// common fields
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
// transaction fields
blockNumber Int @map("block_number")
blockHash String @map("block_hash")
transactionIndex Int @map("transaction_index")
transactionHash String @map("transaction_hash")
state TransferState @default(PENDING)
// transfer fields
currencyType CurrencyType @map("currency_type")
from String
to String
amount Decimal @default(0) @db.Decimal(78, 0)
@@unique([blockHash, transactionIndex, from, to, amount])
@@index([blockHash])
@@index([state])
@@map("currency_transfers")
}
model Block {
// common fields
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
// token fields
number Int
hash String @unique
parentHash String @map("parent_hash")
state BlockState @default(PENDING)
scanState BlockScanState @default(WATCHED) @map("scan_state")
@@index([parentHash])
@@index([number])
@@index([state])
@@index([scanState])
@@map("blocks")
}
model Play {
// common fields
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
playSessionId String @map("play_session_id") @db.Uuid
// unique constraint ON plays (play_session_id) WHERE (result is null)
endedAt DateTime? @map("ended_at")
score Int?
result PlayResult?
playSession PlaySession @relation(fields: [playSessionId], references: [id])
ownerTerasReward Decimal? @map("owner_teras_reward") @db.Decimal(78, 0)
playerTerasReward Decimal? @map("player_teras_reward") @db.Decimal(78, 0)
megaSpark Boolean @default(false) @map("mega_spark")
terasBoosterRatio Float? @map("teras_booster_ratio")
@@index([playSessionId])
@@index([endedAt])
@@index([result])
@@map("plays")
}
model PlaySession {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
endedAt DateTime? @map("ended_at")
playerId String @map("player_id") @db.Uuid
// unique constraint ON play_sessions (player_id) WHERE (state <> 'FINISHED')
arcadeMachineId String @map("arcade_machine_id")
// unique constraint ON play_sessions (arcade_machine_id) WHERE (state <> 'FINISHED')
// This constraint has been disabled in CBT2
arcadeMachineOwnerId String @map("arcade_machine_owner_id") @db.Uuid
gameCenterId String? @map("game_center_id")
gameCenterOwnerId String? @map("game_center_owner_id") @db.Uuid
difficulty Int?
targetScore Int? @map("target_score")
maxPlayCount Int? @map("max_play_count")
/// @TypeGraphQL.omit(output: true, input: true)
authToken String @unique @map("auth_token")
state PlaySessionState
fever Boolean @default(false)
// relation fields
arcadeMachine ArcadeMachine @relation(fields: [arcadeMachineId], references: [id])
arcadeMachineOwner User? @relation("arcadeMachineOwner", fields: [arcadeMachineOwnerId], references: [id])
gameCenter GameCenter? @relation(fields: [gameCenterId], references: [id])
gameCenterOwner User? @relation("gameCenterOwner", fields: [gameCenterOwnerId], references: [id])
player User @relation("player", fields: [playerId], references: [id])
plays Play[]
@@index([playerId])
@@index([arcadeMachineId])
@@index([arcadeMachineOwnerId])
@@index([gameCenterId])
@@index([gameCenterOwnerId])
@@index([createdAt])
@@index([state])
@@map("play_sessions")
}
model GameSetting {
game String @id
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
dailyMaxPlayCount Int @map("daily_max_play_count")
difficulty Int?
targetScore Int? @map("target_score")
// EASY_MODEのブースターが有効な時に使われる値
easyDifficulty Int? @map("easy_difficulty")
easyTargetScore Int? @map("easy_target_score")
@@map("game_settings")
}
model RentalFee {
date String // yyyyMMdd
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
arcadeMachineOwnerId String @map("arcade_machine_owner_id") @db.Uuid
arcadeMachineId String @map("arcade_machine_id")
gameCenterOwnerId String @map("game_center_owner_id") @db.Uuid
gameCenterId String @map("game_center_id")
fee Decimal @db.Decimal(78, 0)
collectState CollectState @default(UNPROCESSED) @map("collect_state")
collectDate DateTime? @map("collect_date")
paymentState PaymentState @default(UNPROCESSED) @map("payment_state")
paymentDate DateTime? @map("payment_date")
@@id([date, arcadeMachineId])
@@index([date, arcadeMachineId, arcadeMachineOwnerId])
@@index([date, gameCenterOwnerId, gameCenterId])
@@map("rental_fees")
}
model Notification {
/// @TypeGraphQL.omit(input: true)
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
userId String @map("user_id") @db.Uuid
notificationType NotificationType @map("notification_type")
tokenId String? @map("token_id") // イベントがToken複数に対しての場合があるのでNull許容
nftType NftType @map("nft_type")
/// @TypeGraphQL.omit(input: true)
messageJson Json @map("message_json") // 1行のメッセージ
/// @TypeGraphQL.omit(input: true)
messageDetailJson Json? @map("message_detail_json") // 詳細
/// @TypeGraphQL.omit(input: true)
user User @relation(fields: [userId], references: [id])
@@index([userId, notificationType])
@@map("notifications")
}
model AccessLog {
date String
// ログを結合したりしないし、リレーションしてしまうとUser消す時にログも消えてしまうしと
// DB的にリレーションを貼る必要性がない
userId String @map("user_id") @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
accessCount Int @default(1) @map("access_count")
@@id([date, userId])
@@map("access_logs")
}
model Craft {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
userId String @map("user_id") @db.Uuid
craftedArcadeMachineId String @unique @map("crafted_arcade_machine_id")
usedTerasBalance Decimal @map("used_teras_balance") @db.Decimal(78, 0)
usedAkvBalance Decimal @default(0) @map("used_akv_balance") @db.Decimal(78, 0)
// relation
user User @relation(fields: [userId], references: [id])
craftedArcadeMachine ArcadeMachine @relation(fields: [craftedArcadeMachineId], references: [id])
arcadeParts ArcadePart[]
@@index([userId])
@@map("craft")
}
model Junk {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
userId String @map("user_id") @db.Uuid
user User @relation(fields: [userId], references: [id])
category ArcadePartCategory
subCategory String @map("sub_category")
amount Int
// 20230523065158_add_open_beta_phase_1_tables_and_columns
// amount over zero check constraint
// userId/category/subCategoryでユニークにする
@@unique([userId, category, subCategory])
@@index([userId])
@@map("junks")
}
model ExtractJunkInventory {
category String
subCategory String @map("sub_category")
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
amount Int
// 20230523065158_add_open_beta_phase_1_tables_and_columns
// amount over zero check constraint
@@id([category, subCategory])
@@map("extract_junk_inventories")
}
enum ExtractableItemType {
ARCADE_PART
JUNK_PART
@@map("extractable_item_type")
}
model ExtractInitialInventory {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
seasonId String @map("season_id")
itemType ExtractableItemType @map("item_type")
category String
subCategory String @map("sub_category")
initialAmount Int @map("initial_amount")
featuredItem Boolean @map("featured_item")
@@unique([seasonId, itemType, category, subCategory]) // Seasonごとに各Item1行まで
@@index([seasonId])
@@map("extract_initial_inventories")
}
model Season {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
startAt DateTime @map("start_at")
endAt DateTime? @map("end_at")
baseExtractItemCount Int @map("base_extract_item_count") // 基準排出数
@@map("seasons")
}
model Extract {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
userId String @map("user_id") @db.Uuid
user User @relation(fields: [userId], references: [id])
arcadeMachineId String @map("arcade_machine_id")
arcadeMachine ArcadeMachine @relation(fields: [arcadeMachineId], references: [id])
extractArcadePartsCount Int @map("extract_arcade_parts_count")
extractJunkPartsCount Int @map("extract_junk_parts_count")
extractDetail Json @map("extract_detail")
@@index([userId])
@@index([arcadeMachineId])
@@map("extracts")
}
model Reward {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
title String
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
userId String @map("user_id") @db.Uuid
user User @relation(fields: [userId], references: [id])
rewardItemType RewardItemType @map("reward_item_type")
category RewardCategory
subCategory String? @map("sub_category")
// Terasの量が入る場合もあるが、現実的に配布する桁数であればIntで足りる想定
amount Int
// 受け取り期限 nullの場合は無期限
availableUntil DateTime? @map("available_until")
// 受け取り日 not null = 受け取り済
acceptedAt DateTime? @map("accepted_at")
@@index([userId])
@@map("rewards")
}
// 消費系アイテム
// 現状仕様が確定していないのでコメントアウト
// model ConsumptionItem {
// id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
// createdAt DateTime @default(now()) @map("created_at")
// /// @TypeGraphQL.omit(output: true, input: true)
// updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
// userId String @map("user_id") @db.Uuid
// user User @relation(fields: [userId], references: [id])
// category String
// subCategory String
// expiredAt DateTime?
// used Boolean @default(false)
// }
// だいじなもの
enum CollectibleItemCategory {
ICON
TITLE
FRAME
@@map("collectible_item_category")
}
model CollectibleItem {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
userId String @map("user_id") @db.Uuid
user User @relation(fields: [userId], references: [id])
category CollectibleItemCategory
subCategory String @map("sub_category")
@@unique([userId, category, subCategory])
@@index([userId])
@@map("collectible_items")
}
model QuestChain {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
userId String @map("user_id") @db.Uuid
user User @relation(fields: [userId], references: [id])
questChainMasterId String @map("quest_chain_master_id")
completed Boolean @default(false)
acceptedAt DateTime @default(now()) @map("accepted_at")
expiredAt DateTime? @map("expired_at")
quests Quest[]
@@unique([userId, questChainMasterId])
@@index([userId])
@@map("quest_chains")
}
model Quest {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
questChainId String @map("quest_chain_id") @db.Uuid
questChain QuestChain @relation(fields: [questChainId], references: [id])
questMasterId String @map("quest_master_id")
startAt DateTime @default(now()) @map("start_at")
completedAt DateTime? @map("completed_at")
@@unique([questChainId, questMasterId])
@@index([questChainId])
@@map("quests")
}
enum NewsCategory {
INFO
EVENT
PROMO
@@map("news_category")
}
model News {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
category NewsCategory
title String
externalLink String? @map("external_link")
display Boolean @default(true)
startAt DateTime? @map("start_at")
endAt DateTime? @map("end_at")
@@map("news")
}
model Banner {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at")
/// @TypeGraphQL.omit(output: true, input: true)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
mainImageUrl String @map("main_image_url")
bgImageUrl String @map("bg_image_url")
externalLink String? @map("external_link")
display Boolean @default(true)
startAt DateTime? @map("start_at")
endAt DateTime? @map("end_at")
frontEndType FrontEndType @default(WM) @map("front_end_type")
targetArea String? @map("target_area") // 国コードカンマ区切り
description String? // レコードの説明、スプシのIDなどを記録するためのカラム
@@map("banners")
}