Files
IsleBot/Migrations/20231107003428_Initial.cs
2023-11-07 01:47:56 +01:00

132 lines
5.3 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace IsleBot.Migrations
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Players",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
UserName = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Players", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Cards",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
Attack = table.Column<int>(type: "INTEGER", nullable: false),
Defense = table.Column<int>(type: "INTEGER", nullable: false),
MaxHealth = table.Column<int>(type: "INTEGER", nullable: false),
CurrentHealth = table.Column<int>(type: "INTEGER", nullable: false),
OwnerId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Cards", x => x.Id);
table.ForeignKey(
name: "FK_Cards_Players_OwnerId",
column: x => x.OwnerId,
principalTable: "Players",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Matches",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
PlayerAId = table.Column<int>(type: "INTEGER", nullable: false),
PlayerACardId = table.Column<int>(type: "INTEGER", nullable: false),
PlayerBId = table.Column<int>(type: "INTEGER", nullable: false),
PlayerBCardId = table.Column<int>(type: "INTEGER", nullable: false),
PlayedTurns = table.Column<int>(type: "INTEGER", nullable: false),
Status = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Matches", x => x.Id);
table.ForeignKey(
name: "FK_Matches_Cards_PlayerACardId",
column: x => x.PlayerACardId,
principalTable: "Cards",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Matches_Cards_PlayerBCardId",
column: x => x.PlayerBCardId,
principalTable: "Cards",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Matches_Players_PlayerAId",
column: x => x.PlayerAId,
principalTable: "Players",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Matches_Players_PlayerBId",
column: x => x.PlayerBId,
principalTable: "Players",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Cards_OwnerId",
table: "Cards",
column: "OwnerId");
migrationBuilder.CreateIndex(
name: "IX_Matches_PlayerACardId",
table: "Matches",
column: "PlayerACardId");
migrationBuilder.CreateIndex(
name: "IX_Matches_PlayerAId",
table: "Matches",
column: "PlayerAId");
migrationBuilder.CreateIndex(
name: "IX_Matches_PlayerBCardId",
table: "Matches",
column: "PlayerBCardId");
migrationBuilder.CreateIndex(
name: "IX_Matches_PlayerBId",
table: "Matches",
column: "PlayerBId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Matches");
migrationBuilder.DropTable(
name: "Cards");
migrationBuilder.DropTable(
name: "Players");
}
}
}