using System; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace SystemRevivalServer.Migrations { /// public partial class AddVoidScavengersStats : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "match_history", columns: table => new { Id = table.Column(type: "bigint unsigned", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), MatchId = table.Column(type: "varchar(32)", maxLength: 32, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), AccountId = table.Column(type: "bigint unsigned", nullable: false), Result = table.Column(type: "int", nullable: false), Placement = table.Column(type: "int", nullable: false), TotalPlayers = table.Column(type: "int", nullable: false), Kills = table.Column(type: "int", nullable: false), Deaths = table.Column(type: "int", nullable: false), DamageDealt = table.Column(type: "int", nullable: false), DamageTaken = table.Column(type: "int", nullable: false), ScrapCollected = table.Column(type: "int", nullable: false), EnergyCollected = table.Column(type: "int", nullable: false), RareCollected = table.Column(type: "int", nullable: false), ItemsCrafted = table.Column(type: "int", nullable: false), SurvivalTimeSeconds = table.Column(type: "int", nullable: false), MatchDurationSeconds = table.Column(type: "int", nullable: false), EloChange = table.Column(type: "int", nullable: false), EloAfter = table.Column(type: "int", nullable: false), PlayedAt = table.Column(type: "datetime(6)", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP(6)") }, constraints: table => { table.PrimaryKey("PK_match_history", x => x.Id); table.ForeignKey( name: "FK_match_history_accounts_AccountId", column: x => x.AccountId, principalTable: "accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "player_stats", columns: table => new { Id = table.Column(type: "bigint unsigned", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), AccountId = table.Column(type: "bigint unsigned", nullable: false), MatchesPlayed = table.Column(type: "int", nullable: false), Wins = table.Column(type: "int", nullable: false), Losses = table.Column(type: "int", nullable: false), Extractions = table.Column(type: "int", nullable: false), Kills = table.Column(type: "int", nullable: false), Deaths = table.Column(type: "int", nullable: false), TotalDamageDealt = table.Column(type: "bigint", nullable: false), TotalDamageTaken = table.Column(type: "bigint", nullable: false), TotalScrapCollected = table.Column(type: "bigint", nullable: false), TotalEnergyCollected = table.Column(type: "bigint", nullable: false), TotalRareCollected = table.Column(type: "bigint", nullable: false), ItemsCrafted = table.Column(type: "int", nullable: false), TotalPlayTimeSeconds = table.Column(type: "bigint", nullable: false), LongestSurvivalSeconds = table.Column(type: "int", nullable: false), Elo = table.Column(type: "int", nullable: false, defaultValue: 1000), CreatedAt = table.Column(type: "datetime(6)", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP(6)"), UpdatedAt = table.Column(type: "datetime(6)", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP(6)") .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn) }, constraints: table => { table.PrimaryKey("PK_player_stats", x => x.Id); table.ForeignKey( name: "FK_player_stats_accounts_AccountId", column: x => x.AccountId, principalTable: "accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_match_history_AccountId", table: "match_history", column: "AccountId"); migrationBuilder.CreateIndex( name: "IX_match_history_MatchId", table: "match_history", column: "MatchId"); migrationBuilder.CreateIndex( name: "IX_match_history_PlayedAt", table: "match_history", column: "PlayedAt"); migrationBuilder.CreateIndex( name: "IX_player_stats_AccountId", table: "player_stats", column: "AccountId", unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "match_history"); migrationBuilder.DropTable( name: "player_stats"); } } }