using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace Data.Migrations.Postgresql { /// public partial class InitialZombieStats : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "PerformanceBucket", table: "EFServers", type: "text", nullable: true); migrationBuilder.AddColumn( name: "PerformanceBucket", table: "EFClientRankingHistory", type: "text", nullable: true); migrationBuilder.CreateTable( name: "EFZombieMatch", columns: table => new { ZombieMatchId = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), MapId = table.Column(type: "integer", nullable: true), ServerId = table.Column(type: "bigint", nullable: true), ClientsCompleted = table.Column(type: "integer", nullable: false), MatchStartDate = table.Column(type: "timestamp with time zone", nullable: false), MatchEndDate = table.Column(type: "timestamp with time zone", nullable: true), CreatedDateTime = table.Column(type: "timestamp with time zone", nullable: false), UpdatedDateTime = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("PK_EFZombieMatch", x => x.ZombieMatchId); table.ForeignKey( name: "FK_EFZombieMatch_EFMaps_MapId", column: x => x.MapId, principalTable: "EFMaps", principalColumn: "MapId"); table.ForeignKey( name: "FK_EFZombieMatch_EFServers_ServerId", column: x => x.ServerId, principalTable: "EFServers", principalColumn: "ServerId"); }); migrationBuilder.CreateTable( name: "EFZombieClientStat", columns: table => new { ZombieClientStatId = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), MatchId = table.Column(type: "integer", nullable: true), ClientId = table.Column(type: "integer", nullable: false), Kills = table.Column(type: "integer", nullable: false), Deaths = table.Column(type: "integer", nullable: false), DamageDealt = table.Column(type: "bigint", nullable: false), DamageReceived = table.Column(type: "integer", nullable: false), Headshots = table.Column(type: "integer", nullable: false), HeadshotKills = table.Column(type: "integer", nullable: false), Melees = table.Column(type: "integer", nullable: false), Downs = table.Column(type: "integer", nullable: false), Revives = table.Column(type: "integer", nullable: false), PointsEarned = table.Column(type: "bigint", nullable: false), PointsSpent = table.Column(type: "bigint", nullable: false), PerksConsumed = table.Column(type: "integer", nullable: false), PowerupsGrabbed = table.Column(type: "integer", nullable: false), CreatedDateTime = table.Column(type: "timestamp with time zone", nullable: false), UpdatedDateTime = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("PK_EFZombieClientStat", x => x.ZombieClientStatId); table.ForeignKey( name: "FK_EFZombieClientStat_EFClients_ClientId", column: x => x.ClientId, principalTable: "EFClients", principalColumn: "ClientId", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_EFZombieClientStat_EFZombieMatch_MatchId", column: x => x.MatchId, principalTable: "EFZombieMatch", principalColumn: "ZombieMatchId"); }); migrationBuilder.CreateTable( name: "EFZombieEvents", columns: table => new { ZombieEventLogId = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), EventType = table.Column(type: "integer", nullable: false), SourceClientId = table.Column(type: "integer", nullable: true), AssociatedClientId = table.Column(type: "integer", nullable: true), NumericalValue = table.Column(type: "double precision", nullable: true), TextualValue = table.Column(type: "text", nullable: true), MatchId = table.Column(type: "integer", nullable: true), CreatedDateTime = table.Column(type: "timestamp with time zone", nullable: false), UpdatedDateTime = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("PK_EFZombieEvents", x => x.ZombieEventLogId); table.ForeignKey( name: "FK_EFZombieEvents_EFClients_AssociatedClientId", column: x => x.AssociatedClientId, principalTable: "EFClients", principalColumn: "ClientId"); table.ForeignKey( name: "FK_EFZombieEvents_EFClients_SourceClientId", column: x => x.SourceClientId, principalTable: "EFClients", principalColumn: "ClientId"); table.ForeignKey( name: "FK_EFZombieEvents_EFZombieMatch_MatchId", column: x => x.MatchId, principalTable: "EFZombieMatch", principalColumn: "ZombieMatchId"); }); migrationBuilder.CreateTable( name: "EFZombieAggregateClientStat", columns: table => new { ZombieClientStatId = table.Column(type: "bigint", nullable: false), ServerId = table.Column(type: "bigint", nullable: true), AverageKillsPerDown = table.Column(type: "double precision", nullable: false), AverageDowns = table.Column(type: "double precision", nullable: false), AverageRevives = table.Column(type: "double precision", nullable: false), HeadshotPercentage = table.Column(type: "double precision", nullable: false), AlivePercentage = table.Column(type: "double precision", nullable: false), AverageMelees = table.Column(type: "double precision", nullable: false), AverageRoundReached = table.Column(type: "double precision", nullable: false), AveragePoints = table.Column(type: "double precision", nullable: false), HighestRound = table.Column(type: "integer", nullable: false), TotalRoundsPlayed = table.Column(type: "integer", nullable: false), TotalMatchesPlayed = table.Column(type: "integer", nullable: false), TotalMatchesCompleted = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_EFZombieAggregateClientStat", x => x.ZombieClientStatId); table.ForeignKey( name: "FK_EFZombieAggregateClientStat_EFServers_ServerId", column: x => x.ServerId, principalTable: "EFServers", principalColumn: "ServerId"); table.ForeignKey( name: "FK_EFZombieAggregateClientStat_EFZombieClientStat_ZombieClient~", column: x => x.ZombieClientStatId, principalTable: "EFZombieClientStat", principalColumn: "ZombieClientStatId", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "EFZombieMatchClientStat", columns: table => new { ZombieClientStatId = table.Column(type: "bigint", nullable: false) }, constraints: table => { table.PrimaryKey("PK_EFZombieMatchClientStat", x => x.ZombieClientStatId); table.ForeignKey( name: "FK_EFZombieMatchClientStat_EFZombieClientStat_ZombieClientStat~", column: x => x.ZombieClientStatId, principalTable: "EFZombieClientStat", principalColumn: "ZombieClientStatId", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "EFZombieRoundClientStat", columns: table => new { ZombieClientStatId = table.Column(type: "bigint", nullable: false), StartTime = table.Column(type: "timestamp with time zone", nullable: false), EndTime = table.Column(type: "timestamp with time zone", nullable: true), Duration = table.Column(type: "interval", nullable: true), TimeAlive = table.Column(type: "interval", nullable: true), RoundNumber = table.Column(type: "integer", nullable: false), Points = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_EFZombieRoundClientStat", x => x.ZombieClientStatId); table.ForeignKey( name: "FK_EFZombieRoundClientStat_EFZombieClientStat_ZombieClientStat~", column: x => x.ZombieClientStatId, principalTable: "EFZombieClientStat", principalColumn: "ZombieClientStatId", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "EFZombieClientStatRecord", columns: table => new { ZombieClientStatRecordId = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: false), Type = table.Column(type: "text", nullable: false), Value = table.Column(type: "text", nullable: false), ClientId = table.Column(type: "integer", nullable: true), RoundId = table.Column(type: "bigint", nullable: true), CreatedDateTime = table.Column(type: "timestamp with time zone", nullable: false), UpdatedDateTime = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("PK_EFZombieClientStatRecord", x => x.ZombieClientStatRecordId); table.ForeignKey( name: "FK_EFZombieClientStatRecord_EFClients_ClientId", column: x => x.ClientId, principalTable: "EFClients", principalColumn: "ClientId"); table.ForeignKey( name: "FK_EFZombieClientStatRecord_EFZombieRoundClientStat_RoundId", column: x => x.RoundId, principalTable: "EFZombieRoundClientStat", principalColumn: "ZombieClientStatId"); }); migrationBuilder.CreateIndex( name: "IX_EFZombieAggregateClientStat_ServerId", table: "EFZombieAggregateClientStat", column: "ServerId"); migrationBuilder.CreateIndex( name: "IX_EFZombieClientStat_ClientId", table: "EFZombieClientStat", column: "ClientId"); migrationBuilder.CreateIndex( name: "IX_EFZombieClientStat_MatchId", table: "EFZombieClientStat", column: "MatchId"); migrationBuilder.CreateIndex( name: "IX_EFZombieClientStatRecord_ClientId", table: "EFZombieClientStatRecord", column: "ClientId"); migrationBuilder.CreateIndex( name: "IX_EFZombieClientStatRecord_RoundId", table: "EFZombieClientStatRecord", column: "RoundId"); migrationBuilder.CreateIndex( name: "IX_EFZombieEvents_AssociatedClientId", table: "EFZombieEvents", column: "AssociatedClientId"); migrationBuilder.CreateIndex( name: "IX_EFZombieEvents_MatchId", table: "EFZombieEvents", column: "MatchId"); migrationBuilder.CreateIndex( name: "IX_EFZombieEvents_SourceClientId", table: "EFZombieEvents", column: "SourceClientId"); migrationBuilder.CreateIndex( name: "IX_EFZombieMatch_MapId", table: "EFZombieMatch", column: "MapId"); migrationBuilder.CreateIndex( name: "IX_EFZombieMatch_ServerId", table: "EFZombieMatch", column: "ServerId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "EFZombieAggregateClientStat"); migrationBuilder.DropTable( name: "EFZombieClientStatRecord"); migrationBuilder.DropTable( name: "EFZombieEvents"); migrationBuilder.DropTable( name: "EFZombieMatchClientStat"); migrationBuilder.DropTable( name: "EFZombieRoundClientStat"); migrationBuilder.DropTable( name: "EFZombieClientStat"); migrationBuilder.DropTable( name: "EFZombieMatch"); migrationBuilder.DropColumn( name: "PerformanceBucket", table: "EFServers"); migrationBuilder.DropColumn( name: "PerformanceBucket", table: "EFClientRankingHistory"); } } }