Files
2025-09-07 19:06:43 +02:00

238 lines
10 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace MTG_CollectionVerwaltung.Data.Migrations.MTG
{
/// <inheritdoc />
public partial class MTG_InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Sets",
columns: table => new
{
SetCode = table.Column<string>(type: "TEXT", maxLength: 10, nullable: false),
SetName = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
SetIcon = table.Column<string>(type: "TEXT", nullable: false),
SetType = table.Column<string>(type: "TEXT", nullable: false),
CardCount = table.Column<int>(type: "INTEGER", nullable: false),
ReleaseDate = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Sets", x => x.SetCode);
});
migrationBuilder.CreateTable(
name: "Supertypes",
columns: table => new
{
TypeId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
TypeEn = table.Column<string>(type: "TEXT", nullable: false, collation: "NOCASE"),
TypeDe = table.Column<string>(type: "TEXT", nullable: false, collation: "NOCASE")
},
constraints: table =>
{
table.PrimaryKey("PK_Supertypes", x => x.TypeId);
});
migrationBuilder.CreateTable(
name: "Types",
columns: table => new
{
TypeId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
TypeEn = table.Column<string>(type: "TEXT", nullable: false, collation: "NOCASE"),
TypeDe = table.Column<string>(type: "TEXT", nullable: false, collation: "NOCASE")
},
constraints: table =>
{
table.PrimaryKey("PK_Types", x => x.TypeId);
});
migrationBuilder.CreateTable(
name: "Cards",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
SetCode = table.Column<string>(type: "TEXT", maxLength: 10, nullable: false),
CardName = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
CollectorNumber = table.Column<string>(type: "TEXT", nullable: true),
ManaCost = table.Column<string>(type: "TEXT", nullable: true),
Foil = table.Column<bool>(type: "INTEGER", nullable: false, defaultValue: false),
NonFoil = table.Column<bool>(type: "INTEGER", nullable: false, defaultValue: false),
Rarity = table.Column<string>(type: "TEXT", nullable: true),
Power = table.Column<string>(type: "TEXT", nullable: true),
Toughness = table.Column<string>(type: "TEXT", nullable: true),
SuperTypeId = table.Column<int>(type: "INTEGER", nullable: false),
Cmc = table.Column<int>(type: "INTEGER", nullable: false),
OtherFace = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Cards", x => x.Id);
table.ForeignKey(
name: "FK_Cards_Sets_SetCode",
column: x => x.SetCode,
principalTable: "Sets",
principalColumn: "SetCode",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Cards_Supertypes_SuperTypeId",
column: x => x.SuperTypeId,
principalTable: "Supertypes",
principalColumn: "TypeId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "CardCollections",
columns: table => new
{
CardId = table.Column<string>(type: "TEXT", nullable: false),
UserId = table.Column<string>(type: "TEXT", nullable: false),
Count = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CardCollections", x => new { x.CardId, x.UserId });
table.ForeignKey(
name: "FK_CardCollections_Cards_CardId",
column: x => x.CardId,
principalTable: "Cards",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "CardPrintings",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
CardId = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
Lang = table.Column<string>(type: "TEXT", maxLength: 5, nullable: false),
Name = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false, collation: "NOCASE"),
OracleText = table.Column<string>(type: "TEXT", nullable: true, collation: "NOCASE"),
FlavorText = table.Column<string>(type: "TEXT", nullable: true),
ImageUriSmall = table.Column<string>(type: "TEXT", nullable: true),
ImageUriNormal = table.Column<string>(type: "TEXT", nullable: true),
ImageUriLarge = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_CardPrintings", x => x.Id);
table.ForeignKey(
name: "FK_CardPrintings_Cards_CardId",
column: x => x.CardId,
principalTable: "Cards",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "CardTypes",
columns: table => new
{
CardId = table.Column<string>(type: "TEXT", nullable: false),
TypeId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CardTypes", x => new { x.CardId, x.TypeId });
table.ForeignKey(
name: "FK_CardTypes_Cards_CardId",
column: x => x.CardId,
principalTable: "Cards",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_CardTypes_Types_TypeId",
column: x => x.TypeId,
principalTable: "Types",
principalColumn: "TypeId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_CardCollections_UserId",
table: "CardCollections",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_CardPrintings_CardId_Lang",
table: "CardPrintings",
columns: new[] { "CardId", "Lang" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_CardPrintings_Name",
table: "CardPrintings",
column: "Name");
migrationBuilder.CreateIndex(
name: "IX_CardPrintings_OracleText",
table: "CardPrintings",
column: "OracleText");
migrationBuilder.CreateIndex(
name: "IX_Cards_CardName",
table: "Cards",
column: "CardName");
migrationBuilder.CreateIndex(
name: "IX_Cards_CollectorNumber_SetCode",
table: "Cards",
columns: new[] { "CollectorNumber", "SetCode" });
migrationBuilder.CreateIndex(
name: "IX_Cards_SetCode",
table: "Cards",
column: "SetCode");
migrationBuilder.CreateIndex(
name: "IX_Cards_SuperTypeId",
table: "Cards",
column: "SuperTypeId");
migrationBuilder.CreateIndex(
name: "IX_CardTypes_TypeId",
table: "CardTypes",
column: "TypeId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("DROP TABLE IF EXISTS CardPrintingsFTS;");
migrationBuilder.DropTable(
name: "CardCollections");
migrationBuilder.DropTable(
name: "CardPrintings");
migrationBuilder.DropTable(
name: "CardTypes");
migrationBuilder.DropTable(
name: "Cards");
migrationBuilder.DropTable(
name: "Types");
migrationBuilder.DropTable(
name: "Sets");
migrationBuilder.DropTable(
name: "Supertypes");
}
}
}