using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; namespace ReallifeGamemode.Migrations { public partial class BankAccountSummary : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_UserBankAccounts_Users_UserId", table: "UserBankAccounts"); migrationBuilder.DropTable( name: "BusinessBankAccounts"); migrationBuilder.DropTable( name: "FactionBankAccounts"); migrationBuilder.DropTable( name: "GroupBankAccounts"); migrationBuilder.DropPrimaryKey( name: "PK_UserBankAccounts", table: "UserBankAccounts"); migrationBuilder.RenameTable( name: "UserBankAccounts", newName: "BankAccounts"); migrationBuilder.AlterColumn( name: "UserId", table: "BankAccounts", nullable: true, oldClrType: typeof(int)); migrationBuilder.AddColumn( name: "Discriminator", table: "BankAccounts", nullable: false, defaultValue: ""); migrationBuilder.AddColumn( name: "BusinessId", table: "BankAccounts", nullable: true); migrationBuilder.AddColumn( name: "FactionId", table: "BankAccounts", nullable: true); migrationBuilder.AddColumn( name: "GroupId", table: "BankAccounts", nullable: true); migrationBuilder.AddPrimaryKey( name: "PK_BankAccounts", table: "BankAccounts", column: "Id"); migrationBuilder.CreateIndex( name: "IX_BankAccounts_BusinessId", table: "BankAccounts", column: "BusinessId", unique: true); migrationBuilder.CreateIndex( name: "IX_BankAccounts_FactionId", table: "BankAccounts", column: "FactionId"); migrationBuilder.CreateIndex( name: "IX_BankAccounts_GroupId", table: "BankAccounts", column: "GroupId"); migrationBuilder.AddForeignKey( name: "FK_BankAccounts_Factions_FactionId", table: "BankAccounts", column: "FactionId", principalTable: "Factions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_BankAccounts_Groups_GroupId", table: "BankAccounts", column: "GroupId", principalTable: "Groups", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_BankAccounts_Users_UserId", table: "BankAccounts", column: "UserId", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_BankAccounts_Factions_FactionId", table: "BankAccounts"); migrationBuilder.DropForeignKey( name: "FK_BankAccounts_Groups_GroupId", table: "BankAccounts"); migrationBuilder.DropForeignKey( name: "FK_BankAccounts_Users_UserId", table: "BankAccounts"); migrationBuilder.DropPrimaryKey( name: "PK_BankAccounts", table: "BankAccounts"); migrationBuilder.DropIndex( name: "IX_BankAccounts_BusinessId", table: "BankAccounts"); migrationBuilder.DropIndex( name: "IX_BankAccounts_FactionId", table: "BankAccounts"); migrationBuilder.DropIndex( name: "IX_BankAccounts_GroupId", table: "BankAccounts"); migrationBuilder.DropColumn( name: "Discriminator", table: "BankAccounts"); migrationBuilder.DropColumn( name: "BusinessId", table: "BankAccounts"); migrationBuilder.DropColumn( name: "FactionId", table: "BankAccounts"); migrationBuilder.DropColumn( name: "GroupId", table: "BankAccounts"); migrationBuilder.RenameTable( name: "BankAccounts", newName: "UserBankAccounts"); migrationBuilder.AlterColumn( name: "UserId", table: "UserBankAccounts", nullable: false, oldClrType: typeof(int), oldNullable: true); migrationBuilder.AddPrimaryKey( name: "PK_UserBankAccounts", table: "UserBankAccounts", column: "Id"); migrationBuilder.CreateTable( name: "BusinessBankAccounts", columns: table => new { Id = table.Column(nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Balance = table.Column(nullable: false), BusinessId = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_BusinessBankAccounts", x => x.Id); }); migrationBuilder.CreateTable( name: "FactionBankAccounts", columns: table => new { Id = table.Column(nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), Balance = table.Column(nullable: false), Bic = table.Column(maxLength: 12, nullable: true), FactionId = table.Column(nullable: false), Iban = table.Column(maxLength: 32, nullable: true) }, constraints: table => { table.PrimaryKey("PK_FactionBankAccounts", x => x.Id); table.ForeignKey( name: "FK_FactionBankAccounts_Factions_FactionId", column: x => x.FactionId, principalTable: "Factions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "GroupBankAccounts", columns: table => new { Id = table.Column(nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Balance = table.Column(nullable: false), GroupId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_GroupBankAccounts", x => x.Id); table.ForeignKey( name: "FK_GroupBankAccounts_Groups_GroupId", column: x => x.GroupId, principalTable: "Groups", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_BusinessBankAccounts_BusinessId", table: "BusinessBankAccounts", column: "BusinessId", unique: true); migrationBuilder.CreateIndex( name: "IX_FactionBankAccounts_FactionId", table: "FactionBankAccounts", column: "FactionId"); migrationBuilder.CreateIndex( name: "IX_GroupBankAccounts_GroupId", table: "GroupBankAccounts", column: "GroupId"); migrationBuilder.AddForeignKey( name: "FK_UserBankAccounts_Users_UserId", table: "UserBankAccounts", column: "UserId", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } } }