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,195 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace LANCommander.Migrations
{
/// <inheritdoc />
public partial class AddGameVersions : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "GameVersionId",
table: "Scripts",
type: "TEXT",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "GameVersionId",
table: "SavePaths",
type: "TEXT",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "GameVersionId",
table: "Archive",
type: "TEXT",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "GameVersionId",
table: "Actions",
type: "TEXT",
nullable: true);
migrationBuilder.CreateTable(
name: "GameVersions",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
Version = table.Column<string>(type: "TEXT", nullable: false),
Changelog = table.Column<string>(type: "TEXT", nullable: true),
SortOrder = table.Column<int>(type: "INTEGER", nullable: false),
GameId = table.Column<Guid>(type: "TEXT", nullable: false),
CreatedOn = table.Column<DateTime>(type: "TEXT", nullable: false),
CreatedById = table.Column<Guid>(type: "TEXT", nullable: true),
UpdatedOn = table.Column<DateTime>(type: "TEXT", nullable: false),
UpdatedById = table.Column<Guid>(type: "TEXT", nullable: true)
},
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);
});
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

@ -188,6 +188,9 @@ namespace LANCommander.Migrations
b.Property<Guid?>("GameId")
.HasColumnType("TEXT");
b.Property<Guid?>("GameVersionId")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
@ -225,6 +228,8 @@ namespace LANCommander.Migrations
b.HasIndex("GameId");
b.HasIndex("GameVersionId");
b.HasIndex("ServerId");
b.HasIndex("ToolId");
@ -255,6 +260,9 @@ namespace LANCommander.Migrations
b.Property<Guid?>("GameId")
.HasColumnType("TEXT");
b.Property<Guid?>("GameVersionId")
.HasColumnType("TEXT");
b.Property<Guid?>("LastVersionId")
.HasColumnType("TEXT");
@ -290,6 +298,9 @@ namespace LANCommander.Migrations
b.HasIndex("GameId");
b.HasIndex("GameVersionId")
.IsUnique();
b.HasIndex("LastVersionId");
b.HasIndex("RedistributableId");
@ -717,6 +728,48 @@ namespace LANCommander.Migrations
b.ToTable("GameSaves");
});
modelBuilder.Entity("LANCommander.Server.Data.Models.GameVersion", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("Changelog")
.HasColumnType("TEXT");
b.Property<Guid?>("CreatedById")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedOn")
.HasColumnType("TEXT");
b.Property<Guid>("GameId")
.HasColumnType("TEXT");
b.Property<int>("SortOrder")
.HasColumnType("INTEGER");
b.Property<Guid?>("UpdatedById")
.HasColumnType("TEXT");
b.Property<DateTime>("UpdatedOn")
.HasColumnType("TEXT");
b.Property<string>("Version")
.IsRequired()
.HasColumnType("TEXT");
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")
@ -1301,6 +1354,9 @@ namespace LANCommander.Migrations
b.Property<Guid?>("GameId")
.HasColumnType("TEXT");
b.Property<Guid?>("GameVersionId")
.HasColumnType("TEXT");
b.Property<bool>("IsRegex")
.HasColumnType("INTEGER");
@ -1326,6 +1382,8 @@ namespace LANCommander.Migrations
b.HasIndex("GameId");
b.HasIndex("GameVersionId");
b.HasIndex("UpdatedById");
b.ToTable("SavePaths");
@ -1353,6 +1411,9 @@ namespace LANCommander.Migrations
b.Property<Guid?>("GameId")
.HasColumnType("TEXT");
b.Property<Guid?>("GameVersionId")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
@ -1384,6 +1445,8 @@ namespace LANCommander.Migrations
b.HasIndex("GameId");
b.HasIndex("GameVersionId");
b.HasIndex("RedistributableId");
b.HasIndex("ServerId");
@ -2147,6 +2210,11 @@ namespace LANCommander.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")
@ -2166,6 +2234,8 @@ namespace LANCommander.Migrations
b.Navigation("Game");
b.Navigation("GameVersion");
b.Navigation("Server");
b.Navigation("Tool");
@ -2185,6 +2255,11 @@ namespace LANCommander.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");
@ -2214,6 +2289,8 @@ namespace LANCommander.Migrations
b.Navigation("Game");
b.Navigation("GameVersion");
b.Navigation("LastVersion");
b.Navigation("Redistributable");
@ -2481,6 +2558,31 @@ namespace LANCommander.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")
@ -2812,6 +2914,11 @@ namespace LANCommander.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")
@ -2821,6 +2928,8 @@ namespace LANCommander.Migrations
b.Navigation("Game");
b.Navigation("GameVersion");
b.Navigation("UpdatedBy");
});
@ -2836,6 +2945,11 @@ namespace LANCommander.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")
@ -2860,6 +2974,8 @@ namespace LANCommander.Migrations
b.Navigation("Game");
b.Navigation("GameVersion");
b.Navigation("Redistributable");
b.Navigation("Server");
@ -3201,6 +3317,19 @@ namespace LANCommander.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 =>