Files
systemrevivalserver/Migrations/20251204134242_AddVoidScavengersStats.cs
T
2025-12-04 08:43:10 -05:00

124 lines
6.4 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SystemRevivalServer.Migrations
{
/// <inheritdoc />
public partial class AddVoidScavengersStats : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "match_history",
columns: table => new
{
Id = table.Column<ulong>(type: "bigint unsigned", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
MatchId = table.Column<string>(type: "varchar(32)", maxLength: 32, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
AccountId = table.Column<ulong>(type: "bigint unsigned", nullable: false),
Result = table.Column<int>(type: "int", nullable: false),
Placement = table.Column<int>(type: "int", nullable: false),
TotalPlayers = table.Column<int>(type: "int", nullable: false),
Kills = table.Column<int>(type: "int", nullable: false),
Deaths = table.Column<int>(type: "int", nullable: false),
DamageDealt = table.Column<int>(type: "int", nullable: false),
DamageTaken = table.Column<int>(type: "int", nullable: false),
ScrapCollected = table.Column<int>(type: "int", nullable: false),
EnergyCollected = table.Column<int>(type: "int", nullable: false),
RareCollected = table.Column<int>(type: "int", nullable: false),
ItemsCrafted = table.Column<int>(type: "int", nullable: false),
SurvivalTimeSeconds = table.Column<int>(type: "int", nullable: false),
MatchDurationSeconds = table.Column<int>(type: "int", nullable: false),
EloChange = table.Column<int>(type: "int", nullable: false),
EloAfter = table.Column<int>(type: "int", nullable: false),
PlayedAt = table.Column<DateTime>(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<ulong>(type: "bigint unsigned", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
AccountId = table.Column<ulong>(type: "bigint unsigned", nullable: false),
MatchesPlayed = table.Column<int>(type: "int", nullable: false),
Wins = table.Column<int>(type: "int", nullable: false),
Losses = table.Column<int>(type: "int", nullable: false),
Extractions = table.Column<int>(type: "int", nullable: false),
Kills = table.Column<int>(type: "int", nullable: false),
Deaths = table.Column<int>(type: "int", nullable: false),
TotalDamageDealt = table.Column<long>(type: "bigint", nullable: false),
TotalDamageTaken = table.Column<long>(type: "bigint", nullable: false),
TotalScrapCollected = table.Column<long>(type: "bigint", nullable: false),
TotalEnergyCollected = table.Column<long>(type: "bigint", nullable: false),
TotalRareCollected = table.Column<long>(type: "bigint", nullable: false),
ItemsCrafted = table.Column<int>(type: "int", nullable: false),
TotalPlayTimeSeconds = table.Column<long>(type: "bigint", nullable: false),
LongestSurvivalSeconds = table.Column<int>(type: "int", nullable: false),
Elo = table.Column<int>(type: "int", nullable: false, defaultValue: 1000),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP(6)"),
UpdatedAt = table.Column<DateTime>(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);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "match_history");
migrationBuilder.DropTable(
name: "player_stats");
}
}
}