SteamGameTimeTrack/API/Migrations/20250525221352_Initial.cs
2025-05-26 01:44:36 +02:00

126 lines
4.9 KiB
C#

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");
}
}
}