Added GameSaves table migration

dashboard
Pat Hartl 2023-01-17 19:36:58 -06:00
parent 4f07c62247
commit 45be2f7d89
5 changed files with 1347 additions and 15 deletions

View File

@ -104,5 +104,7 @@ namespace LANCommander.Data
public DbSet<Company>? Companies { get; set; }
public DbSet<Key>? Keys { get; set; }
public DbSet<GameSave>? GameSaves { get; set; }
}
}

View File

@ -3,6 +3,7 @@ using System.Text.Json.Serialization;
namespace LANCommander.Data.Models
{
[Table("GameSaves")]
public class GameSave : BaseModel
{
public Guid GameId { get; set; }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,77 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace LANCommander.Migrations
{
public partial class AddGameSaves : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "GameSaves",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
GameId = table.Column<Guid>(type: "TEXT", nullable: false),
UserId = 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_GameSaves", x => x.Id);
table.ForeignKey(
name: "FK_GameSaves_AspNetUsers_CreatedById",
column: x => x.CreatedById,
principalTable: "AspNetUsers",
principalColumn: "Id");
table.ForeignKey(
name: "FK_GameSaves_AspNetUsers_UpdatedById",
column: x => x.UpdatedById,
principalTable: "AspNetUsers",
principalColumn: "Id");
table.ForeignKey(
name: "FK_GameSaves_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GameSaves_Games_GameId",
column: x => x.GameId,
principalTable: "Games",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_GameSaves_CreatedById",
table: "GameSaves",
column: "CreatedById");
migrationBuilder.CreateIndex(
name: "IX_GameSaves_GameId",
table: "GameSaves",
column: "GameId");
migrationBuilder.CreateIndex(
name: "IX_GameSaves_UpdatedById",
table: "GameSaves",
column: "UpdatedById");
migrationBuilder.CreateIndex(
name: "IX_GameSaves_UserId",
table: "GameSaves",
column: "UserId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "GameSaves");
}
}
}

View File

@ -29,7 +29,7 @@ namespace LANCommander.Migrations
b.HasIndex("GamesId");
b.ToTable("CategoryGame", (string)null);
b.ToTable("CategoryGame");
});
modelBuilder.Entity("GameDeveloper", b =>
@ -44,7 +44,7 @@ namespace LANCommander.Migrations
b.HasIndex("GameId");
b.ToTable("GameDeveloper", (string)null);
b.ToTable("GameDeveloper");
});
modelBuilder.Entity("GameGenre", b =>
@ -59,7 +59,7 @@ namespace LANCommander.Migrations
b.HasIndex("GenresId");
b.ToTable("GameGenre", (string)null);
b.ToTable("GameGenre");
});
modelBuilder.Entity("GamePublisher", b =>
@ -74,7 +74,7 @@ namespace LANCommander.Migrations
b.HasIndex("PublisherId");
b.ToTable("GamePublisher", (string)null);
b.ToTable("GamePublisher");
});
modelBuilder.Entity("GameTag", b =>
@ -89,7 +89,7 @@ namespace LANCommander.Migrations
b.HasIndex("TagsId");
b.ToTable("GameTag", (string)null);
b.ToTable("GameTag");
});
modelBuilder.Entity("LANCommander.Data.Models.Action", b =>
@ -140,7 +140,7 @@ namespace LANCommander.Migrations
b.HasIndex("UpdatedById");
b.ToTable("Actions", (string)null);
b.ToTable("Actions");
});
modelBuilder.Entity("LANCommander.Data.Models.Archive", b =>
@ -194,7 +194,7 @@ namespace LANCommander.Migrations
b.HasIndex("UpdatedById");
b.ToTable("Archive", (string)null);
b.ToTable("Archive");
});
modelBuilder.Entity("LANCommander.Data.Models.Category", b =>
@ -230,7 +230,7 @@ namespace LANCommander.Migrations
b.HasIndex("UpdatedById");
b.ToTable("Categories", (string)null);
b.ToTable("Categories");
});
modelBuilder.Entity("LANCommander.Data.Models.Company", b =>
@ -261,7 +261,7 @@ namespace LANCommander.Migrations
b.HasIndex("UpdatedById");
b.ToTable("Companies", (string)null);
b.ToTable("Companies");
});
modelBuilder.Entity("LANCommander.Data.Models.Game", b =>
@ -316,7 +316,44 @@ namespace LANCommander.Migrations
b.HasIndex("UpdatedById");
b.ToTable("Games", (string)null);
b.ToTable("Games");
});
modelBuilder.Entity("LANCommander.Data.Models.GameSave", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<Guid?>("CreatedById")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedOn")
.HasColumnType("TEXT");
b.Property<Guid>("GameId")
.HasColumnType("TEXT");
b.Property<Guid?>("UpdatedById")
.HasColumnType("TEXT");
b.Property<DateTime>("UpdatedOn")
.HasColumnType("TEXT");
b.Property<Guid>("UserId")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("CreatedById");
b.HasIndex("GameId");
b.HasIndex("UpdatedById");
b.HasIndex("UserId");
b.ToTable("GameSaves");
});
modelBuilder.Entity("LANCommander.Data.Models.Genre", b =>
@ -347,7 +384,7 @@ namespace LANCommander.Migrations
b.HasIndex("UpdatedById");
b.ToTable("Genres", (string)null);
b.ToTable("Genres");
});
modelBuilder.Entity("LANCommander.Data.Models.Key", b =>
@ -407,7 +444,7 @@ namespace LANCommander.Migrations
b.HasIndex("UpdatedById");
b.ToTable("Keys", (string)null);
b.ToTable("Keys");
});
modelBuilder.Entity("LANCommander.Data.Models.MultiplayerMode", b =>
@ -458,7 +495,7 @@ namespace LANCommander.Migrations
b.HasIndex("UpdatedById");
b.ToTable("MultiplayerModes", (string)null);
b.ToTable("MultiplayerModes");
});
modelBuilder.Entity("LANCommander.Data.Models.Role", b =>
@ -535,7 +572,7 @@ namespace LANCommander.Migrations
b.HasIndex("UpdatedById");
b.ToTable("Scripts", (string)null);
b.ToTable("Scripts");
});
modelBuilder.Entity("LANCommander.Data.Models.Tag", b =>
@ -566,7 +603,7 @@ namespace LANCommander.Migrations
b.HasIndex("UpdatedById");
b.ToTable("Tags", (string)null);
b.ToTable("Tags");
});
modelBuilder.Entity("LANCommander.Data.Models.User", b =>
@ -921,6 +958,37 @@ namespace LANCommander.Migrations
b.Navigation("UpdatedBy");
});
modelBuilder.Entity("LANCommander.Data.Models.GameSave", b =>
{
b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
.WithMany()
.HasForeignKey("CreatedById");
b.HasOne("LANCommander.Data.Models.Game", "Game")
.WithMany("GameSaves")
.HasForeignKey("GameId")
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
.WithMany()
.HasForeignKey("UpdatedById");
b.HasOne("LANCommander.Data.Models.User", "User")
.WithMany("GameSaves")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CreatedBy");
b.Navigation("Game");
b.Navigation("UpdatedBy");
b.Navigation("User");
});
modelBuilder.Entity("LANCommander.Data.Models.Genre", b =>
{
b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
@ -1088,12 +1156,19 @@ namespace LANCommander.Migrations
b.Navigation("Archives");
b.Navigation("GameSaves");
b.Navigation("Keys");
b.Navigation("MultiplayerModes");
b.Navigation("Scripts");
});
modelBuilder.Entity("LANCommander.Data.Models.User", b =>
{
b.Navigation("GameSaves");
});
#pragma warning restore 612, 618
}
}