Fix MySQL migrations

Fixes #168
This commit is contained in:
Pat Hartl 2025-02-12 20:38:59 -06:00
parent 10e4db0ec6
commit 2012f12379
9 changed files with 19 additions and 29 deletions

View file

@ -20,8 +20,8 @@
<PackageReference Include="Crc32.NET" Version="1.2.0" />
<PackageReference Include="Facepunch.Steamworks" Version="2.3.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.1" />
<PackageReference Include="Microsoft.PowerShell.Commands.Diagnostics" Version="7.5.0" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.5.0" />
<PackageReference Include="Microsoft.PowerShell.Commands.Diagnostics" Version="7.4.7" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.4.7" />
<PackageReference Include="PeanutButter.INI" Version="3.0.339" />
<PackageReference Include="RestSharp" Version="112.1.0" />
<PackageReference Include="Semver" Version="3.0.0" />

View file

@ -9,15 +9,11 @@
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.1" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0-preview.2.efcore.9.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LANCommander.Server.Data\LANCommander.Server.Data.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
</Project>

View file

@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace LANCommander.Server.Data.MySQL.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20250203083220_InitialMigration")]
[Migration("20250213023250_InitialMigration")]
partial class InitialMigration
{
/// <inheritdoc />
@ -20,7 +20,7 @@ namespace LANCommander.Server.Data.MySQL.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.10")
.HasAnnotation("ProductVersion", "9.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
@ -806,8 +806,7 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.Property<string>("Description")
.HasColumnType("longtext");
b.Property<Guid?>("GameId")
.IsRequired()
b.Property<Guid>("GameId")
.HasColumnType("char(36)");
b.Property<int>("MaxPlayers")
@ -1263,8 +1262,7 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.Property<int?>("Port")
.HasColumnType("int");
b.Property<Guid?>("ServerId")
.IsRequired()
b.Property<Guid>("ServerId")
.HasColumnType("char(36)");
b.Property<Guid?>("ServerId1")
@ -1524,8 +1522,7 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.Property<DateTime>("UpdatedOn")
.HasColumnType("datetime(6)");
b.Property<Guid?>("UserId")
.IsRequired()
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.Property<string>("Value")
@ -2201,7 +2198,7 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.HasOne("LANCommander.Server.Data.Models.StorageLocation", "StorageLocation")
.WithMany("Media")
.HasForeignKey("StorageLocationId")
.OnDelete(DeleteBehavior.SetNull)
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("LANCommander.Server.Data.Models.Media", "Thumbnail")

View file

@ -1245,7 +1245,7 @@ namespace LANCommander.Server.Data.MySQL.Migrations
column: x => x.StorageLocationId,
principalTable: "StorageLocations",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Media_Users_CreatedById",
column: x => x.CreatedById,

View file

@ -17,7 +17,7 @@ namespace LANCommander.Server.Data.MySQL.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.10")
.HasAnnotation("ProductVersion", "9.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
@ -803,8 +803,7 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.Property<string>("Description")
.HasColumnType("longtext");
b.Property<Guid?>("GameId")
.IsRequired()
b.Property<Guid>("GameId")
.HasColumnType("char(36)");
b.Property<int>("MaxPlayers")
@ -1260,8 +1259,7 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.Property<int?>("Port")
.HasColumnType("int");
b.Property<Guid?>("ServerId")
.IsRequired()
b.Property<Guid>("ServerId")
.HasColumnType("char(36)");
b.Property<Guid?>("ServerId1")
@ -1521,8 +1519,7 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.Property<DateTime>("UpdatedOn")
.HasColumnType("datetime(6)");
b.Property<Guid?>("UserId")
.IsRequired()
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.Property<string>("Value")
@ -2198,7 +2195,7 @@ namespace LANCommander.Server.Data.MySQL.Migrations
b.HasOne("LANCommander.Server.Data.Models.StorageLocation", "StorageLocation")
.WithMany("Media")
.HasForeignKey("StorageLocationId")
.OnDelete(DeleteBehavior.SetNull)
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("LANCommander.Server.Data.Models.Media", "Thumbnail")

View file

@ -220,7 +220,7 @@ namespace LANCommander.Server.Data
.HasOne(m => m.StorageLocation)
.WithMany(l => l.Media)
.IsRequired(true)
.OnDelete(DeleteBehavior.SetNull);
.OnDelete(DeleteBehavior.Cascade);
builder.Entity<Media>()
.Navigation(m => m.StorageLocation)

View file

@ -13,7 +13,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.3" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0-preview.2.efcore.9.0.0" />
</ItemGroup>
<ItemGroup>

View file

@ -17,7 +17,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.3" />
<PackageReference Include="Octokit" Version="14.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0-preview.2.efcore.9.0.0" />
<PackageReference Include="rix0rrr.BeaconLib" Version="1.0.2" />
<PackageReference Include="Semver" Version="3.0.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.6" />

View file

@ -94,7 +94,7 @@
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="9.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.1">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>