mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-22 00:14:25 +01:00
Cascade delete notifications for user
This commit is contained in:
@@ -26,7 +26,7 @@ namespace BTCPayServer.Data
|
|||||||
builder.Entity<NotificationData>()
|
builder.Entity<NotificationData>()
|
||||||
.HasOne(o => o.ApplicationUser)
|
.HasOne(o => o.ApplicationUser)
|
||||||
.WithMany(n => n.Notifications)
|
.WithMany(n => n.Notifications)
|
||||||
.HasForeignKey(k => k.ApplicationUserId);
|
.HasForeignKey(k => k.ApplicationUserId).OnDelete(DeleteBehavior.Cascade);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
using BTCPayServer.Data;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace BTCPayServer.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(ApplicationDbContext))]
|
||||||
|
[Migration("20200613234439_CascadeDeleteNotificationsForUser")]
|
||||||
|
public partial class CascadeDeleteNotificationsForUser : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Notifications_AspNetUsers_ApplicationUserId",
|
||||||
|
table: "Notifications");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Notifications_AspNetUsers_ApplicationUserId",
|
||||||
|
table: "Notifications",
|
||||||
|
column: "ApplicationUserId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Notifications_AspNetUsers_ApplicationUserId",
|
||||||
|
table: "Notifications");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Notifications_AspNetUsers_ApplicationUserId",
|
||||||
|
table: "Notifications",
|
||||||
|
column: "ApplicationUserId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -794,7 +794,8 @@ namespace BTCPayServer.Migrations
|
|||||||
{
|
{
|
||||||
b.HasOne("BTCPayServer.Data.ApplicationUser", "ApplicationUser")
|
b.HasOne("BTCPayServer.Data.ApplicationUser", "ApplicationUser")
|
||||||
.WithMany("Notifications")
|
.WithMany("Notifications")
|
||||||
.HasForeignKey("ApplicationUserId");
|
.HasForeignKey("ApplicationUserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("BTCPayServer.Data.PairedSINData", b =>
|
modelBuilder.Entity("BTCPayServer.Data.PairedSINData", b =>
|
||||||
|
|||||||
Reference in New Issue
Block a user