diff --git a/API/Migrations/notifications/20250701203510_Notification-Identifiable.Designer.cs b/API/Migrations/notifications/20250701203510_Notification-Identifiable.Designer.cs
new file mode 100644
index 0000000..09dddbd
--- /dev/null
+++ b/API/Migrations/notifications/20250701203510_Notification-Identifiable.Designer.cs
@@ -0,0 +1,88 @@
+//
+using System;
+using System.Collections.Generic;
+using API.Schema.Contexts;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace API.Migrations.notifications
+{
+ [DbContext(typeof(NotificationsContext))]
+ [Migration("20250701203510_Notification-Identifiable")]
+ partial class NotificationIdentifiable
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "9.0.5")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "hstore");
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("API.Schema.Notification", b =>
+ {
+ b.Property("Key")
+ .HasColumnType("text");
+
+ b.Property("Date")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Message")
+ .IsRequired()
+ .HasMaxLength(512)
+ .HasColumnType("character varying(512)");
+
+ b.Property("Title")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Urgency")
+ .HasColumnType("smallint");
+
+ b.HasKey("Key");
+
+ b.ToTable("Notifications");
+ });
+
+ modelBuilder.Entity("API.Schema.NotificationConnectors.NotificationConnector", b =>
+ {
+ b.Property("Name")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property("Body")
+ .IsRequired()
+ .HasMaxLength(4096)
+ .HasColumnType("character varying(4096)");
+
+ b.Property>("Headers")
+ .IsRequired()
+ .HasColumnType("hstore");
+
+ b.Property("HttpMethod")
+ .IsRequired()
+ .HasMaxLength(8)
+ .HasColumnType("character varying(8)");
+
+ b.Property("Url")
+ .IsRequired()
+ .HasMaxLength(2048)
+ .HasColumnType("character varying(2048)");
+
+ b.HasKey("Name");
+
+ b.ToTable("NotificationConnectors");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/API/Migrations/notifications/20250701203510_Notification-Identifiable.cs b/API/Migrations/notifications/20250701203510_Notification-Identifiable.cs
new file mode 100644
index 0000000..3cc52ad
--- /dev/null
+++ b/API/Migrations/notifications/20250701203510_Notification-Identifiable.cs
@@ -0,0 +1,59 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace API.Migrations.notifications
+{
+ ///
+ public partial class NotificationIdentifiable : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropPrimaryKey(
+ name: "PK_Notifications",
+ table: "Notifications");
+
+ migrationBuilder.DropColumn(
+ name: "NotificationId",
+ table: "Notifications");
+
+ migrationBuilder.AddColumn(
+ name: "Key",
+ table: "Notifications",
+ type: "text",
+ nullable: false,
+ defaultValue: "");
+
+ migrationBuilder.AddPrimaryKey(
+ name: "PK_Notifications",
+ table: "Notifications",
+ column: "Key");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropPrimaryKey(
+ name: "PK_Notifications",
+ table: "Notifications");
+
+ migrationBuilder.DropColumn(
+ name: "Key",
+ table: "Notifications");
+
+ migrationBuilder.AddColumn(
+ name: "NotificationId",
+ table: "Notifications",
+ type: "character varying(64)",
+ maxLength: 64,
+ nullable: false,
+ defaultValue: "");
+
+ migrationBuilder.AddPrimaryKey(
+ name: "PK_Notifications",
+ table: "Notifications",
+ column: "NotificationId");
+ }
+ }
+}
diff --git a/API/Migrations/notifications/NotificationsContextModelSnapshot.cs b/API/Migrations/notifications/NotificationsContextModelSnapshot.cs
index a0f7e0a..94a333e 100644
--- a/API/Migrations/notifications/NotificationsContextModelSnapshot.cs
+++ b/API/Migrations/notifications/NotificationsContextModelSnapshot.cs
@@ -18,7 +18,7 @@ namespace API.Migrations.notifications
{
#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("ProductVersion", "9.0.3")
+ .HasAnnotation("ProductVersion", "9.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "hstore");
@@ -26,9 +26,8 @@ namespace API.Migrations.notifications
modelBuilder.Entity("API.Schema.Notification", b =>
{
- b.Property("NotificationId")
- .HasMaxLength(64)
- .HasColumnType("character varying(64)");
+ b.Property("Key")
+ .HasColumnType("text");
b.Property("Date")
.HasColumnType("timestamp with time zone");
@@ -46,7 +45,7 @@ namespace API.Migrations.notifications
b.Property("Urgency")
.HasColumnType("smallint");
- b.HasKey("NotificationId");
+ b.HasKey("Key");
b.ToTable("Notifications");
});
diff --git a/API/Schema/Notification.cs b/API/Schema/Notification.cs
index e58fe16..02231fe 100644
--- a/API/Schema/Notification.cs
+++ b/API/Schema/Notification.cs
@@ -3,13 +3,9 @@ using Microsoft.EntityFrameworkCore;
namespace API.Schema;
-[PrimaryKey("NotificationId")]
-public class Notification
+[PrimaryKey(nameof(Key))]
+public class Notification : Identifiable
{
- [StringLength(64)]
- [Required]
- public string NotificationId { get; init; }
-
[Required]
public NotificationUrgency Urgency { get; init; }
@@ -25,8 +21,8 @@ public class Notification
public DateTime Date { get; init; }
public Notification(string title, string message = "", NotificationUrgency urgency = NotificationUrgency.Normal, DateTime? date = null)
+ : base(TokenGen.CreateToken("Notification"))
{
- this.NotificationId = TokenGen.CreateToken("Notification");
this.Title = title;
this.Message = message;
this.Urgency = urgency;
@@ -36,17 +32,21 @@ public class Notification
///
/// EF ONLY!!!
///
- public Notification(string notificationId, string title, string message, NotificationUrgency urgency, DateTime date)
+ public Notification(string key, string title, string message, NotificationUrgency urgency, DateTime date)
+ : base(key)
{
- this.NotificationId = notificationId;
this.Title = title;
this.Message = message;
this.Urgency = urgency;
this.Date = date;
}
- public override string ToString()
- {
- return $"{NotificationId} {Urgency} {Title}";
- }
+ public override string ToString() => $"{base.ToString()} {Urgency} {Title}";
+}
+
+public enum NotificationUrgency : byte
+{
+ Low = 1,
+ Normal = 3,
+ High = 5
}
\ No newline at end of file
diff --git a/API/Schema/NotificationUrgency.cs b/API/Schema/NotificationUrgency.cs
deleted file mode 100644
index 711f1f0..0000000
--- a/API/Schema/NotificationUrgency.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace API.Schema;
-
-public enum NotificationUrgency : byte
-{
- Low = 1,
- Normal = 3,
- High = 5
-}
\ No newline at end of file