using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace MTG_CollectionVerwaltung.Data.Migrations.MTG { /// public partial class MTG_InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Sets", columns: table => new { SetCode = table.Column(type: "TEXT", maxLength: 10, nullable: false), SetName = table.Column(type: "TEXT", maxLength: 50, nullable: false), SetIcon = table.Column(type: "TEXT", nullable: false), SetType = table.Column(type: "TEXT", nullable: false), CardCount = table.Column(type: "INTEGER", nullable: false), ReleaseDate = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Sets", x => x.SetCode); }); migrationBuilder.CreateTable( name: "Supertypes", columns: table => new { TypeId = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), TypeEn = table.Column(type: "TEXT", nullable: false, collation: "NOCASE"), TypeDe = table.Column(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(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), TypeEn = table.Column(type: "TEXT", nullable: false, collation: "NOCASE"), TypeDe = table.Column(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(type: "TEXT", nullable: false), SetCode = table.Column(type: "TEXT", maxLength: 10, nullable: false), CardName = table.Column(type: "TEXT", maxLength: 100, nullable: false), CollectorNumber = table.Column(type: "TEXT", nullable: true), ManaCost = table.Column(type: "TEXT", nullable: true), Foil = table.Column(type: "INTEGER", nullable: false, defaultValue: false), NonFoil = table.Column(type: "INTEGER", nullable: false, defaultValue: false), Rarity = table.Column(type: "TEXT", nullable: true), Power = table.Column(type: "TEXT", nullable: true), Toughness = table.Column(type: "TEXT", nullable: true), SuperTypeId = table.Column(type: "INTEGER", nullable: false), Cmc = table.Column(type: "INTEGER", nullable: false), OtherFace = table.Column(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(type: "TEXT", nullable: false), UserId = table.Column(type: "TEXT", nullable: false), Count = table.Column(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(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), CardId = table.Column(type: "TEXT", maxLength: 40, nullable: false), Lang = table.Column(type: "TEXT", maxLength: 5, nullable: false), Name = table.Column(type: "TEXT", maxLength: 100, nullable: false, collation: "NOCASE"), OracleText = table.Column(type: "TEXT", nullable: true, collation: "NOCASE"), FlavorText = table.Column(type: "TEXT", nullable: true), ImageUriSmall = table.Column(type: "TEXT", nullable: true), ImageUriNormal = table.Column(type: "TEXT", nullable: true), ImageUriLarge = table.Column(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(type: "TEXT", nullable: false), TypeId = table.Column(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"); } /// 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"); } } }