bank account refactor
This commit is contained in:
1423
ReallifeGamemode.Database/Migrations/20200315113621_BankAccountRefactor.Designer.cs
generated
Normal file
1423
ReallifeGamemode.Database/Migrations/20200315113621_BankAccountRefactor.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,210 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace ReallifeGamemode.Database.Migrations
|
||||
{
|
||||
public partial class BankAccountRefactor : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_FactionBankAccounts_Factions_FactionId",
|
||||
table: "FactionBankAccounts");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_GroupBankAccounts_Groups_GroupId",
|
||||
table: "GroupBankAccounts");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_UserBankAccounts_Users_UserId",
|
||||
table: "UserBankAccounts");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_UserBankAccounts_UserId",
|
||||
table: "UserBankAccounts");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_GroupBankAccounts_GroupId",
|
||||
table: "GroupBankAccounts");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_FactionBankAccounts_FactionId",
|
||||
table: "FactionBankAccounts");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "BankAccountId",
|
||||
table: "Users",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "BankAccountId",
|
||||
table: "Groups",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "BankAccountId",
|
||||
table: "Factions",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.Sql(@"
|
||||
UPDATE users u
|
||||
INNER JOIN userbankaccounts ub ON ub.userid = u.id
|
||||
SET u.bankaccountid = ub.id");
|
||||
|
||||
migrationBuilder.Sql(@"
|
||||
UPDATE factions f
|
||||
INNER JOIN factionbankaccounts fb ON fb.factionid = f.id
|
||||
SET f.bankaccountid = fb.id");
|
||||
|
||||
migrationBuilder.Sql(@"
|
||||
UPDATE groups g
|
||||
INNER JOIN groupbankaccounts gb ON gb.groupid = g.id
|
||||
SET g.bankaccountid = gb.id");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "UserId",
|
||||
table: "UserBankAccounts");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "GroupId",
|
||||
table: "GroupBankAccounts");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "FactionId",
|
||||
table: "FactionBankAccounts");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Users_BankAccountId",
|
||||
table: "Users",
|
||||
column: "BankAccountId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Groups_BankAccountId",
|
||||
table: "Groups",
|
||||
column: "BankAccountId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Factions_BankAccountId",
|
||||
table: "Factions",
|
||||
column: "BankAccountId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Factions_FactionBankAccounts_BankAccountId",
|
||||
table: "Factions",
|
||||
column: "BankAccountId",
|
||||
principalTable: "FactionBankAccounts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Groups_GroupBankAccounts_BankAccountId",
|
||||
table: "Groups",
|
||||
column: "BankAccountId",
|
||||
principalTable: "GroupBankAccounts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Users_UserBankAccounts_BankAccountId",
|
||||
table: "Users",
|
||||
column: "BankAccountId",
|
||||
principalTable: "UserBankAccounts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Factions_FactionBankAccounts_BankAccountId",
|
||||
table: "Factions");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Groups_GroupBankAccounts_BankAccountId",
|
||||
table: "Groups");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Users_UserBankAccounts_BankAccountId",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Users_BankAccountId",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Groups_BankAccountId",
|
||||
table: "Groups");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Factions_BankAccountId",
|
||||
table: "Factions");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "BankAccountId",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "BankAccountId",
|
||||
table: "Groups");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "BankAccountId",
|
||||
table: "Factions");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "UserId",
|
||||
table: "UserBankAccounts",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "GroupId",
|
||||
table: "GroupBankAccounts",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "FactionId",
|
||||
table: "FactionBankAccounts",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UserBankAccounts_UserId",
|
||||
table: "UserBankAccounts",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_GroupBankAccounts_GroupId",
|
||||
table: "GroupBankAccounts",
|
||||
column: "GroupId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_FactionBankAccounts_FactionId",
|
||||
table: "FactionBankAccounts",
|
||||
column: "FactionId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_FactionBankAccounts_Factions_FactionId",
|
||||
table: "FactionBankAccounts",
|
||||
column: "FactionId",
|
||||
principalTable: "Factions",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_GroupBankAccounts_Groups_GroupId",
|
||||
table: "GroupBankAccounts",
|
||||
column: "GroupId",
|
||||
principalTable: "Groups",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_UserBankAccounts_Users_UserId",
|
||||
table: "UserBankAccounts",
|
||||
column: "UserId",
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -351,6 +351,8 @@ namespace ReallifeGamemode.Database.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int?>("BankAccountId");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(32);
|
||||
|
||||
@@ -360,6 +362,8 @@ namespace ReallifeGamemode.Database.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BankAccountId");
|
||||
|
||||
b.ToTable("Factions");
|
||||
});
|
||||
|
||||
@@ -375,15 +379,11 @@ namespace ReallifeGamemode.Database.Migrations
|
||||
b.Property<string>("Bic")
|
||||
.HasMaxLength(12);
|
||||
|
||||
b.Property<int>("FactionId");
|
||||
|
||||
b.Property<string>("Iban")
|
||||
.HasMaxLength(32);
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FactionId");
|
||||
|
||||
b.ToTable("FactionBankAccounts");
|
||||
});
|
||||
|
||||
@@ -453,10 +453,14 @@ namespace ReallifeGamemode.Database.Migrations
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int?>("BankAccountId");
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BankAccountId");
|
||||
|
||||
b.ToTable("Groups");
|
||||
});
|
||||
|
||||
@@ -467,12 +471,8 @@ namespace ReallifeGamemode.Database.Migrations
|
||||
|
||||
b.Property<int>("Balance");
|
||||
|
||||
b.Property<int?>("GroupId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("GroupId");
|
||||
|
||||
b.ToTable("GroupBankAccounts");
|
||||
});
|
||||
|
||||
@@ -967,6 +967,8 @@ namespace ReallifeGamemode.Database.Migrations
|
||||
|
||||
b.Property<int?>("BanId");
|
||||
|
||||
b.Property<int?>("BankAccountId");
|
||||
|
||||
b.Property<int?>("BusinessId");
|
||||
|
||||
b.Property<int?>("CharacterId");
|
||||
@@ -1032,6 +1034,8 @@ namespace ReallifeGamemode.Database.Migrations
|
||||
|
||||
b.HasIndex("BanId");
|
||||
|
||||
b.HasIndex("BankAccountId");
|
||||
|
||||
b.HasIndex("BusinessId")
|
||||
.IsUnique();
|
||||
|
||||
@@ -1063,12 +1067,8 @@ namespace ReallifeGamemode.Database.Migrations
|
||||
b.Property<string>("Iban")
|
||||
.HasMaxLength(32);
|
||||
|
||||
b.Property<int>("UserId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("UserBankAccounts");
|
||||
});
|
||||
|
||||
@@ -1273,12 +1273,11 @@ namespace ReallifeGamemode.Database.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.FactionBankAccount", b =>
|
||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Faction", b =>
|
||||
{
|
||||
b.HasOne("ReallifeGamemode.Database.Entities.Faction", "Faction")
|
||||
b.HasOne("ReallifeGamemode.Database.Entities.FactionBankAccount", "BankAccount")
|
||||
.WithMany()
|
||||
.HasForeignKey("FactionId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
.HasForeignKey("BankAccountId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.FactionRank", b =>
|
||||
@@ -1296,11 +1295,11 @@ namespace ReallifeGamemode.Database.Migrations
|
||||
.HasForeignKey("FactionId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.GroupBankAccount", b =>
|
||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Group", b =>
|
||||
{
|
||||
b.HasOne("ReallifeGamemode.Database.Entities.Group", "Group")
|
||||
b.HasOne("ReallifeGamemode.Database.Entities.GroupBankAccount", "BankAccount")
|
||||
.WithMany()
|
||||
.HasForeignKey("GroupId");
|
||||
.HasForeignKey("BankAccountId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.House", b =>
|
||||
@@ -1346,6 +1345,10 @@ namespace ReallifeGamemode.Database.Migrations
|
||||
.WithMany()
|
||||
.HasForeignKey("BanId");
|
||||
|
||||
b.HasOne("ReallifeGamemode.Database.Entities.UserBankAccount", "BankAccount")
|
||||
.WithMany()
|
||||
.HasForeignKey("BankAccountId");
|
||||
|
||||
b.HasOne("ReallifeGamemode.Database.Entities.Character", "Character")
|
||||
.WithMany()
|
||||
.HasForeignKey("CharacterId");
|
||||
@@ -1367,14 +1370,6 @@ namespace ReallifeGamemode.Database.Migrations
|
||||
.HasForeignKey("HouseId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.UserBankAccount", b =>
|
||||
{
|
||||
b.HasOne("ReallifeGamemode.Database.Entities.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.UserItem", b =>
|
||||
{
|
||||
b.HasOne("ReallifeGamemode.Database.Entities.User", "User")
|
||||
|
||||
Reference in New Issue
Block a user