🗃️ Fix notification push subscription unique key
This commit is contained in:
		@@ -27,7 +27,7 @@ public enum NotificationPushProvider
 | 
			
		||||
    Google
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
[Index(nameof(DeviceToken), nameof(DeviceId), IsUnique = true)]
 | 
			
		||||
[Index(nameof(DeviceToken), nameof(DeviceId), nameof(AccountId), IsUnique = true)]
 | 
			
		||||
public class NotificationPushSubscription : ModelBase
 | 
			
		||||
{
 | 
			
		||||
    public Guid Id { get; set; } = Guid.NewGuid();
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,6 @@ public class NotificationService(
 | 
			
		||||
            // Reset these audit fields to renew the lifecycle of this device token
 | 
			
		||||
            existingSubscription.DeviceId = deviceId;
 | 
			
		||||
            existingSubscription.DeviceToken = deviceToken;
 | 
			
		||||
            existingSubscription.UpdatedAt = SystemClock.Instance.GetCurrentInstant();
 | 
			
		||||
            db.Update(existingSubscription);
 | 
			
		||||
            await db.SaveChangesAsync();
 | 
			
		||||
            return existingSubscription;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3394
									
								
								DysonNetwork.Sphere/Migrations/20250602144445_FixPushNotificationIndex.Designer.cs
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										3394
									
								
								DysonNetwork.Sphere/Migrations/20250602144445_FixPushNotificationIndex.Designer.cs
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -0,0 +1,38 @@
 | 
			
		||||
using Microsoft.EntityFrameworkCore.Migrations;
 | 
			
		||||
 | 
			
		||||
#nullable disable
 | 
			
		||||
 | 
			
		||||
namespace DysonNetwork.Sphere.Migrations
 | 
			
		||||
{
 | 
			
		||||
    /// <inheritdoc />
 | 
			
		||||
    public partial class FixPushNotificationIndex : Migration
 | 
			
		||||
    {
 | 
			
		||||
        /// <inheritdoc />
 | 
			
		||||
        protected override void Up(MigrationBuilder migrationBuilder)
 | 
			
		||||
        {
 | 
			
		||||
            migrationBuilder.DropIndex(
 | 
			
		||||
                name: "ix_notification_push_subscriptions_device_token_device_id",
 | 
			
		||||
                table: "notification_push_subscriptions");
 | 
			
		||||
 | 
			
		||||
            migrationBuilder.CreateIndex(
 | 
			
		||||
                name: "ix_notification_push_subscriptions_device_token_device_id_acco",
 | 
			
		||||
                table: "notification_push_subscriptions",
 | 
			
		||||
                columns: new[] { "device_token", "device_id", "account_id" },
 | 
			
		||||
                unique: true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <inheritdoc />
 | 
			
		||||
        protected override void Down(MigrationBuilder migrationBuilder)
 | 
			
		||||
        {
 | 
			
		||||
            migrationBuilder.DropIndex(
 | 
			
		||||
                name: "ix_notification_push_subscriptions_device_token_device_id_acco",
 | 
			
		||||
                table: "notification_push_subscriptions");
 | 
			
		||||
 | 
			
		||||
            migrationBuilder.CreateIndex(
 | 
			
		||||
                name: "ix_notification_push_subscriptions_device_token_device_id",
 | 
			
		||||
                table: "notification_push_subscriptions",
 | 
			
		||||
                columns: new[] { "device_token", "device_id" },
 | 
			
		||||
                unique: true);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user