From 1233f882d8c91c9d9a493e545d791a0ab78696d2 Mon Sep 17 00:00:00 2001 From: Hammerbeck Date: Fri, 31 May 2024 16:20:53 +0200 Subject: [PATCH] fix db error --- .../CorrespondenceNotificationDetailsExt.cs | 6 ++++++ .../Models/CorrespondenceNotificationEntity.cs | 2 +- ...240531141939_Initial-Migration.Designer.cs} | 18 +++++++++++++----- ....cs => 20240531141939_Initial-Migration.cs} | 8 ++++---- .../ApplicationDbContextModelSnapshot.cs | 16 ++++++++++++---- 5 files changed, 36 insertions(+), 14 deletions(-) rename src/Altinn.Correspondence.Persistence/Migrations/{20240531140059_Initial-Migration.Designer.cs => 20240531141939_Initial-Migration.Designer.cs} (97%) rename src/Altinn.Correspondence.Persistence/Migrations/{20240531140059_Initial-Migration.cs => 20240531141939_Initial-Migration.cs} (98%) diff --git a/src/Altinn.Correspondence.API/Models/CorrespondenceNotificationDetailsExt.cs b/src/Altinn.Correspondence.API/Models/CorrespondenceNotificationDetailsExt.cs index d2190e7d..9d148884 100644 --- a/src/Altinn.Correspondence.API/Models/CorrespondenceNotificationDetailsExt.cs +++ b/src/Altinn.Correspondence.API/Models/CorrespondenceNotificationDetailsExt.cs @@ -30,5 +30,11 @@ public class CorrespondenceNotificationDetailsExt : CorrespondenceNotificationOv /// [JsonPropertyName("statusHistory")] public List StatusHistory { get; set; } + + /// + /// Created timestamp for the notification + /// + [JsonPropertyName("created")] + public DateTimeOffset Created { get; set; } } } diff --git a/src/Altinn.Correspondence.Core/Models/CorrespondenceNotificationEntity.cs b/src/Altinn.Correspondence.Core/Models/CorrespondenceNotificationEntity.cs index a06f5279..358d8380 100644 --- a/src/Altinn.Correspondence.Core/Models/CorrespondenceNotificationEntity.cs +++ b/src/Altinn.Correspondence.Core/Models/CorrespondenceNotificationEntity.cs @@ -8,7 +8,7 @@ public class CorrespondenceNotificationEntity [Key] public Guid Id { get; set; } - public string NotificationTemplate { get; set; } + public required string NotificationTemplate { get; set; } [StringLength(128, MinimumLength = 0)] public string? CustomTextToken { get; set; } diff --git a/src/Altinn.Correspondence.Persistence/Migrations/20240531140059_Initial-Migration.Designer.cs b/src/Altinn.Correspondence.Persistence/Migrations/20240531141939_Initial-Migration.Designer.cs similarity index 97% rename from src/Altinn.Correspondence.Persistence/Migrations/20240531140059_Initial-Migration.Designer.cs rename to src/Altinn.Correspondence.Persistence/Migrations/20240531141939_Initial-Migration.Designer.cs index 339c381b..bc9ae00c 100644 --- a/src/Altinn.Correspondence.Persistence/Migrations/20240531140059_Initial-Migration.Designer.cs +++ b/src/Altinn.Correspondence.Persistence/Migrations/20240531141939_Initial-Migration.Designer.cs @@ -12,7 +12,7 @@ namespace Altinn.Correspondence.Persistence.Migrations { [DbContext(typeof(ApplicationDbContext))] - [Migration("20240531140059_Initial-Migration")] + [Migration("20240531141939_Initial-Migration")] partial class InitialMigration { /// @@ -93,7 +93,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("integer"); b.Property("StatusChanged") - .HasColumnType("timestamp with time zone"); + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("NOW()"); b.Property("StatusText") .IsRequired() @@ -255,7 +257,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("uuid"); b.Property("Created") - .HasColumnType("timestamp with time zone"); + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("NOW()"); b.Property("CustomTextToken") .HasMaxLength(128) @@ -292,7 +296,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("text"); b.Property("StatusChanged") - .HasColumnType("timestamp with time zone"); + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("NOW()"); b.Property("StatusText") .HasColumnType("text"); @@ -341,7 +347,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("integer"); b.Property("StatusChanged") - .HasColumnType("timestamp with time zone"); + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("NOW()"); b.Property("StatusText") .IsRequired() diff --git a/src/Altinn.Correspondence.Persistence/Migrations/20240531140059_Initial-Migration.cs b/src/Altinn.Correspondence.Persistence/Migrations/20240531141939_Initial-Migration.cs similarity index 98% rename from src/Altinn.Correspondence.Persistence/Migrations/20240531140059_Initial-Migration.cs rename to src/Altinn.Correspondence.Persistence/Migrations/20240531141939_Initial-Migration.cs index 3a066c5d..1734857f 100644 --- a/src/Altinn.Correspondence.Persistence/Migrations/20240531140059_Initial-Migration.cs +++ b/src/Altinn.Correspondence.Persistence/Migrations/20240531141939_Initial-Migration.cs @@ -89,7 +89,7 @@ protected override void Up(MigrationBuilder migrationBuilder) SendersReference = table.Column(type: "text", nullable: true), RequestedSendTime = table.Column(type: "timestamp with time zone", nullable: false), CorrespondenceId = table.Column(type: "uuid", nullable: false), - Created = table.Column(type: "timestamp with time zone", nullable: false) + Created = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "NOW()") }, constraints: table => { @@ -129,7 +129,7 @@ protected override void Up(MigrationBuilder migrationBuilder) Id = table.Column(type: "uuid", nullable: false), Status = table.Column(type: "integer", nullable: false), StatusText = table.Column(type: "text", nullable: false), - StatusChanged = table.Column(type: "timestamp with time zone", nullable: false), + StatusChanged = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "NOW()"), CorrespondenceId = table.Column(type: "uuid", nullable: false) }, constraints: table => @@ -204,7 +204,7 @@ protected override void Up(MigrationBuilder migrationBuilder) Id = table.Column(type: "uuid", nullable: false), Status = table.Column(type: "text", nullable: false), StatusText = table.Column(type: "text", nullable: true), - StatusChanged = table.Column(type: "timestamp with time zone", nullable: false), + StatusChanged = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "NOW()"), NotificationId = table.Column(type: "uuid", nullable: false) }, constraints: table => @@ -225,7 +225,7 @@ protected override void Up(MigrationBuilder migrationBuilder) Id = table.Column(type: "uuid", nullable: false), Status = table.Column(type: "integer", nullable: false), StatusText = table.Column(type: "text", nullable: false), - StatusChanged = table.Column(type: "timestamp with time zone", nullable: false), + StatusChanged = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "NOW()"), AttachmentId = table.Column(type: "uuid", nullable: false), CorrespondenceAttachmentEntityId = table.Column(type: "uuid", nullable: true) }, diff --git a/src/Altinn.Correspondence.Persistence/Migrations/ApplicationDbContextModelSnapshot.cs b/src/Altinn.Correspondence.Persistence/Migrations/ApplicationDbContextModelSnapshot.cs index fdf723ec..e7ee455a 100644 --- a/src/Altinn.Correspondence.Persistence/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/Altinn.Correspondence.Persistence/Migrations/ApplicationDbContextModelSnapshot.cs @@ -90,7 +90,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("integer"); b.Property("StatusChanged") - .HasColumnType("timestamp with time zone"); + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("NOW()"); b.Property("StatusText") .IsRequired() @@ -252,7 +254,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("uuid"); b.Property("Created") - .HasColumnType("timestamp with time zone"); + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("NOW()"); b.Property("CustomTextToken") .HasMaxLength(128) @@ -289,7 +293,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("text"); b.Property("StatusChanged") - .HasColumnType("timestamp with time zone"); + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("NOW()"); b.Property("StatusText") .HasColumnType("text"); @@ -338,7 +344,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("integer"); b.Property("StatusChanged") - .HasColumnType("timestamp with time zone"); + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("NOW()"); b.Property("StatusText") .IsRequired()