This commit is contained in:
2025-05-26 01:44:36 +02:00
parent 1a08f932af
commit 4405c0349e
4 changed files with 426 additions and 0 deletions

View File

@ -0,0 +1,148 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SQLiteEF;
#nullable disable
namespace API.Migrations
{
[DbContext(typeof(Context))]
[Migration("20250525221352_Initial")]
partial class Initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.5");
modelBuilder.Entity("GamePlayer", b =>
{
b.Property<ulong>("GamesAppId")
.HasColumnType("INTEGER");
b.Property<ulong>("PlayedBySteamId")
.HasColumnType("INTEGER");
b.HasKey("GamesAppId", "PlayedBySteamId");
b.HasIndex("PlayedBySteamId");
b.ToTable("GamePlayer");
});
modelBuilder.Entity("SQLiteEF.Game", b =>
{
b.Property<ulong>("AppId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("AppId");
b.ToTable("Games");
});
modelBuilder.Entity("SQLiteEF.Player", b =>
{
b.Property<ulong>("SteamId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("AvatarUrl")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("ProfileUrl")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("TEXT");
b.HasKey("SteamId");
b.ToTable("Players");
});
modelBuilder.Entity("SQLiteEF.TrackedTime", b =>
{
b.Property<DateTime>("TimeStamp")
.HasColumnType("TEXT");
b.Property<ulong>("GameAppId")
.HasColumnType("INTEGER");
b.Property<ulong>("PlayerSteamId")
.HasColumnType("INTEGER");
b.Property<ulong>("TimePlayed")
.HasColumnType("INTEGER");
b.HasKey("TimeStamp");
b.HasIndex("GameAppId");
b.HasIndex("PlayerSteamId");
b.ToTable("TrackedTime");
});
modelBuilder.Entity("GamePlayer", b =>
{
b.HasOne("SQLiteEF.Game", null)
.WithMany()
.HasForeignKey("GamesAppId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SQLiteEF.Player", null)
.WithMany()
.HasForeignKey("PlayedBySteamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("SQLiteEF.TrackedTime", b =>
{
b.HasOne("SQLiteEF.Game", "Game")
.WithMany("TrackedTimes")
.HasForeignKey("GameAppId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SQLiteEF.Player", "Player")
.WithMany("TrackedTimes")
.HasForeignKey("PlayerSteamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Game");
b.Navigation("Player");
});
modelBuilder.Entity("SQLiteEF.Game", b =>
{
b.Navigation("TrackedTimes");
});
modelBuilder.Entity("SQLiteEF.Player", b =>
{
b.Navigation("TrackedTimes");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,125 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace API.Migrations
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Games",
columns: table => new
{
AppId = table.Column<ulong>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Games", x => x.AppId);
});
migrationBuilder.CreateTable(
name: "Players",
columns: table => new
{
SteamId = table.Column<ulong>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
ProfileUrl = table.Column<string>(type: "TEXT", nullable: false),
AvatarUrl = table.Column<string>(type: "TEXT", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Players", x => x.SteamId);
});
migrationBuilder.CreateTable(
name: "GamePlayer",
columns: table => new
{
GamesAppId = table.Column<ulong>(type: "INTEGER", nullable: false),
PlayedBySteamId = table.Column<ulong>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GamePlayer", x => new { x.GamesAppId, x.PlayedBySteamId });
table.ForeignKey(
name: "FK_GamePlayer_Games_GamesAppId",
column: x => x.GamesAppId,
principalTable: "Games",
principalColumn: "AppId",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GamePlayer_Players_PlayedBySteamId",
column: x => x.PlayedBySteamId,
principalTable: "Players",
principalColumn: "SteamId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "TrackedTime",
columns: table => new
{
TimeStamp = table.Column<DateTime>(type: "TEXT", nullable: false),
GameAppId = table.Column<ulong>(type: "INTEGER", nullable: false),
PlayerSteamId = table.Column<ulong>(type: "INTEGER", nullable: false),
TimePlayed = table.Column<ulong>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TrackedTime", x => x.TimeStamp);
table.ForeignKey(
name: "FK_TrackedTime_Games_GameAppId",
column: x => x.GameAppId,
principalTable: "Games",
principalColumn: "AppId",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TrackedTime_Players_PlayerSteamId",
column: x => x.PlayerSteamId,
principalTable: "Players",
principalColumn: "SteamId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_GamePlayer_PlayedBySteamId",
table: "GamePlayer",
column: "PlayedBySteamId");
migrationBuilder.CreateIndex(
name: "IX_TrackedTime_GameAppId",
table: "TrackedTime",
column: "GameAppId");
migrationBuilder.CreateIndex(
name: "IX_TrackedTime_PlayerSteamId",
table: "TrackedTime",
column: "PlayerSteamId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "GamePlayer");
migrationBuilder.DropTable(
name: "TrackedTime");
migrationBuilder.DropTable(
name: "Games");
migrationBuilder.DropTable(
name: "Players");
}
}
}

View File

@ -0,0 +1,145 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SQLiteEF;
#nullable disable
namespace API.Migrations
{
[DbContext(typeof(Context))]
partial class ContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.5");
modelBuilder.Entity("GamePlayer", b =>
{
b.Property<ulong>("GamesAppId")
.HasColumnType("INTEGER");
b.Property<ulong>("PlayedBySteamId")
.HasColumnType("INTEGER");
b.HasKey("GamesAppId", "PlayedBySteamId");
b.HasIndex("PlayedBySteamId");
b.ToTable("GamePlayer");
});
modelBuilder.Entity("SQLiteEF.Game", b =>
{
b.Property<ulong>("AppId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("AppId");
b.ToTable("Games");
});
modelBuilder.Entity("SQLiteEF.Player", b =>
{
b.Property<ulong>("SteamId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("AvatarUrl")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("ProfileUrl")
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("TEXT");
b.HasKey("SteamId");
b.ToTable("Players");
});
modelBuilder.Entity("SQLiteEF.TrackedTime", b =>
{
b.Property<DateTime>("TimeStamp")
.HasColumnType("TEXT");
b.Property<ulong>("GameAppId")
.HasColumnType("INTEGER");
b.Property<ulong>("PlayerSteamId")
.HasColumnType("INTEGER");
b.Property<ulong>("TimePlayed")
.HasColumnType("INTEGER");
b.HasKey("TimeStamp");
b.HasIndex("GameAppId");
b.HasIndex("PlayerSteamId");
b.ToTable("TrackedTime");
});
modelBuilder.Entity("GamePlayer", b =>
{
b.HasOne("SQLiteEF.Game", null)
.WithMany()
.HasForeignKey("GamesAppId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SQLiteEF.Player", null)
.WithMany()
.HasForeignKey("PlayedBySteamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("SQLiteEF.TrackedTime", b =>
{
b.HasOne("SQLiteEF.Game", "Game")
.WithMany("TrackedTimes")
.HasForeignKey("GameAppId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SQLiteEF.Player", "Player")
.WithMany("TrackedTimes")
.HasForeignKey("PlayerSteamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Game");
b.Navigation("Player");
});
modelBuilder.Entity("SQLiteEF.Game", b =>
{
b.Navigation("TrackedTimes");
});
modelBuilder.Entity("SQLiteEF.Player", b =>
{
b.Navigation("TrackedTimes");
});
#pragma warning restore 612, 618
}
}
}