From 94056b59ef80d52e242b0c3a0226bed0f3b912fb Mon Sep 17 00:00:00 2001 From: Niek Candaele <22315101+niekcandaele@users.noreply.github.com> Date: Fri, 24 Jul 2020 17:24:29 +0200 Subject: [PATCH] Define data schema for CSGO stats (#25) --- entities/bombStatus.entity.ts | 50 +++ entities/kill.entity.ts | 55 +++ entities/match.entity.ts | 6 +- entities/playerBlind.entity.ts | 48 +++ entities/playerHurt.entity.ts | 56 +++ entities/playerInfo.entity.ts | 69 ++++ entities/playerJump.entity.ts | 38 ++ entities/position.entity.ts | 25 ++ entities/round.entity.ts | 35 ++ entities/team.entity.ts | 43 ++ entities/utilityActivated.entity.ts | 51 +++ entities/utilityThrown.entity.ts | 56 +++ entities/weaponStatus.entity.ts | 49 +++ metadata.json | 2 +- .../1595532035147-Add-lots-ingame-info.ts | 261 ++++++++++++ .../1595598314317-fix-one-to-one-joins.ts | 371 ++++++++++++++++++ types/BombStatusChange.enum.ts | 9 + types/HurtSources.enum.ts | 5 + types/RoundWinReason.enum.ts | 6 + types/Weapon.enum.ts | 36 ++ types/WeaponStatusChange.enum.ts | 14 + types/utilityType.enum.ts | 9 + 22 files changed, 1292 insertions(+), 2 deletions(-) create mode 100644 entities/bombStatus.entity.ts create mode 100644 entities/kill.entity.ts create mode 100644 entities/playerBlind.entity.ts create mode 100644 entities/playerHurt.entity.ts create mode 100644 entities/playerInfo.entity.ts create mode 100644 entities/playerJump.entity.ts create mode 100644 entities/position.entity.ts create mode 100644 entities/round.entity.ts create mode 100644 entities/team.entity.ts create mode 100644 entities/utilityActivated.entity.ts create mode 100644 entities/utilityThrown.entity.ts create mode 100644 entities/weaponStatus.entity.ts create mode 100644 migrations/1595532035147-Add-lots-ingame-info.ts create mode 100644 migrations/1595598314317-fix-one-to-one-joins.ts create mode 100644 types/BombStatusChange.enum.ts create mode 100644 types/HurtSources.enum.ts create mode 100644 types/RoundWinReason.enum.ts create mode 100644 types/Weapon.enum.ts create mode 100644 types/WeaponStatusChange.enum.ts create mode 100644 types/utilityType.enum.ts diff --git a/entities/bombStatus.entity.ts b/entities/bombStatus.entity.ts new file mode 100644 index 0000000..4842653 --- /dev/null +++ b/entities/bombStatus.entity.ts @@ -0,0 +1,50 @@ +import { + BaseEntity, + Column, + CreateDateColumn, + Entity, + JoinColumn, + ManyToOne, + OneToOne, + PrimaryGeneratedColumn +} from 'typeorm'; +import { BombStatusChange } from 'types/BombStatusChange.enum'; + +import { PlayerInfo } from './playerInfo.entity'; +import { Position } from './position.entity'; +import { Round } from './round.entity'; + +/** + * Database record + */ +@Entity() +export class BombStatus extends BaseEntity { + /** + * Primary key + */ + @PrimaryGeneratedColumn() + id: number; + + @CreateDateColumn() + createdAt: Date; + + @Column() + tick: number; + + @Column({ + type: "enum", + enum: Object.values(BombStatusChange) + }) + type: BombStatusChange; + + @OneToOne(() => PlayerInfo) + @JoinColumn() + player: PlayerInfo; + + @OneToOne(() => Position) + @JoinColumn() + position: Position; + + @ManyToOne(() => Round) + round: Round; +} diff --git a/entities/kill.entity.ts b/entities/kill.entity.ts new file mode 100644 index 0000000..3cf1447 --- /dev/null +++ b/entities/kill.entity.ts @@ -0,0 +1,55 @@ +import { + BaseEntity, + Column, + CreateDateColumn, + Entity, + JoinColumn, + ManyToOne, + OneToOne, + PrimaryGeneratedColumn +} from 'typeorm'; + +import { PlayerInfo } from './playerInfo.entity'; +import { Round } from './round.entity'; + +/** + * Database record + */ +@Entity() +export class Kill extends BaseEntity { + /** + * Primary key + */ + @PrimaryGeneratedColumn() + id: number; + + @CreateDateColumn() + createdAt: Date; + + @Column() + tick: number; + + @Column() + throughSmoke: boolean; + + @Column() + whileBlind: boolean; + + @Column() + throughWall: boolean; + + @OneToOne(() => PlayerInfo) + @JoinColumn() + attacker: PlayerInfo; + + @OneToOne(() => PlayerInfo) + @JoinColumn() + victim: PlayerInfo; + + @OneToOne(() => PlayerInfo, { nullable: true }) + @JoinColumn() + assister: PlayerInfo; + + @ManyToOne(() => Round) + round: Round; +} diff --git a/entities/match.entity.ts b/entities/match.entity.ts index 98e4fb6..72fc723 100644 --- a/entities/match.entity.ts +++ b/entities/match.entity.ts @@ -1,7 +1,8 @@ -import { BaseEntity, Column, Entity, JoinTable, ManyToMany, PrimaryGeneratedColumn, Unique } from 'typeorm'; +import { BaseEntity, Column, Entity, JoinTable, ManyToMany, OneToMany, PrimaryGeneratedColumn, Unique } from 'typeorm'; import { IMatchType } from '../types/matchType.interface'; import { Player } from './player.entity'; +import { Round } from './round.entity'; /** * Match database record @@ -63,4 +64,7 @@ export class Match extends BaseEntity { @ManyToMany(() => Player, (player) => player.matches) @JoinTable() players: Player[]; + + @OneToMany(() => Round, (round) => round.match) + rounds: Round[]; } diff --git a/entities/playerBlind.entity.ts b/entities/playerBlind.entity.ts new file mode 100644 index 0000000..59591e2 --- /dev/null +++ b/entities/playerBlind.entity.ts @@ -0,0 +1,48 @@ +import { + BaseEntity, + Column, + CreateDateColumn, + Entity, + JoinColumn, + ManyToOne, + OneToOne, + PrimaryGeneratedColumn +} from 'typeorm'; + +import { PlayerInfo } from './playerInfo.entity'; +import { Round } from './round.entity'; + +/** + * Database record + */ +@Entity() +export class PlayerBlind extends BaseEntity { + /** + * Primary key + */ + @PrimaryGeneratedColumn() + id: number; + + @CreateDateColumn() + createdAt: Date; + + @Column() + tick: number; + + /** + * How long a player was blinded, in ticks + */ + @Column() + duration: number; + + @OneToOne(() => PlayerInfo) + @JoinColumn() + attacker: PlayerInfo; + + @OneToOne(() => PlayerInfo) + @JoinColumn() + victim: PlayerInfo; + + @ManyToOne(() => Round) + round: Round; +} diff --git a/entities/playerHurt.entity.ts b/entities/playerHurt.entity.ts new file mode 100644 index 0000000..061474b --- /dev/null +++ b/entities/playerHurt.entity.ts @@ -0,0 +1,56 @@ +import { + BaseEntity, + Column, + CreateDateColumn, + Entity, + JoinColumn, + ManyToOne, + OneToOne, + PrimaryGeneratedColumn +} from 'typeorm'; +import { HurtSources } from 'types/HurtSources.enum'; + +import { PlayerInfo } from './playerInfo.entity'; +import { Round } from './round.entity'; + +/** + * Database record + */ +@Entity() +export class PlayerHurt extends BaseEntity { + /** + * Primary key + */ + @PrimaryGeneratedColumn() + id: number; + + @CreateDateColumn() + createdAt: Date; + + @Column() + tick: number; + + @Column() + damageArmour: number; + + @Column() + damageHealth: number; + + // TODO: Should be an enum but cba checking what values are possible right now :) + @Column() + hitGroup: number; + + @Column() + source: HurtSources; + + @OneToOne(() => PlayerInfo) + @JoinColumn() + attacker: PlayerInfo; + + @OneToOne(() => PlayerInfo) + @JoinColumn() + victim: PlayerInfo; + + @ManyToOne(() => Round) + round: Round; +} diff --git a/entities/playerInfo.entity.ts b/entities/playerInfo.entity.ts new file mode 100644 index 0000000..9416e5c --- /dev/null +++ b/entities/playerInfo.entity.ts @@ -0,0 +1,69 @@ +import { + BaseEntity, + Column, + CreateDateColumn, + Entity, + JoinColumn, + ManyToOne, + OneToOne, + PrimaryGeneratedColumn +} from 'typeorm'; +import { Weapon } from 'types/Weapon.enum'; + +import { Player } from './player.entity'; +import { Position } from './position.entity'; + +/** + * Database record + */ +@Entity() +export class PlayerInfo extends BaseEntity { + /** + * Primary key + */ + @PrimaryGeneratedColumn() + id: number; + + @CreateDateColumn() + createdAt: Date; + + @Column() + tick: number; + + @Column() + equipmentValue: number; + + @Column() + freezeTimeEndEquipmentValue: number; + + @Column() + cashSpentInRound: number; + + @Column() + hasC4: boolean; + + @Column() + health: number; + + @Column() + armour: number; + + @Column() + isScoped: boolean; + + @Column({ + type: "enum", + enum: Object.values(Weapon) + }) + weapon: Weapon; + + @Column() + bulletsInMagazine: number; + + @OneToOne(() => Position) + @JoinColumn() + position: Position; + + @ManyToOne(() => Player) + player: Player; +} diff --git a/entities/playerJump.entity.ts b/entities/playerJump.entity.ts new file mode 100644 index 0000000..3a166e9 --- /dev/null +++ b/entities/playerJump.entity.ts @@ -0,0 +1,38 @@ +import { + BaseEntity, + Column, + CreateDateColumn, + Entity, + JoinColumn, + ManyToOne, + OneToOne, + PrimaryGeneratedColumn +} from 'typeorm'; + +import { PlayerInfo } from './playerInfo.entity'; +import { Round } from './round.entity'; + +/** + * Database record + */ +@Entity() +export class PlayerJump extends BaseEntity { + /** + * Primary key + */ + @PrimaryGeneratedColumn() + id: number; + + @CreateDateColumn() + createdAt: Date; + + @Column() + tick: number; + + @OneToOne(() => PlayerInfo) + @JoinColumn() + player: PlayerInfo; + + @ManyToOne(() => Round) + round: Round; +} diff --git a/entities/position.entity.ts b/entities/position.entity.ts new file mode 100644 index 0000000..e5d323c --- /dev/null +++ b/entities/position.entity.ts @@ -0,0 +1,25 @@ +import { BaseEntity, Column, CreateDateColumn, Entity, PrimaryGeneratedColumn } from 'typeorm'; + +/** + * Database record + */ +@Entity() +export class Position extends BaseEntity { + /** + * Primary key + */ + @PrimaryGeneratedColumn() + id: number; + + @CreateDateColumn() + createdAt: Date; + + @Column() + x: number; + + @Column() + y: number; + + @Column() + z: number; +} diff --git a/entities/round.entity.ts b/entities/round.entity.ts new file mode 100644 index 0000000..fcdcc68 --- /dev/null +++ b/entities/round.entity.ts @@ -0,0 +1,35 @@ +import { BaseEntity, Column, CreateDateColumn, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; +import { RoundWinReason } from 'types/RoundWinReason.enum'; + +import { Match } from './match.entity'; +import { Team } from './team.entity'; + +/** + * Database record + */ +@Entity() +export class Round extends BaseEntity { + /** + * Primary key + */ + @PrimaryGeneratedColumn() + id: number; + + @CreateDateColumn() + createdAt: Date; + + @Column() + startTick: number; + + @Column() + endTick: number; + + @Column() + winReason: RoundWinReason; + + @ManyToOne(() => Match, (match) => match.rounds) + match: Match; + + @OneToMany(() => Team, (team) => team.roundsWon) + winningTeam: Team; +} diff --git a/entities/team.entity.ts b/entities/team.entity.ts new file mode 100644 index 0000000..32547d4 --- /dev/null +++ b/entities/team.entity.ts @@ -0,0 +1,43 @@ +import { + BaseEntity, + Column, + CreateDateColumn, + Entity, + JoinTable, + ManyToMany, + ManyToOne, + PrimaryGeneratedColumn +} from 'typeorm'; + +import { Match } from './match.entity'; +import { Player } from './player.entity'; +import { Round } from './round.entity'; + +/** + * Database record + */ +@Entity() +export class Team extends BaseEntity { + /** + * Primary key + */ + @PrimaryGeneratedColumn() + id: number; + + @CreateDateColumn() + createdAt: Date; + + @Column({ nullable: true }) + name: string; + + @ManyToMany(() => Player) + @JoinTable() + players: Player[]; + + @ManyToMany(() => Match) + @JoinTable() + matches: Match[]; + + @ManyToOne(() => Round) + roundsWon: Round[]; +} diff --git a/entities/utilityActivated.entity.ts b/entities/utilityActivated.entity.ts new file mode 100644 index 0000000..c307173 --- /dev/null +++ b/entities/utilityActivated.entity.ts @@ -0,0 +1,51 @@ +import { + BaseEntity, + Column, + CreateDateColumn, + Entity, + JoinColumn, + ManyToOne, + OneToOne, + PrimaryGeneratedColumn +} from 'typeorm'; +import { UtilityType } from 'types/utilityType.enum'; + +import { Position } from './position.entity'; +import { Round } from './round.entity'; + +/** + * Database record + */ +@Entity() +export class UtilityActivated extends BaseEntity { + /** + * Primary key + */ + @PrimaryGeneratedColumn() + id: number; + + @CreateDateColumn() + createdAt: Date; + + @Column() + tick: number; + + @Column({ + type: "enum", + enum: Object.values(UtilityType) + }) + type: UtilityType; + + /** + * ID of the ingame entity + */ + @Column() + entityId: number; + + @OneToOne(() => Position) + @JoinColumn() + position: Position; + + @ManyToOne(() => Round) + round: Round; +} diff --git a/entities/utilityThrown.entity.ts b/entities/utilityThrown.entity.ts new file mode 100644 index 0000000..69c8c12 --- /dev/null +++ b/entities/utilityThrown.entity.ts @@ -0,0 +1,56 @@ +import { + BaseEntity, + Column, + CreateDateColumn, + Entity, + JoinColumn, + ManyToOne, + OneToOne, + PrimaryGeneratedColumn +} from 'typeorm'; +import { UtilityType } from 'types/utilityType.enum'; + +import { PlayerInfo } from './playerInfo.entity'; +import { Position } from './position.entity'; +import { Round } from './round.entity'; + +/** + * Database record + */ +@Entity() +export class UtilityThrown extends BaseEntity { + /** + * Primary key + */ + @PrimaryGeneratedColumn() + id: number; + + @CreateDateColumn() + createdAt: Date; + + @Column() + tick: number; + + @Column({ + type: "enum", + enum: Object.values(UtilityType) + }) + type: UtilityType; + + /** + * ID of the ingame entity + */ + @Column() + entityId: number; + + @OneToOne(() => PlayerInfo) + @JoinColumn() + player: PlayerInfo; + + @OneToOne(() => Position) + @JoinColumn() + position: Position; + + @ManyToOne(() => Round) + round: Round; +} diff --git a/entities/weaponStatus.entity.ts b/entities/weaponStatus.entity.ts new file mode 100644 index 0000000..cfab7c7 --- /dev/null +++ b/entities/weaponStatus.entity.ts @@ -0,0 +1,49 @@ +import { + BaseEntity, + Column, + CreateDateColumn, + Entity, + JoinColumn, + ManyToOne, + OneToOne, + PrimaryGeneratedColumn +} from 'typeorm'; +import { Weapon } from 'types/Weapon.enum'; +import { WeaponStatusChange } from 'types/WeaponStatusChange.enum'; + +import { PlayerInfo } from './playerInfo.entity'; +import { Round } from './round.entity'; + +/** + * Database record + */ +@Entity() +export class WeaponStatus extends BaseEntity { + /** + * Primary key + */ + @PrimaryGeneratedColumn() + id: number; + + @CreateDateColumn() + createdAt: Date; + + @Column() + tick: number; + + @Column({ + type: "enum", + enum: Object.values(Weapon) + }) + weapon: Weapon; + + @Column() + type: WeaponStatusChange; + + @OneToOne(() => PlayerInfo) + @JoinColumn() + player: PlayerInfo; + + @ManyToOne(() => Round) + round: Round; +} diff --git a/metadata.json b/metadata.json index 251baa8..739c446 100644 --- a/metadata.json +++ b/metadata.json @@ -1 +1 @@ -{"version":2,"tables":[{"table":{"schema":"public","name":"ban"},"object_relationships":[{"name":"player","using":{"foreign_key_constraint_on":"playerId"}}],"select_permissions":[{"role":"user","permission":{"columns":["detectedAt","id","playerId","preExisting","type","unbanned","unbannedAt"],"filter":{},"allow_aggregations":true}}]},{"table":{"schema":"public","name":"match"},"array_relationships":[{"name":"players","using":{"foreign_key_constraint_on":{"column":"matchId","table":{"schema":"public","name":"match_players_player"}}}}],"select_permissions":[{"role":"user","permission":{"columns":["date","durationTicks","externalId","id","map","tickrate","type","typeExtended"],"filter":{},"limit":250,"allow_aggregations":true}}]},{"table":{"schema":"public","name":"match_players_player"},"object_relationships":[{"name":"match","using":{"foreign_key_constraint_on":"matchId"}},{"name":"player","using":{"foreign_key_constraint_on":"playerId"}}],"select_permissions":[{"role":"user","permission":{"columns":["matchId","playerId"],"filter":{},"allow_aggregations":true}}]},{"table":{"schema":"public","name":"notification"},"object_relationships":[{"name":"ban","using":{"foreign_key_constraint_on":"banId"}},{"name":"user","using":{"foreign_key_constraint_on":"userId"}}],"select_permissions":[{"role":"user","permission":{"columns":["banId","createdAt","deleted","id","seen","userId"],"filter":{"userId":{"_eq":"X-Hasura-User-Id"}},"limit":100,"allow_aggregations":true}}]},{"table":{"schema":"public","name":"notification_bans_ban"},"object_relationships":[{"name":"ban","using":{"foreign_key_constraint_on":"banId"}},{"name":"notification","using":{"foreign_key_constraint_on":"notificationId"}}],"select_permissions":[{"role":"user","permission":{"columns":["banId","notificationId"],"filter":{"notification":{"userId":{"_eq":"X-Hasura-User-Id"}}},"limit":200,"allow_aggregations":true}}]},{"table":{"schema":"public","name":"player"},"array_relationships":[{"name":"bans","using":{"foreign_key_constraint_on":{"column":"playerId","table":{"schema":"public","name":"ban"}}}},{"name":"followedBy","using":{"foreign_key_constraint_on":{"column":"playerId","table":{"schema":"public","name":"player_followed_by_user"}}}},{"name":"matches","using":{"foreign_key_constraint_on":{"column":"playerId","table":{"schema":"public","name":"match_players_player"}}}},{"name":"trackedBy","using":{"foreign_key_constraint_on":{"column":"playerId","table":{"schema":"public","name":"player_tracked_by_user"}}}}],"select_permissions":[{"role":"user","permission":{"columns":["createdAt","id","lastCheckedAt","steamAvatar","steamId","steamProfile","steamUsername"],"filter":{},"allow_aggregations":true}}]},{"table":{"schema":"public","name":"player_followed_by_user"},"object_relationships":[{"name":"player","using":{"foreign_key_constraint_on":"playerId"}},{"name":"user","using":{"foreign_key_constraint_on":"userId"}}],"select_permissions":[{"role":"user","permission":{"columns":["playerId","userId"],"filter":{"userId":{"_eq":"X-Hasura-User-Id"}},"allow_aggregations":true}}]},{"table":{"schema":"public","name":"player_tracked_by_user"},"object_relationships":[{"name":"player","using":{"foreign_key_constraint_on":"playerId"}},{"name":"user","using":{"foreign_key_constraint_on":"userId"}}],"select_permissions":[{"role":"user","permission":{"columns":["playerId","userId"],"filter":{"userId":{"_eq":"X-Hasura-User-Id"}},"allow_aggregations":true}}]},{"table":{"schema":"public","name":"user"},"object_relationships":[{"name":"settings","using":{"foreign_key_constraint_on":"settingsId"}}],"array_relationships":[{"name":"follows","using":{"foreign_key_constraint_on":{"column":"userId","table":{"schema":"public","name":"player_followed_by_user"}}}},{"name":"notifications","using":{"foreign_key_constraint_on":{"column":"userId","table":{"schema":"public","name":"notification"}}}},{"name":"tracks","using":{"foreign_key_constraint_on":{"column":"userId","table":{"schema":"public","name":"player_tracked_by_user"}}}}],"select_permissions":[{"role":"user","permission":{"columns":["discordId","faceitId","faceitName","id","lastCheckedAtFaceit","lastCheckedAtSteam","role","settingsId","steamId","username"],"filter":{"id":{"_eq":"X-Hasura-User-Id"}}}}]},{"table":{"schema":"public","name":"user_settings"},"object_relationships":[{"name":"user","using":{"manual_configuration":{"remote_table":{"schema":"public","name":"user"},"column_mapping":{"id":"settingsId"}}}}],"select_permissions":[{"role":"user","permission":{"columns":["lastKnownMatch","matchAuthCode","notificationCommunityEnabled","notificationDiscordEnabled","notificationEconomyEnabled","notificationFaceitEnabled","notificationGameEnabled","notificationVACEnabled"],"filter":{"user":{"id":{"_eq":"X-Hasura-User-Id"}}}}}]}]} \ No newline at end of file +{"version":2,"tables":[{"table":{"schema":"public","name":"ban"},"object_relationships":[{"name":"player","using":{"foreign_key_constraint_on":"playerId"}}],"select_permissions":[{"role":"user","permission":{"columns":["detectedAt","id","playerId","preExisting","type","unbanned","unbannedAt"],"filter":{},"allow_aggregations":true}}]},{"table":{"schema":"public","name":"bomb_status"},"object_relationships":[{"name":"player_info","using":{"foreign_key_constraint_on":"playerId"}},{"name":"position","using":{"foreign_key_constraint_on":"positionId"}},{"name":"round","using":{"foreign_key_constraint_on":"roundId"}}],"select_permissions":[{"role":"user","permission":{"columns":["createdAt","id","playerId","positionId","roundId","tick","type"],"filter":{},"limit":200,"allow_aggregations":true}}]},{"table":{"schema":"public","name":"kill"},"object_relationships":[{"name":"assister","using":{"foreign_key_constraint_on":"assisterId"}},{"name":"attacker","using":{"foreign_key_constraint_on":"attackerId"}},{"name":"round","using":{"foreign_key_constraint_on":"roundId"}},{"name":"victim","using":{"foreign_key_constraint_on":"victimId"}}],"select_permissions":[{"role":"user","permission":{"columns":["assisterId","attackerId","createdAt","id","roundId","throughSmoke","throughWall","tick","victimId","whileBlind"],"filter":{},"limit":200,"allow_aggregations":true}}]},{"table":{"schema":"public","name":"match"},"array_relationships":[{"name":"players","using":{"foreign_key_constraint_on":{"column":"matchId","table":{"schema":"public","name":"match_players_player"}}}},{"name":"rounds","using":{"foreign_key_constraint_on":{"column":"matchId","table":{"schema":"public","name":"round"}}}},{"name":"team_matches_matches","using":{"foreign_key_constraint_on":{"column":"matchId","table":{"schema":"public","name":"team_matches_match"}}}}],"select_permissions":[{"role":"user","permission":{"columns":["date","durationTicks","externalId","id","map","tickrate","type","typeExtended"],"filter":{},"limit":250,"allow_aggregations":true}}]},{"table":{"schema":"public","name":"match_players_player"},"object_relationships":[{"name":"match","using":{"foreign_key_constraint_on":"matchId"}},{"name":"player","using":{"foreign_key_constraint_on":"playerId"}}],"select_permissions":[{"role":"user","permission":{"columns":["matchId","playerId"],"filter":{},"allow_aggregations":true}}]},{"table":{"schema":"public","name":"notification"},"object_relationships":[{"name":"ban","using":{"foreign_key_constraint_on":"banId"}},{"name":"user","using":{"foreign_key_constraint_on":"userId"}}],"select_permissions":[{"role":"user","permission":{"columns":["banId","createdAt","deleted","id","seen","userId"],"filter":{"userId":{"_eq":"X-Hasura-User-Id"}},"limit":100,"allow_aggregations":true}}]},{"table":{"schema":"public","name":"notification_bans_ban"},"object_relationships":[{"name":"ban","using":{"foreign_key_constraint_on":"banId"}},{"name":"notification","using":{"foreign_key_constraint_on":"notificationId"}}],"select_permissions":[{"role":"user","permission":{"columns":["banId","notificationId"],"filter":{"notification":{"userId":{"_eq":"X-Hasura-User-Id"}}},"limit":200,"allow_aggregations":true}}]},{"table":{"schema":"public","name":"player"},"array_relationships":[{"name":"bans","using":{"foreign_key_constraint_on":{"column":"playerId","table":{"schema":"public","name":"ban"}}}},{"name":"followedBy","using":{"foreign_key_constraint_on":{"column":"playerId","table":{"schema":"public","name":"player_followed_by_user"}}}},{"name":"matches","using":{"foreign_key_constraint_on":{"column":"playerId","table":{"schema":"public","name":"match_players_player"}}}},{"name":"player_infos","using":{"foreign_key_constraint_on":{"column":"playerId","table":{"schema":"public","name":"player_info"}}}},{"name":"team_players_players","using":{"foreign_key_constraint_on":{"column":"playerId","table":{"schema":"public","name":"team_players_player"}}}},{"name":"trackedBy","using":{"foreign_key_constraint_on":{"column":"playerId","table":{"schema":"public","name":"player_tracked_by_user"}}}}],"select_permissions":[{"role":"user","permission":{"columns":["createdAt","id","lastCheckedAt","steamAvatar","steamId","steamProfile","steamUsername"],"filter":{},"allow_aggregations":true}}]},{"table":{"schema":"public","name":"player_blind"},"object_relationships":[{"name":"attacker","using":{"foreign_key_constraint_on":"attackerId"}},{"name":"round","using":{"foreign_key_constraint_on":"roundId"}},{"name":"victim","using":{"foreign_key_constraint_on":"victimId"}}],"select_permissions":[{"role":"user","permission":{"columns":["attackerId","createdAt","duration","id","roundId","tick","victimId"],"filter":{},"limit":200,"allow_aggregations":true}}]},{"table":{"schema":"public","name":"player_followed_by_user"},"object_relationships":[{"name":"player","using":{"foreign_key_constraint_on":"playerId"}},{"name":"user","using":{"foreign_key_constraint_on":"userId"}}],"select_permissions":[{"role":"user","permission":{"columns":["playerId","userId"],"filter":{"userId":{"_eq":"X-Hasura-User-Id"}},"allow_aggregations":true}}]},{"table":{"schema":"public","name":"player_hurt"},"object_relationships":[{"name":"attacker","using":{"foreign_key_constraint_on":"attackerId"}},{"name":"round","using":{"foreign_key_constraint_on":"roundId"}},{"name":"victim","using":{"foreign_key_constraint_on":"victimId"}}],"select_permissions":[{"role":"user","permission":{"columns":["attackerId","createdAt","damageArmour","damageHealth","hitGroup","id","roundId","source","tick","victimId"],"filter":{},"limit":200,"allow_aggregations":true}}]},{"table":{"schema":"public","name":"player_info"},"object_relationships":[{"name":"player","using":{"foreign_key_constraint_on":"playerId"}}],"select_permissions":[{"role":"user","permission":{"columns":["id","createdAt","tick","equipmentValue","freezeTimeEndEquipmentValue","cashSpentInRound","hasC4","health","armour","isScoped","weapon","bulletsInMagazine","playerId"],"filter":{},"limit":200,"allow_aggregations":true}}]},{"table":{"schema":"public","name":"player_jump"},"object_relationships":[{"name":"player","using":{"foreign_key_constraint_on":"playerId"}},{"name":"round","using":{"foreign_key_constraint_on":"roundId"}}],"select_permissions":[{"role":"user","permission":{"columns":["createdAt","id","playerId","roundId","tick"],"filter":{},"limit":200,"allow_aggregations":true}}]},{"table":{"schema":"public","name":"player_tracked_by_user"},"object_relationships":[{"name":"player","using":{"foreign_key_constraint_on":"playerId"}},{"name":"user","using":{"foreign_key_constraint_on":"userId"}}],"select_permissions":[{"role":"user","permission":{"columns":["playerId","userId"],"filter":{"userId":{"_eq":"X-Hasura-User-Id"}},"allow_aggregations":true}}]},{"table":{"schema":"public","name":"position"},"select_permissions":[{"role":"user","permission":{"columns":["id","createdAt","x","y","z"],"filter":{},"limit":200,"allow_aggregations":true}}]},{"table":{"schema":"public","name":"round"},"object_relationships":[{"name":"match","using":{"foreign_key_constraint_on":"matchId"}}],"array_relationships":[{"name":"bomb_statuses","using":{"foreign_key_constraint_on":{"column":"roundId","table":{"schema":"public","name":"bomb_status"}}}},{"name":"kills","using":{"foreign_key_constraint_on":{"column":"roundId","table":{"schema":"public","name":"kill"}}}},{"name":"player_blinds","using":{"foreign_key_constraint_on":{"column":"roundId","table":{"schema":"public","name":"player_blind"}}}},{"name":"player_hurts","using":{"foreign_key_constraint_on":{"column":"roundId","table":{"schema":"public","name":"player_hurt"}}}},{"name":"player_jumps","using":{"foreign_key_constraint_on":{"column":"roundId","table":{"schema":"public","name":"player_jump"}}}},{"name":"teams","using":{"foreign_key_constraint_on":{"column":"roundsWonId","table":{"schema":"public","name":"team"}}}},{"name":"utility_activateds","using":{"foreign_key_constraint_on":{"column":"roundId","table":{"schema":"public","name":"utility_activated"}}}},{"name":"utility_throwns","using":{"foreign_key_constraint_on":{"column":"roundId","table":{"schema":"public","name":"utility_thrown"}}}},{"name":"weapon_statuses","using":{"foreign_key_constraint_on":{"column":"roundId","table":{"schema":"public","name":"weapon_status"}}}}],"select_permissions":[{"role":"user","permission":{"columns":["createdAt","endTick","id","matchId","startTick","winReason"],"filter":{},"limit":200,"allow_aggregations":true}}]},{"table":{"schema":"public","name":"team"},"object_relationships":[{"name":"round","using":{"foreign_key_constraint_on":"roundsWonId"}}],"array_relationships":[{"name":"team_matches_matches","using":{"foreign_key_constraint_on":{"column":"teamId","table":{"schema":"public","name":"team_matches_match"}}}},{"name":"team_players_players","using":{"foreign_key_constraint_on":{"column":"teamId","table":{"schema":"public","name":"team_players_player"}}}}],"select_permissions":[{"role":"user","permission":{"columns":["id","createdAt","name","roundsWonId"],"filter":{},"limit":200,"allow_aggregations":true}}]},{"table":{"schema":"public","name":"team_matches_match"},"object_relationships":[{"name":"match","using":{"foreign_key_constraint_on":"matchId"}},{"name":"team","using":{"foreign_key_constraint_on":"teamId"}}],"select_permissions":[{"role":"user","permission":{"columns":["teamId","matchId"],"filter":{},"limit":200,"allow_aggregations":true}}]},{"table":{"schema":"public","name":"team_players_player"},"object_relationships":[{"name":"player","using":{"foreign_key_constraint_on":"playerId"}},{"name":"team","using":{"foreign_key_constraint_on":"teamId"}}],"select_permissions":[{"role":"user","permission":{"columns":["teamId","playerId"],"filter":{},"limit":200,"allow_aggregations":true}}]},{"table":{"schema":"public","name":"user"},"object_relationships":[{"name":"settings","using":{"foreign_key_constraint_on":"settingsId"}}],"array_relationships":[{"name":"follows","using":{"foreign_key_constraint_on":{"column":"userId","table":{"schema":"public","name":"player_followed_by_user"}}}},{"name":"notifications","using":{"foreign_key_constraint_on":{"column":"userId","table":{"schema":"public","name":"notification"}}}},{"name":"tracks","using":{"foreign_key_constraint_on":{"column":"userId","table":{"schema":"public","name":"player_tracked_by_user"}}}}],"select_permissions":[{"role":"user","permission":{"columns":["discordId","faceitId","faceitName","id","lastCheckedAtFaceit","lastCheckedAtSteam","role","settingsId","steamId","username"],"filter":{"id":{"_eq":"X-Hasura-User-Id"}}}}]},{"table":{"schema":"public","name":"user_settings"},"object_relationships":[{"name":"user","using":{"manual_configuration":{"remote_table":{"schema":"public","name":"user"},"column_mapping":{"id":"settingsId"}}}}],"select_permissions":[{"role":"user","permission":{"columns":["lastKnownMatch","matchAuthCode","notificationCommunityEnabled","notificationDiscordEnabled","notificationEconomyEnabled","notificationFaceitEnabled","notificationGameEnabled","notificationVACEnabled"],"filter":{"user":{"id":{"_eq":"X-Hasura-User-Id"}}}}}]},{"table":{"schema":"public","name":"utility_activated"},"object_relationships":[{"name":"position","using":{"foreign_key_constraint_on":"positionId"}},{"name":"round","using":{"foreign_key_constraint_on":"roundId"}}],"select_permissions":[{"role":"user","permission":{"columns":["createdAt","entityId","id","positionId","roundId","tick","type"],"filter":{},"limit":200,"allow_aggregations":true}}]},{"table":{"schema":"public","name":"utility_thrown"},"object_relationships":[{"name":"player","using":{"foreign_key_constraint_on":"playerId"}},{"name":"position","using":{"foreign_key_constraint_on":"positionId"}},{"name":"round","using":{"foreign_key_constraint_on":"roundId"}}],"select_permissions":[{"role":"user","permission":{"columns":["createdAt","entityId","id","playerId","positionId","roundId","tick","type"],"filter":{},"limit":200,"allow_aggregations":true}}]},{"table":{"schema":"public","name":"weapon_status"},"object_relationships":[{"name":"player","using":{"foreign_key_constraint_on":"playerId"}},{"name":"round","using":{"foreign_key_constraint_on":"roundId"}}],"select_permissions":[{"role":"user","permission":{"columns":["createdAt","id","playerId","roundId","tick","type","weapon"],"filter":{},"limit":200,"allow_aggregations":true}}]}]} \ No newline at end of file diff --git a/migrations/1595532035147-Add-lots-ingame-info.ts b/migrations/1595532035147-Add-lots-ingame-info.ts new file mode 100644 index 0000000..946c056 --- /dev/null +++ b/migrations/1595532035147-Add-lots-ingame-info.ts @@ -0,0 +1,261 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddLotsIngameInfo1595532035147 implements MigrationInterface { + name = "AddLotsIngameInfo1595532035147"; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE "team" ("id" SERIAL NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "name" character varying, "roundsWonId" integer, CONSTRAINT "PK_f57d8293406df4af348402e4b74" PRIMARY KEY ("id"))`, + undefined + ); + await queryRunner.query( + `CREATE TABLE "round" ("id" SERIAL NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "startTick" integer NOT NULL, "endTick" integer NOT NULL, "winReason" integer NOT NULL, "matchId" integer, CONSTRAINT "PK_34bd959f3f4a90eb86e4ae24d2d" PRIMARY KEY ("id"))`, + undefined + ); + await queryRunner.query( + `CREATE TABLE "position" ("id" SERIAL NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "x" integer NOT NULL, "y" integer NOT NULL, "z" integer NOT NULL, CONSTRAINT "PK_b7f483581562b4dc62ae1a5b7e2" PRIMARY KEY ("id"))`, + undefined + ); + await queryRunner.query( + `CREATE TYPE "player_info_weapon_enum" AS ENUM('Knife', 'P200', 'USP', 'Glock', 'P250', 'FiveSeven', 'Tec9', 'CZ75', 'DualBerettas', 'DesertEagle', 'R8Revolver', 'Nova', 'XM1014', 'Mag7', 'SawedOff', 'MP9', 'PPBizon', 'MP7', 'UMP45', 'P90', 'MP5', 'Famas', 'Galil', 'M4A4', 'M4A1S', 'AK47', 'AUG', 'SG553', 'SSG08', 'AWP', 'SCAR20', 'G3SG1', 'M249', 'Negev', '0', '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')`, + undefined + ); + await queryRunner.query( + `CREATE TABLE "player_info" ("id" SERIAL NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "tick" integer NOT NULL, "equipmentValue" integer NOT NULL, "freezeTimeEndEquipmentValue" integer NOT NULL, "cashSpentInRound" integer NOT NULL, "hasC4" boolean NOT NULL, "health" integer NOT NULL, "armour" integer NOT NULL, "isScoped" boolean NOT NULL, "weapon" "player_info_weapon_enum" NOT NULL, "bulletsInMagazine" integer NOT NULL, "playerId" integer, CONSTRAINT "PK_0d42212f46cf376d2ef91116704" PRIMARY KEY ("id"))`, + undefined + ); + await queryRunner.query( + `CREATE TYPE "bomb_status_type_enum" AS ENUM('Planted', 'Defused', 'StartDefuse', 'StopDefuse', 'Dropped', 'PickedUp', 'Exploded', '0', '1', '2', '3', '4', '5', '6')`, + undefined + ); + await queryRunner.query( + `CREATE TABLE "bomb_status" ("id" SERIAL NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "tick" integer NOT NULL, "type" "bomb_status_type_enum" NOT NULL, "roundId" integer, CONSTRAINT "PK_b2ee5ae6aa7678e96ce7205a18e" PRIMARY KEY ("id"))`, + undefined + ); + await queryRunner.query( + `CREATE TABLE "kill" ("id" SERIAL NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "tick" integer NOT NULL, "throughSmoke" boolean NOT NULL, "whileBlind" boolean NOT NULL, "throughWall" boolean NOT NULL, "roundId" integer, CONSTRAINT "PK_8264cb6c8543bd37675fd6d2580" PRIMARY KEY ("id"))`, + undefined + ); + await queryRunner.query( + `CREATE TABLE "player_blind" ("id" SERIAL NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "tick" integer NOT NULL, "duration" integer NOT NULL, "roundId" integer, CONSTRAINT "PK_1fa32b75d4152b8762c9f2af810" PRIMARY KEY ("id"))`, + undefined + ); + await queryRunner.query( + `CREATE TABLE "player_hurt" ("id" SERIAL NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "tick" integer NOT NULL, "damageArmour" integer NOT NULL, "damageHealth" integer NOT NULL, "hitGroup" integer NOT NULL, "source" integer NOT NULL, "roundId" integer, CONSTRAINT "PK_e2c4b8cd585012f80929b2193b8" PRIMARY KEY ("id"))`, + undefined + ); + await queryRunner.query( + `CREATE TABLE "player_jump" ("id" SERIAL NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "tick" integer NOT NULL, "roundId" integer, CONSTRAINT "PK_071d67a1d276021eaa191b2fd74" PRIMARY KEY ("id"))`, + undefined + ); + await queryRunner.query( + `CREATE TYPE "utility_activated_type_enum" AS ENUM('Smoke', 'HighExplosiveGrenade', 'Decoy', 'Molotov', 'Flash', 'Snowball', 'TacticalAwarenessGrenade', '0', '1', '2', '3', '4', '5', '6')`, + undefined + ); + await queryRunner.query( + `CREATE TABLE "utility_activated" ("id" SERIAL NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "tick" integer NOT NULL, "type" "utility_activated_type_enum" NOT NULL, "entityId" integer NOT NULL, "roundId" integer, CONSTRAINT "PK_52f11ab2f104997ebe6f869ea65" PRIMARY KEY ("id"))`, + undefined + ); + await queryRunner.query( + `CREATE TYPE "utility_thrown_type_enum" AS ENUM('Smoke', 'HighExplosiveGrenade', 'Decoy', 'Molotov', 'Flash', 'Snowball', 'TacticalAwarenessGrenade', '0', '1', '2', '3', '4', '5', '6')`, + undefined + ); + await queryRunner.query( + `CREATE TABLE "utility_thrown" ("id" SERIAL NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "tick" integer NOT NULL, "type" "utility_thrown_type_enum" NOT NULL, "entityId" integer NOT NULL, "roundId" integer, CONSTRAINT "PK_03cf1304df6cbd15195991df9dd" PRIMARY KEY ("id"))`, + undefined + ); + await queryRunner.query( + `CREATE TYPE "weapon_status_weapon_enum" AS ENUM('Knife', 'P200', 'USP', 'Glock', 'P250', 'FiveSeven', 'Tec9', 'CZ75', 'DualBerettas', 'DesertEagle', 'R8Revolver', 'Nova', 'XM1014', 'Mag7', 'SawedOff', 'MP9', 'PPBizon', 'MP7', 'UMP45', 'P90', 'MP5', 'Famas', 'Galil', 'M4A4', 'M4A1S', 'AK47', 'AUG', 'SG553', 'SSG08', 'AWP', 'SCAR20', 'G3SG1', 'M249', 'Negev', '0', '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')`, + undefined + ); + await queryRunner.query( + `CREATE TABLE "weapon_status" ("id" SERIAL NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "tick" integer NOT NULL, "weapon" "weapon_status_weapon_enum" NOT NULL, "type" integer NOT NULL, "roundId" integer, CONSTRAINT "PK_4714c7704d21b2c9328ac90c39f" PRIMARY KEY ("id"))`, + undefined + ); + await queryRunner.query( + `CREATE TABLE "team_players_player" ("teamId" integer NOT NULL, "playerId" integer NOT NULL, CONSTRAINT "PK_30ad7c7427cb452e63ff4d4f9a0" PRIMARY KEY ("teamId", "playerId"))`, + undefined + ); + await queryRunner.query( + `CREATE INDEX "IDX_03530e45522b82c6ae46d825dd" ON "team_players_player" ("teamId") `, + undefined + ); + await queryRunner.query( + `CREATE INDEX "IDX_a5a5ca467eb43bf810ce32a119" ON "team_players_player" ("playerId") `, + undefined + ); + await queryRunner.query( + `CREATE TABLE "team_matches_match" ("teamId" integer NOT NULL, "matchId" integer NOT NULL, CONSTRAINT "PK_a8fa5aef8ca0cf27bde29f5fa7c" PRIMARY KEY ("teamId", "matchId"))`, + undefined + ); + await queryRunner.query( + `CREATE INDEX "IDX_93819ccfdcce150379dc206b4a" ON "team_matches_match" ("teamId") `, + undefined + ); + await queryRunner.query( + `CREATE INDEX "IDX_bb8410737b478e3b3e8bb8aad9" ON "team_matches_match" ("matchId") `, + undefined + ); + await queryRunner.query( + `ALTER TABLE "team" ADD CONSTRAINT "FK_57cbf6a5c5441201714a6658002" FOREIGN KEY ("roundsWonId") REFERENCES "round"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "round" ADD CONSTRAINT "FK_7f3ebe2c9b6582d68973dd1de22" FOREIGN KEY ("matchId") REFERENCES "match"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_info" ADD CONSTRAINT "FK_22cee42dd78530aaaa642190e7f" FOREIGN KEY ("playerId") REFERENCES "player"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "bomb_status" ADD CONSTRAINT "FK_7ab59502c18b50c7442ff861ec6" FOREIGN KEY ("roundId") REFERENCES "round"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" ADD CONSTRAINT "FK_5aa4617cdbffcf03dd28856d669" FOREIGN KEY ("roundId") REFERENCES "round"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_blind" ADD CONSTRAINT "FK_f7da2dd9476901e0ba1776fe481" FOREIGN KEY ("roundId") REFERENCES "round"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_hurt" ADD CONSTRAINT "FK_1951f31a3dea3c12e73b913b869" FOREIGN KEY ("roundId") REFERENCES "round"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_jump" ADD CONSTRAINT "FK_c89668877fe92ef47b0b221656b" FOREIGN KEY ("roundId") REFERENCES "round"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_activated" ADD CONSTRAINT "FK_1c41e12cd4d459df374d82e4be8" FOREIGN KEY ("roundId") REFERENCES "round"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_thrown" ADD CONSTRAINT "FK_fa90f3265605fc1e17860066213" FOREIGN KEY ("roundId") REFERENCES "round"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "weapon_status" ADD CONSTRAINT "FK_fa268657ffbc0bd8fed2fac5517" FOREIGN KEY ("roundId") REFERENCES "round"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "team_players_player" ADD CONSTRAINT "FK_03530e45522b82c6ae46d825dd1" FOREIGN KEY ("teamId") REFERENCES "team"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "team_players_player" ADD CONSTRAINT "FK_a5a5ca467eb43bf810ce32a119d" FOREIGN KEY ("playerId") REFERENCES "player"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "team_matches_match" ADD CONSTRAINT "FK_93819ccfdcce150379dc206b4a5" FOREIGN KEY ("teamId") REFERENCES "team"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "team_matches_match" ADD CONSTRAINT "FK_bb8410737b478e3b3e8bb8aad9c" FOREIGN KEY ("matchId") REFERENCES "match"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + undefined + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "team_matches_match" DROP CONSTRAINT "FK_bb8410737b478e3b3e8bb8aad9c"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "team_matches_match" DROP CONSTRAINT "FK_93819ccfdcce150379dc206b4a5"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "team_players_player" DROP CONSTRAINT "FK_a5a5ca467eb43bf810ce32a119d"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "team_players_player" DROP CONSTRAINT "FK_03530e45522b82c6ae46d825dd1"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "weapon_status" DROP CONSTRAINT "FK_fa268657ffbc0bd8fed2fac5517"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_thrown" DROP CONSTRAINT "FK_fa90f3265605fc1e17860066213"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_activated" DROP CONSTRAINT "FK_1c41e12cd4d459df374d82e4be8"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_jump" DROP CONSTRAINT "FK_c89668877fe92ef47b0b221656b"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_hurt" DROP CONSTRAINT "FK_1951f31a3dea3c12e73b913b869"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_blind" DROP CONSTRAINT "FK_f7da2dd9476901e0ba1776fe481"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" DROP CONSTRAINT "FK_5aa4617cdbffcf03dd28856d669"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "bomb_status" DROP CONSTRAINT "FK_7ab59502c18b50c7442ff861ec6"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_info" DROP CONSTRAINT "FK_22cee42dd78530aaaa642190e7f"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "round" DROP CONSTRAINT "FK_7f3ebe2c9b6582d68973dd1de22"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "team" DROP CONSTRAINT "FK_57cbf6a5c5441201714a6658002"`, + undefined + ); + await queryRunner.query( + `DROP INDEX "IDX_bb8410737b478e3b3e8bb8aad9"`, + undefined + ); + await queryRunner.query( + `DROP INDEX "IDX_93819ccfdcce150379dc206b4a"`, + undefined + ); + await queryRunner.query(`DROP TABLE "team_matches_match"`, undefined); + await queryRunner.query( + `DROP INDEX "IDX_a5a5ca467eb43bf810ce32a119"`, + undefined + ); + await queryRunner.query( + `DROP INDEX "IDX_03530e45522b82c6ae46d825dd"`, + undefined + ); + await queryRunner.query(`DROP TABLE "team_players_player"`, undefined); + await queryRunner.query(`DROP TABLE "weapon_status"`, undefined); + await queryRunner.query(`DROP TYPE "weapon_status_weapon_enum"`, undefined); + await queryRunner.query(`DROP TABLE "utility_thrown"`, undefined); + await queryRunner.query(`DROP TYPE "utility_thrown_type_enum"`, undefined); + await queryRunner.query(`DROP TABLE "utility_activated"`, undefined); + await queryRunner.query( + `DROP TYPE "utility_activated_type_enum"`, + undefined + ); + await queryRunner.query(`DROP TABLE "player_jump"`, undefined); + await queryRunner.query(`DROP TABLE "player_hurt"`, undefined); + await queryRunner.query(`DROP TABLE "player_blind"`, undefined); + await queryRunner.query(`DROP TABLE "kill"`, undefined); + await queryRunner.query(`DROP TABLE "bomb_status"`, undefined); + await queryRunner.query(`DROP TYPE "bomb_status_type_enum"`, undefined); + await queryRunner.query(`DROP TABLE "player_info"`, undefined); + await queryRunner.query(`DROP TYPE "player_info_weapon_enum"`, undefined); + await queryRunner.query(`DROP TABLE "position"`, undefined); + await queryRunner.query(`DROP TABLE "round"`, undefined); + await queryRunner.query(`DROP TABLE "team"`, undefined); + } +} diff --git a/migrations/1595598314317-fix-one-to-one-joins.ts b/migrations/1595598314317-fix-one-to-one-joins.ts new file mode 100644 index 0000000..55f0fa8 --- /dev/null +++ b/migrations/1595598314317-fix-one-to-one-joins.ts @@ -0,0 +1,371 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class fixOneToOneJoins1595598314317 implements MigrationInterface { + name = "fixOneToOneJoins1595598314317"; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "player_info" ADD "positionId" integer`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_info" ADD CONSTRAINT "UQ_2f379f4936298abb4337fcf3bd4" UNIQUE ("positionId")`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "bomb_status" ADD "playerId" integer`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "bomb_status" ADD CONSTRAINT "UQ_5198178354128c0f245f0001b56" UNIQUE ("playerId")`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "bomb_status" ADD "positionId" integer`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "bomb_status" ADD CONSTRAINT "UQ_3f7258564029924db971c82df2f" UNIQUE ("positionId")`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" ADD "attackerId" integer`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" ADD CONSTRAINT "UQ_66bae58484e73e6eed83806204f" UNIQUE ("attackerId")`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" ADD "victimId" integer`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" ADD CONSTRAINT "UQ_8b237366204443c950e6ad7040d" UNIQUE ("victimId")`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" ADD "assisterId" integer`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" ADD CONSTRAINT "UQ_9e959653091685dbdba8dc5be34" UNIQUE ("assisterId")`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_blind" ADD "attackerId" integer`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_blind" ADD CONSTRAINT "UQ_6cf645028c4e85c13f397f5cbc4" UNIQUE ("attackerId")`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_blind" ADD "victimId" integer`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_blind" ADD CONSTRAINT "UQ_f38ac2d3a1491a03c11b6b03e82" UNIQUE ("victimId")`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_hurt" ADD "attackerId" integer`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_hurt" ADD CONSTRAINT "UQ_11325a767513055480b7f0576e9" UNIQUE ("attackerId")`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_hurt" ADD "victimId" integer`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_hurt" ADD CONSTRAINT "UQ_c827f7e140f620740d30a1abfa8" UNIQUE ("victimId")`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_jump" ADD "playerId" integer`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_jump" ADD CONSTRAINT "UQ_05717296fd699479e773327f37f" UNIQUE ("playerId")`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_activated" ADD "positionId" integer`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_activated" ADD CONSTRAINT "UQ_97e57c666e734d24763c2e6f1ed" UNIQUE ("positionId")`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_thrown" ADD "playerId" integer`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_thrown" ADD CONSTRAINT "UQ_18fc7c134dd8b26207487732153" UNIQUE ("playerId")`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_thrown" ADD "positionId" integer`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_thrown" ADD CONSTRAINT "UQ_9e6abb1c691794d1e4c14624998" UNIQUE ("positionId")`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "weapon_status" ADD "playerId" integer`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "weapon_status" ADD CONSTRAINT "UQ_24f67795602b4bbf7be1191fc04" UNIQUE ("playerId")`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_info" ADD CONSTRAINT "FK_2f379f4936298abb4337fcf3bd4" FOREIGN KEY ("positionId") REFERENCES "position"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "bomb_status" ADD CONSTRAINT "FK_5198178354128c0f245f0001b56" FOREIGN KEY ("playerId") REFERENCES "player_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "bomb_status" ADD CONSTRAINT "FK_3f7258564029924db971c82df2f" FOREIGN KEY ("positionId") REFERENCES "position"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" ADD CONSTRAINT "FK_66bae58484e73e6eed83806204f" FOREIGN KEY ("attackerId") REFERENCES "player_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" ADD CONSTRAINT "FK_8b237366204443c950e6ad7040d" FOREIGN KEY ("victimId") REFERENCES "player_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" ADD CONSTRAINT "FK_9e959653091685dbdba8dc5be34" FOREIGN KEY ("assisterId") REFERENCES "player_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_blind" ADD CONSTRAINT "FK_6cf645028c4e85c13f397f5cbc4" FOREIGN KEY ("attackerId") REFERENCES "player_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_blind" ADD CONSTRAINT "FK_f38ac2d3a1491a03c11b6b03e82" FOREIGN KEY ("victimId") REFERENCES "player_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_hurt" ADD CONSTRAINT "FK_11325a767513055480b7f0576e9" FOREIGN KEY ("attackerId") REFERENCES "player_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_hurt" ADD CONSTRAINT "FK_c827f7e140f620740d30a1abfa8" FOREIGN KEY ("victimId") REFERENCES "player_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_jump" ADD CONSTRAINT "FK_05717296fd699479e773327f37f" FOREIGN KEY ("playerId") REFERENCES "player_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_activated" ADD CONSTRAINT "FK_97e57c666e734d24763c2e6f1ed" FOREIGN KEY ("positionId") REFERENCES "position"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_thrown" ADD CONSTRAINT "FK_18fc7c134dd8b26207487732153" FOREIGN KEY ("playerId") REFERENCES "player_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_thrown" ADD CONSTRAINT "FK_9e6abb1c691794d1e4c14624998" FOREIGN KEY ("positionId") REFERENCES "position"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "weapon_status" ADD CONSTRAINT "FK_24f67795602b4bbf7be1191fc04" FOREIGN KEY ("playerId") REFERENCES "player_info"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + undefined + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "weapon_status" DROP CONSTRAINT "FK_24f67795602b4bbf7be1191fc04"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_thrown" DROP CONSTRAINT "FK_9e6abb1c691794d1e4c14624998"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_thrown" DROP CONSTRAINT "FK_18fc7c134dd8b26207487732153"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_activated" DROP CONSTRAINT "FK_97e57c666e734d24763c2e6f1ed"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_jump" DROP CONSTRAINT "FK_05717296fd699479e773327f37f"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_hurt" DROP CONSTRAINT "FK_c827f7e140f620740d30a1abfa8"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_hurt" DROP CONSTRAINT "FK_11325a767513055480b7f0576e9"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_blind" DROP CONSTRAINT "FK_f38ac2d3a1491a03c11b6b03e82"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_blind" DROP CONSTRAINT "FK_6cf645028c4e85c13f397f5cbc4"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" DROP CONSTRAINT "FK_9e959653091685dbdba8dc5be34"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" DROP CONSTRAINT "FK_8b237366204443c950e6ad7040d"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" DROP CONSTRAINT "FK_66bae58484e73e6eed83806204f"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "bomb_status" DROP CONSTRAINT "FK_3f7258564029924db971c82df2f"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "bomb_status" DROP CONSTRAINT "FK_5198178354128c0f245f0001b56"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_info" DROP CONSTRAINT "FK_2f379f4936298abb4337fcf3bd4"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "weapon_status" DROP CONSTRAINT "UQ_24f67795602b4bbf7be1191fc04"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "weapon_status" DROP COLUMN "playerId"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_thrown" DROP CONSTRAINT "UQ_9e6abb1c691794d1e4c14624998"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_thrown" DROP COLUMN "positionId"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_thrown" DROP CONSTRAINT "UQ_18fc7c134dd8b26207487732153"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_thrown" DROP COLUMN "playerId"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_activated" DROP CONSTRAINT "UQ_97e57c666e734d24763c2e6f1ed"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "utility_activated" DROP COLUMN "positionId"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_jump" DROP CONSTRAINT "UQ_05717296fd699479e773327f37f"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_jump" DROP COLUMN "playerId"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_hurt" DROP CONSTRAINT "UQ_c827f7e140f620740d30a1abfa8"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_hurt" DROP COLUMN "victimId"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_hurt" DROP CONSTRAINT "UQ_11325a767513055480b7f0576e9"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_hurt" DROP COLUMN "attackerId"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_blind" DROP CONSTRAINT "UQ_f38ac2d3a1491a03c11b6b03e82"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_blind" DROP COLUMN "victimId"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_blind" DROP CONSTRAINT "UQ_6cf645028c4e85c13f397f5cbc4"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_blind" DROP COLUMN "attackerId"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" DROP CONSTRAINT "UQ_9e959653091685dbdba8dc5be34"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" DROP COLUMN "assisterId"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" DROP CONSTRAINT "UQ_8b237366204443c950e6ad7040d"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" DROP COLUMN "victimId"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" DROP CONSTRAINT "UQ_66bae58484e73e6eed83806204f"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "kill" DROP COLUMN "attackerId"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "bomb_status" DROP CONSTRAINT "UQ_3f7258564029924db971c82df2f"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "bomb_status" DROP COLUMN "positionId"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "bomb_status" DROP CONSTRAINT "UQ_5198178354128c0f245f0001b56"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "bomb_status" DROP COLUMN "playerId"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_info" DROP CONSTRAINT "UQ_2f379f4936298abb4337fcf3bd4"`, + undefined + ); + await queryRunner.query( + `ALTER TABLE "player_info" DROP COLUMN "positionId"`, + undefined + ); + } +} diff --git a/types/BombStatusChange.enum.ts b/types/BombStatusChange.enum.ts new file mode 100644 index 0000000..92c18fc --- /dev/null +++ b/types/BombStatusChange.enum.ts @@ -0,0 +1,9 @@ +export enum BombStatusChange { + Planted, + Defused, + StartDefuse, + StopDefuse, + Dropped, + PickedUp, + Exploded, +} diff --git a/types/HurtSources.enum.ts b/types/HurtSources.enum.ts new file mode 100644 index 0000000..e97453b --- /dev/null +++ b/types/HurtSources.enum.ts @@ -0,0 +1,5 @@ +export enum HurtSources { + Weapon, + FallDamage, + Bomb, +} diff --git a/types/RoundWinReason.enum.ts b/types/RoundWinReason.enum.ts new file mode 100644 index 0000000..bfeccd5 --- /dev/null +++ b/types/RoundWinReason.enum.ts @@ -0,0 +1,6 @@ +export enum RoundWinReason { + PlayersKilled, + BombDefused, + BombExploded, + TimeExpired, +} diff --git a/types/Weapon.enum.ts b/types/Weapon.enum.ts new file mode 100644 index 0000000..1bf575b --- /dev/null +++ b/types/Weapon.enum.ts @@ -0,0 +1,36 @@ +export enum Weapon { + Knife, + P200, + USP, + Glock, + P250, + FiveSeven, + Tec9, + CZ75, + DualBerettas, + DesertEagle, + R8Revolver, + Nova, + XM1014, + Mag7, + SawedOff, + MP9, + PPBizon, + MP7, + UMP45, + P90, + MP5, + Famas, + Galil, + M4A4, + M4A1S, + AK47, + AUG, + SG553, + SSG08, + AWP, + SCAR20, + G3SG1, + M249, + Negev, +} diff --git a/types/WeaponStatusChange.enum.ts b/types/WeaponStatusChange.enum.ts new file mode 100644 index 0000000..b040acc --- /dev/null +++ b/types/WeaponStatusChange.enum.ts @@ -0,0 +1,14 @@ +export enum WeaponStatusChange { + Dropped, + Reload, + Empty, + SilencerAttach, + SilencerAttached, + SilencerDetach, + SilencerDetached, + Bought, + // Should not implement this one yet. Will be a lot of data and we should review if it is worth it or not + Fire, + InspectStart, + InspectEnd, +} diff --git a/types/utilityType.enum.ts b/types/utilityType.enum.ts new file mode 100644 index 0000000..c1c29eb --- /dev/null +++ b/types/utilityType.enum.ts @@ -0,0 +1,9 @@ +export enum UtilityType { + Smoke, + HighExplosiveGrenade, + Decoy, + Molotov, + Flash, + Snowball, + TacticalAwarenessGrenade, +}