🗃️ Fix notification push subscription unique key
This commit is contained in:
parent
b25b08b5c5
commit
09e4150294
@ -27,7 +27,7 @@ public enum NotificationPushProvider
|
|||||||
Google
|
Google
|
||||||
}
|
}
|
||||||
|
|
||||||
[Index(nameof(DeviceToken), nameof(DeviceId), IsUnique = true)]
|
[Index(nameof(DeviceToken), nameof(DeviceId), nameof(AccountId), IsUnique = true)]
|
||||||
public class NotificationPushSubscription : ModelBase
|
public class NotificationPushSubscription : ModelBase
|
||||||
{
|
{
|
||||||
public Guid Id { get; set; } = Guid.NewGuid();
|
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
|
// Reset these audit fields to renew the lifecycle of this device token
|
||||||
existingSubscription.DeviceId = deviceId;
|
existingSubscription.DeviceId = deviceId;
|
||||||
existingSubscription.DeviceToken = deviceToken;
|
existingSubscription.DeviceToken = deviceToken;
|
||||||
existingSubscription.UpdatedAt = SystemClock.Instance.GetCurrentInstant();
|
|
||||||
db.Update(existingSubscription);
|
db.Update(existingSubscription);
|
||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
return existingSubscription;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user