using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace API.Migrations { /// public partial class Initial : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Games", columns: table => new { AppId = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Name = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Games", x => x.AppId); }); migrationBuilder.CreateTable( name: "Players", columns: table => new { SteamId = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Name = table.Column(type: "TEXT", nullable: false), ProfileUrl = table.Column(type: "TEXT", nullable: false), AvatarUrl = table.Column(type: "TEXT", nullable: false), UpdatedAt = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Players", x => x.SteamId); }); migrationBuilder.CreateTable( name: "GamePlayer", columns: table => new { GamesAppId = table.Column(type: "INTEGER", nullable: false), PlayedBySteamId = table.Column(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(type: "TEXT", nullable: false), GameAppId = table.Column(type: "INTEGER", nullable: false), PlayerSteamId = table.Column(type: "INTEGER", nullable: false), TimePlayed = table.Column(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"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "GamePlayer"); migrationBuilder.DropTable( name: "TrackedTime"); migrationBuilder.DropTable( name: "Games"); migrationBuilder.DropTable( name: "Players"); } } }