First pass at adding versions to games

This commit is contained in:
Pat Hartl 2026-06-27 11:03:34 -05:00
parent a778a56b18
commit 1202e11491
41 changed files with 12165 additions and 69 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,202 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace LANCommander.Server.Data.MySQL.Migrations
{
/// <inheritdoc />
public partial class AddGameVersions : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "GameVersionId",
table: "Scripts",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "GameVersionId",
table: "SavePaths",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "GameVersionId",
table: "Archive",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "GameVersionId",
table: "Actions",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.CreateTable(
name: "GameVersions",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Version = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Changelog = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
SortOrder = table.Column<int>(type: "int", nullable: false),
GameId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
CreatedOn = table.Column<DateTime>(type: "datetime(6)", nullable: false),
CreatedById = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
UpdatedOn = table.Column<DateTime>(type: "datetime(6)", nullable: false),
UpdatedById = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_GameVersions", x => x.Id);
table.ForeignKey(
name: "FK_GameVersions_Games_GameId",
column: x => x.GameId,
principalTable: "Games",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GameVersions_Users_CreatedById",
column: x => x.CreatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_GameVersions_Users_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_Scripts_GameVersionId",
table: "Scripts",
column: "GameVersionId");
migrationBuilder.CreateIndex(
name: "IX_SavePaths_GameVersionId",
table: "SavePaths",
column: "GameVersionId");
migrationBuilder.CreateIndex(
name: "IX_Archive_GameVersionId",
table: "Archive",
column: "GameVersionId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Actions_GameVersionId",
table: "Actions",
column: "GameVersionId");
migrationBuilder.CreateIndex(
name: "IX_GameVersions_CreatedById",
table: "GameVersions",
column: "CreatedById");
migrationBuilder.CreateIndex(
name: "IX_GameVersions_GameId",
table: "GameVersions",
column: "GameId");
migrationBuilder.CreateIndex(
name: "IX_GameVersions_UpdatedById",
table: "GameVersions",
column: "UpdatedById");
migrationBuilder.AddForeignKey(
name: "FK_Actions_GameVersions_GameVersionId",
table: "Actions",
column: "GameVersionId",
principalTable: "GameVersions",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Archive_GameVersions_GameVersionId",
table: "Archive",
column: "GameVersionId",
principalTable: "GameVersions",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_SavePaths_GameVersions_GameVersionId",
table: "SavePaths",
column: "GameVersionId",
principalTable: "GameVersions",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Scripts_GameVersions_GameVersionId",
table: "Scripts",
column: "GameVersionId",
principalTable: "GameVersions",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Actions_GameVersions_GameVersionId",
table: "Actions");
migrationBuilder.DropForeignKey(
name: "FK_Archive_GameVersions_GameVersionId",
table: "Archive");
migrationBuilder.DropForeignKey(
name: "FK_SavePaths_GameVersions_GameVersionId",
table: "SavePaths");
migrationBuilder.DropForeignKey(
name: "FK_Scripts_GameVersions_GameVersionId",
table: "Scripts");
migrationBuilder.DropTable(
name: "GameVersions");
migrationBuilder.DropIndex(
name: "IX_Scripts_GameVersionId",
table: "Scripts");
migrationBuilder.DropIndex(
name: "IX_SavePaths_GameVersionId",
table: "SavePaths");
migrationBuilder.DropIndex(
name: "IX_Archive_GameVersionId",
table: "Archive");
migrationBuilder.DropIndex(
name: "IX_Actions_GameVersionId",
table: "Actions");
migrationBuilder.DropColumn(
name: "GameVersionId",
table: "Scripts");
migrationBuilder.DropColumn(
name: "GameVersionId",
table: "SavePaths");
migrationBuilder.DropColumn(
name: "GameVersionId",
table: "Archive");
migrationBuilder.DropColumn(
name: "GameVersionId",
table: "Actions");
}
}
}

View file

@ -193,6 +193,9 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.Property<Guid?>("GameId")
.HasColumnType("char(36)");
b.Property<Guid?>("GameVersionId")
.HasColumnType("char(36)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
@ -230,6 +233,8 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.HasIndex("GameId");
b.HasIndex("GameVersionId");
b.HasIndex("ServerId");
b.HasIndex("ToolId");
@ -260,6 +265,9 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.Property<Guid?>("GameId")
.HasColumnType("char(36)");
b.Property<Guid?>("GameVersionId")
.HasColumnType("char(36)");
b.Property<Guid?>("LastVersionId")
.HasColumnType("char(36)");
@ -295,6 +303,9 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.HasIndex("GameId");
b.HasIndex("GameVersionId")
.IsUnique();
b.HasIndex("LastVersionId");
b.HasIndex("RedistributableId");
@ -722,6 +733,48 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.ToTable("GameSaves");
});
modelBuilder.Entity("LANCommander.Server.Data.Models.GameVersion", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)");
b.Property<string>("Changelog")
.HasColumnType("longtext");
b.Property<Guid?>("CreatedById")
.HasColumnType("char(36)");
b.Property<DateTime>("CreatedOn")
.HasColumnType("datetime(6)");
b.Property<Guid>("GameId")
.HasColumnType("char(36)");
b.Property<int>("SortOrder")
.HasColumnType("int");
b.Property<Guid?>("UpdatedById")
.HasColumnType("char(36)");
b.Property<DateTime>("UpdatedOn")
.HasColumnType("datetime(6)");
b.Property<string>("Version")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.HasIndex("CreatedById");
b.HasIndex("GameId");
b.HasIndex("UpdatedById");
b.ToTable("GameVersions");
});
modelBuilder.Entity("LANCommander.Server.Data.Models.Genre", b =>
{
b.Property<Guid>("Id")
@ -1308,6 +1361,9 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.Property<Guid?>("GameId")
.HasColumnType("char(36)");
b.Property<Guid?>("GameVersionId")
.HasColumnType("char(36)");
b.Property<bool>("IsRegex")
.HasColumnType("tinyint(1)");
@ -1333,6 +1389,8 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.HasIndex("GameId");
b.HasIndex("GameVersionId");
b.HasIndex("UpdatedById");
b.ToTable("SavePaths");
@ -1360,6 +1418,9 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.Property<Guid?>("GameId")
.HasColumnType("char(36)");
b.Property<Guid?>("GameVersionId")
.HasColumnType("char(36)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
@ -1391,6 +1452,8 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.HasIndex("GameId");
b.HasIndex("GameVersionId");
b.HasIndex("RedistributableId");
b.HasIndex("ServerId");
@ -2156,6 +2219,11 @@ namespace LANCommander.Server.Data.MySQL.Migrations
.HasForeignKey("GameId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("LANCommander.Server.Data.Models.GameVersion", "GameVersion")
.WithMany("Actions")
.HasForeignKey("GameVersionId")
.OnDelete(DeleteBehavior.ClientCascade);
b.HasOne("LANCommander.Server.Data.Models.Server", "Server")
.WithMany("Actions")
.HasForeignKey("ServerId")
@ -2175,6 +2243,8 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.Navigation("Game");
b.Navigation("GameVersion");
b.Navigation("Server");
b.Navigation("Tool");
@ -2194,6 +2264,11 @@ namespace LANCommander.Server.Data.MySQL.Migrations
.HasForeignKey("GameId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("LANCommander.Server.Data.Models.GameVersion", "GameVersion")
.WithOne("Archive")
.HasForeignKey("LANCommander.Server.Data.Models.Archive", "GameVersionId")
.OnDelete(DeleteBehavior.ClientCascade);
b.HasOne("LANCommander.Server.Data.Models.Archive", "LastVersion")
.WithMany()
.HasForeignKey("LastVersionId");
@ -2223,6 +2298,8 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.Navigation("Game");
b.Navigation("GameVersion");
b.Navigation("LastVersion");
b.Navigation("Redistributable");
@ -2490,6 +2567,31 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.Navigation("User");
});
modelBuilder.Entity("LANCommander.Server.Data.Models.GameVersion", b =>
{
b.HasOne("LANCommander.Server.Data.Models.User", "CreatedBy")
.WithMany()
.HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("LANCommander.Server.Data.Models.Game", "Game")
.WithMany("Versions")
.HasForeignKey("GameId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("LANCommander.Server.Data.Models.User", "UpdatedBy")
.WithMany()
.HasForeignKey("UpdatedById")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("CreatedBy");
b.Navigation("Game");
b.Navigation("UpdatedBy");
});
modelBuilder.Entity("LANCommander.Server.Data.Models.Genre", b =>
{
b.HasOne("LANCommander.Server.Data.Models.User", "CreatedBy")
@ -2821,6 +2923,11 @@ namespace LANCommander.Server.Data.MySQL.Migrations
.HasForeignKey("GameId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("LANCommander.Server.Data.Models.GameVersion", "GameVersion")
.WithMany("SavePaths")
.HasForeignKey("GameVersionId")
.OnDelete(DeleteBehavior.ClientCascade);
b.HasOne("LANCommander.Server.Data.Models.User", "UpdatedBy")
.WithMany()
.HasForeignKey("UpdatedById")
@ -2830,6 +2937,8 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.Navigation("Game");
b.Navigation("GameVersion");
b.Navigation("UpdatedBy");
});
@ -2845,6 +2954,11 @@ namespace LANCommander.Server.Data.MySQL.Migrations
.HasForeignKey("GameId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("LANCommander.Server.Data.Models.GameVersion", "GameVersion")
.WithMany("Scripts")
.HasForeignKey("GameVersionId")
.OnDelete(DeleteBehavior.ClientCascade);
b.HasOne("LANCommander.Server.Data.Models.Redistributable", "Redistributable")
.WithMany("Scripts")
.HasForeignKey("RedistributableId")
@ -2869,6 +2983,8 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.Navigation("Game");
b.Navigation("GameVersion");
b.Navigation("Redistributable");
b.Navigation("Server");
@ -3210,6 +3326,19 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.Navigation("Scripts");
b.Navigation("Servers");
b.Navigation("Versions");
});
modelBuilder.Entity("LANCommander.Server.Data.Models.GameVersion", b =>
{
b.Navigation("Actions");
b.Navigation("Archive");
b.Navigation("SavePaths");
b.Navigation("Scripts");
});
modelBuilder.Entity("LANCommander.Server.Data.Models.Media", b =>