diff --git a/src/VirtoCommerce.NotificationsModule.Core/Model/EmailAttachment.cs b/src/VirtoCommerce.NotificationsModule.Core/Model/EmailAttachment.cs index f90977d..ad87dc1 100644 --- a/src/VirtoCommerce.NotificationsModule.Core/Model/EmailAttachment.cs +++ b/src/VirtoCommerce.NotificationsModule.Core/Model/EmailAttachment.cs @@ -7,7 +7,7 @@ public class EmailAttachment : ValueObject, IHasLanguageCode public string FileName { get; set; } public string Url { get; set; } public string MimeType { get; set; } - public string Size { get; set; } + public long Size { get; set; } public string LanguageCode { get; set; } } } diff --git a/src/VirtoCommerce.NotificationsModule.Data.MySql/Migrations/20240401101123_ResizeEmailAttachmentEntityFields.Designer.cs b/src/VirtoCommerce.NotificationsModule.Data.MySql/Migrations/20240401101123_ResizeEmailAttachmentEntityFields.Designer.cs new file mode 100644 index 0000000..571f150 --- /dev/null +++ b/src/VirtoCommerce.NotificationsModule.Data.MySql/Migrations/20240401101123_ResizeEmailAttachmentEntityFields.Designer.cs @@ -0,0 +1,498 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using VirtoCommerce.NotificationsModule.Data.Repositories; + +#nullable disable + +namespace VirtoCommerce.NotificationsModule.Data.MySql.Migrations +{ + [DbContext(typeof(NotificationDbContext))] + [Migration("20240401101123_ResizeEmailAttachmentEntityFields")] + partial class ResizeEmailAttachmentEntityFields + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailAttachmentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("FileName") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("LanguageCode") + .HasMaxLength(10) + .HasColumnType("varchar(10)"); + + b.Property("MimeType") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("NotificationMessageId") + .IsRequired() + .HasColumnType("varchar(128)"); + + b.Property("Size") + .HasColumnType("bigint"); + + b.Property("Url") + .IsRequired() + .HasMaxLength(2083) + .HasColumnType("varchar(2083)"); + + b.HasKey("Id"); + + b.HasIndex("NotificationMessageId"); + + b.ToTable("NotificationEmailAttachment", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationEmailRecipientEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("EmailAddress") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("NotificationId") + .HasColumnType("varchar(128)"); + + b.Property("RecipientType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("NotificationId"); + + b.ToTable("NotificationEmailRecipient", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(true); + + b.Property("Kind") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("TenantId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("TenantType") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Type") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Type", "TenantId", "TenantType"); + + b.ToTable("Notification", (string)null); + + b.HasDiscriminator("Discriminator").HasValue("NotificationEntity"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationLayoutEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("IsDefault") + .HasColumnType("tinyint(1)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Template") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("NotificationLayout", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationMessageEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("LanguageCode") + .HasMaxLength(10) + .HasColumnType("varchar(10)"); + + b.Property("LastSendAttemptDate") + .HasColumnType("datetime(6)"); + + b.Property("LastSendError") + .HasColumnType("longtext"); + + b.Property("MaxSendAttemptCount") + .HasColumnType("int"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("NotificationId") + .HasColumnType("varchar(128)"); + + b.Property("NotificationType") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("SendAttemptCount") + .HasColumnType("int"); + + b.Property("SendDate") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("TenantId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("TenantType") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("NotificationId"); + + b.ToTable("NotificationMessage", (string)null); + + b.HasDiscriminator("Discriminator").HasValue("NotificationMessageEntity"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationTemplateEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("LanguageCode") + .HasMaxLength(10) + .HasColumnType("varchar(10)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("NotificationId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("NotificationId"); + + b.ToTable("NotificationTemplate", (string)null); + + b.HasDiscriminator("Discriminator").HasValue("NotificationTemplateEntity"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationEntity", b => + { + b.HasBaseType("VirtoCommerce.NotificationsModule.Data.Model.NotificationEntity"); + + b.Property("From") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("To") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasDiscriminator().HasValue("EmailNotificationEntity"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.SmsNotificationEntity", b => + { + b.HasBaseType("VirtoCommerce.NotificationsModule.Data.Model.NotificationEntity"); + + b.Property("Number") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasDiscriminator().HasValue("SmsNotificationEntity"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationMessageEntity", b => + { + b.HasBaseType("VirtoCommerce.NotificationsModule.Data.Model.NotificationMessageEntity"); + + b.Property("BCC") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("Body") + .HasColumnType("longtext"); + + b.Property("CC") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("From") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Subject") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("To") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasDiscriminator().HasValue("EmailNotificationMessageEntity"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.SmsNotificationMessageEntity", b => + { + b.HasBaseType("VirtoCommerce.NotificationsModule.Data.Model.NotificationMessageEntity"); + + b.Property("Message") + .HasColumnType("longtext"); + + b.Property("Number") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasDiscriminator().HasValue("SmsNotificationMessageEntity"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationTemplateEntity", b => + { + b.HasBaseType("VirtoCommerce.NotificationsModule.Data.Model.NotificationTemplateEntity"); + + b.Property("Body") + .HasColumnType("longtext"); + + b.Property("NotificationLayoutId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Sample") + .HasColumnType("longtext"); + + b.Property("Subject") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.HasIndex("NotificationLayoutId"); + + b.HasDiscriminator().HasValue("EmailNotificationTemplateEntity"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.SmsNotificationTemplateEntity", b => + { + b.HasBaseType("VirtoCommerce.NotificationsModule.Data.Model.NotificationTemplateEntity"); + + b.Property("Message") + .HasColumnType("longtext"); + + b.HasDiscriminator().HasValue("SmsNotificationTemplateEntity"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailAttachmentEntity", b => + { + b.HasOne("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationMessageEntity", "EmailNotificationMessage") + .WithMany("Attachments") + .HasForeignKey("NotificationMessageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EmailNotificationMessage"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationEmailRecipientEntity", b => + { + b.HasOne("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationEntity", "Notification") + .WithMany("Recipients") + .HasForeignKey("NotificationId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Notification"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationMessageEntity", b => + { + b.HasOne("VirtoCommerce.NotificationsModule.Data.Model.NotificationEntity", "Notification") + .WithMany() + .HasForeignKey("NotificationId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Notification"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationTemplateEntity", b => + { + b.HasOne("VirtoCommerce.NotificationsModule.Data.Model.NotificationEntity", "Notification") + .WithMany("Templates") + .HasForeignKey("NotificationId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Notification"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationTemplateEntity", b => + { + b.HasOne("VirtoCommerce.NotificationsModule.Data.Model.NotificationLayoutEntity", "NotificationLayout") + .WithMany() + .HasForeignKey("NotificationLayoutId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("NotificationLayout"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationEntity", b => + { + b.Navigation("Templates"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationEntity", b => + { + b.Navigation("Recipients"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationMessageEntity", b => + { + b.Navigation("Attachments"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/VirtoCommerce.NotificationsModule.Data.MySql/Migrations/20240401101123_ResizeEmailAttachmentEntityFields.cs b/src/VirtoCommerce.NotificationsModule.Data.MySql/Migrations/20240401101123_ResizeEmailAttachmentEntityFields.cs new file mode 100644 index 0000000..511d97c --- /dev/null +++ b/src/VirtoCommerce.NotificationsModule.Data.MySql/Migrations/20240401101123_ResizeEmailAttachmentEntityFields.cs @@ -0,0 +1,124 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace VirtoCommerce.NotificationsModule.Data.MySql.Migrations +{ + /// + public partial class ResizeEmailAttachmentEntityFields : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.UpdateData( + table: "NotificationEmailAttachment", + keyColumn: "Url", + keyValue: null, + column: "Url", + value: ""); + + migrationBuilder.AlterColumn( + name: "Url", + table: "NotificationEmailAttachment", + type: "varchar(2083)", + maxLength: 2083, + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(2048)", + oldMaxLength: 2048, + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Size", + table: "NotificationEmailAttachment", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(string), + oldType: "varchar(128)", + oldMaxLength: 128, + oldNullable: true) + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "MimeType", + table: "NotificationEmailAttachment", + type: "varchar(128)", + maxLength: 128, + nullable: true, + oldClrType: typeof(string), + oldType: "varchar(50)", + oldMaxLength: 50, + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "FileName", + table: "NotificationEmailAttachment", + type: "varchar(1024)", + maxLength: 1024, + nullable: true, + oldClrType: typeof(string), + oldType: "varchar(512)", + oldMaxLength: 512, + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Url", + table: "NotificationEmailAttachment", + type: "varchar(2048)", + maxLength: 2048, + nullable: true, + oldClrType: typeof(string), + oldType: "varchar(2083)", + oldMaxLength: 2083) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Size", + table: "NotificationEmailAttachment", + type: "varchar(128)", + maxLength: 128, + nullable: true, + oldClrType: typeof(long), + oldType: "bigint") + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "MimeType", + table: "NotificationEmailAttachment", + type: "varchar(50)", + maxLength: 50, + nullable: true, + oldClrType: typeof(string), + oldType: "varchar(128)", + oldMaxLength: 128, + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "FileName", + table: "NotificationEmailAttachment", + type: "varchar(512)", + maxLength: 512, + nullable: true, + oldClrType: typeof(string), + oldType: "varchar(1024)", + oldMaxLength: 1024, + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + } + } +} diff --git a/src/VirtoCommerce.NotificationsModule.Data.MySql/Migrations/NotificationDbContextModelSnapshot.cs b/src/VirtoCommerce.NotificationsModule.Data.MySql/Migrations/NotificationDbContextModelSnapshot.cs index 5c98575..3f8f1dc 100644 --- a/src/VirtoCommerce.NotificationsModule.Data.MySql/Migrations/NotificationDbContextModelSnapshot.cs +++ b/src/VirtoCommerce.NotificationsModule.Data.MySql/Migrations/NotificationDbContextModelSnapshot.cs @@ -34,16 +34,16 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("datetime(6)"); b.Property("FileName") - .HasMaxLength(512) - .HasColumnType("varchar(512)"); + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); b.Property("LanguageCode") .HasMaxLength(10) .HasColumnType("varchar(10)"); b.Property("MimeType") - .HasMaxLength(50) - .HasColumnType("varchar(50)"); + .HasMaxLength(128) + .HasColumnType("varchar(128)"); b.Property("ModifiedBy") .HasMaxLength(64) @@ -56,13 +56,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired() .HasColumnType("varchar(128)"); - b.Property("Size") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); + b.Property("Size") + .HasColumnType("bigint"); b.Property("Url") - .HasMaxLength(2048) - .HasColumnType("varchar(2048)"); + .IsRequired() + .HasMaxLength(2083) + .HasColumnType("varchar(2083)"); b.HasKey("Id"); diff --git a/src/VirtoCommerce.NotificationsModule.Data.PostgreSql/Migrations/20240401101011_ResizeEmailAttachmentEntityFields.Designer.cs b/src/VirtoCommerce.NotificationsModule.Data.PostgreSql/Migrations/20240401101011_ResizeEmailAttachmentEntityFields.Designer.cs new file mode 100644 index 0000000..7051ddf --- /dev/null +++ b/src/VirtoCommerce.NotificationsModule.Data.PostgreSql/Migrations/20240401101011_ResizeEmailAttachmentEntityFields.Designer.cs @@ -0,0 +1,501 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using VirtoCommerce.NotificationsModule.Data.Repositories; + +#nullable disable + +namespace VirtoCommerce.NotificationsModule.Data.PostgreSql.VirtoCommerce.NotificationsModule.Data.PostgreSql +{ + [DbContext(typeof(NotificationDbContext))] + [Migration("20240401101011_ResizeEmailAttachmentEntityFields")] + partial class ResizeEmailAttachmentEntityFields + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailAttachmentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("FileName") + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); + + b.Property("LanguageCode") + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("MimeType") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("NotificationMessageId") + .IsRequired() + .HasColumnType("character varying(128)"); + + b.Property("Size") + .HasColumnType("bigint"); + + b.Property("Url") + .IsRequired() + .HasMaxLength(2083) + .HasColumnType("character varying(2083)"); + + b.HasKey("Id"); + + b.HasIndex("NotificationMessageId"); + + b.ToTable("NotificationEmailAttachment", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationEmailRecipientEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("EmailAddress") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("NotificationId") + .HasColumnType("character varying(128)"); + + b.Property("RecipientType") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("NotificationId"); + + b.ToTable("NotificationEmailRecipient", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("Kind") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("TenantId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("TenantType") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Type") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("Type", "TenantId", "TenantType"); + + b.ToTable("Notification", (string)null); + + b.HasDiscriminator("Discriminator").HasValue("NotificationEntity"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationLayoutEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("IsDefault") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Template") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("NotificationLayout", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationMessageEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("LanguageCode") + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("LastSendAttemptDate") + .HasColumnType("timestamp with time zone"); + + b.Property("LastSendError") + .HasColumnType("text"); + + b.Property("MaxSendAttemptCount") + .HasColumnType("integer"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("NotificationId") + .HasColumnType("character varying(128)"); + + b.Property("NotificationType") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("SendAttemptCount") + .HasColumnType("integer"); + + b.Property("SendDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("TenantId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("TenantType") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("NotificationId"); + + b.ToTable("NotificationMessage", (string)null); + + b.HasDiscriminator("Discriminator").HasValue("NotificationMessageEntity"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationTemplateEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("LanguageCode") + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("NotificationId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("NotificationId"); + + b.ToTable("NotificationTemplate", (string)null); + + b.HasDiscriminator("Discriminator").HasValue("NotificationTemplateEntity"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationEntity", b => + { + b.HasBaseType("VirtoCommerce.NotificationsModule.Data.Model.NotificationEntity"); + + b.Property("From") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("To") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasDiscriminator().HasValue("EmailNotificationEntity"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.SmsNotificationEntity", b => + { + b.HasBaseType("VirtoCommerce.NotificationsModule.Data.Model.NotificationEntity"); + + b.Property("Number") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasDiscriminator().HasValue("SmsNotificationEntity"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationMessageEntity", b => + { + b.HasBaseType("VirtoCommerce.NotificationsModule.Data.Model.NotificationMessageEntity"); + + b.Property("BCC") + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); + + b.Property("Body") + .HasColumnType("text"); + + b.Property("CC") + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); + + b.Property("From") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Subject") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("To") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasDiscriminator().HasValue("EmailNotificationMessageEntity"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.SmsNotificationMessageEntity", b => + { + b.HasBaseType("VirtoCommerce.NotificationsModule.Data.Model.NotificationMessageEntity"); + + b.Property("Message") + .HasColumnType("text"); + + b.Property("Number") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasDiscriminator().HasValue("SmsNotificationMessageEntity"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationTemplateEntity", b => + { + b.HasBaseType("VirtoCommerce.NotificationsModule.Data.Model.NotificationTemplateEntity"); + + b.Property("Body") + .HasColumnType("text"); + + b.Property("NotificationLayoutId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Sample") + .HasColumnType("text"); + + b.Property("Subject") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.HasIndex("NotificationLayoutId"); + + b.HasDiscriminator().HasValue("EmailNotificationTemplateEntity"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.SmsNotificationTemplateEntity", b => + { + b.HasBaseType("VirtoCommerce.NotificationsModule.Data.Model.NotificationTemplateEntity"); + + b.Property("Message") + .HasColumnType("text"); + + b.HasDiscriminator().HasValue("SmsNotificationTemplateEntity"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailAttachmentEntity", b => + { + b.HasOne("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationMessageEntity", "EmailNotificationMessage") + .WithMany("Attachments") + .HasForeignKey("NotificationMessageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EmailNotificationMessage"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationEmailRecipientEntity", b => + { + b.HasOne("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationEntity", "Notification") + .WithMany("Recipients") + .HasForeignKey("NotificationId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Notification"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationMessageEntity", b => + { + b.HasOne("VirtoCommerce.NotificationsModule.Data.Model.NotificationEntity", "Notification") + .WithMany() + .HasForeignKey("NotificationId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Notification"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationTemplateEntity", b => + { + b.HasOne("VirtoCommerce.NotificationsModule.Data.Model.NotificationEntity", "Notification") + .WithMany("Templates") + .HasForeignKey("NotificationId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Notification"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationTemplateEntity", b => + { + b.HasOne("VirtoCommerce.NotificationsModule.Data.Model.NotificationLayoutEntity", "NotificationLayout") + .WithMany() + .HasForeignKey("NotificationLayoutId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("NotificationLayout"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationEntity", b => + { + b.Navigation("Templates"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationEntity", b => + { + b.Navigation("Recipients"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationMessageEntity", b => + { + b.Navigation("Attachments"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/VirtoCommerce.NotificationsModule.Data.PostgreSql/Migrations/20240401101011_ResizeEmailAttachmentEntityFields.cs b/src/VirtoCommerce.NotificationsModule.Data.PostgreSql/Migrations/20240401101011_ResizeEmailAttachmentEntityFields.cs new file mode 100644 index 0000000..180f8dc --- /dev/null +++ b/src/VirtoCommerce.NotificationsModule.Data.PostgreSql/Migrations/20240401101011_ResizeEmailAttachmentEntityFields.cs @@ -0,0 +1,104 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace VirtoCommerce.NotificationsModule.Data.PostgreSql.VirtoCommerce.NotificationsModule.Data.PostgreSql +{ + /// + public partial class ResizeEmailAttachmentEntityFields : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Url", + table: "NotificationEmailAttachment", + type: "character varying(2083)", + maxLength: 2083, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "character varying(2048)", + oldMaxLength: 2048, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Size", + table: "NotificationEmailAttachment", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MimeType", + table: "NotificationEmailAttachment", + type: "character varying(128)", + maxLength: 128, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(50)", + oldMaxLength: 50, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FileName", + table: "NotificationEmailAttachment", + type: "character varying(1024)", + maxLength: 1024, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(512)", + oldMaxLength: 512, + oldNullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Url", + table: "NotificationEmailAttachment", + type: "character varying(2048)", + maxLength: 2048, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(2083)", + oldMaxLength: 2083); + + migrationBuilder.AlterColumn( + name: "Size", + table: "NotificationEmailAttachment", + type: "character varying(128)", + maxLength: 128, + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "MimeType", + table: "NotificationEmailAttachment", + type: "character varying(50)", + maxLength: 50, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FileName", + table: "NotificationEmailAttachment", + type: "character varying(512)", + maxLength: 512, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(1024)", + oldMaxLength: 1024, + oldNullable: true); + } + } +} diff --git a/src/VirtoCommerce.NotificationsModule.Data.PostgreSql/Migrations/NotificationDbContextModelSnapshot.cs b/src/VirtoCommerce.NotificationsModule.Data.PostgreSql/Migrations/NotificationDbContextModelSnapshot.cs index a76eef2..853d36a 100644 --- a/src/VirtoCommerce.NotificationsModule.Data.PostgreSql/Migrations/NotificationDbContextModelSnapshot.cs +++ b/src/VirtoCommerce.NotificationsModule.Data.PostgreSql/Migrations/NotificationDbContextModelSnapshot.cs @@ -37,16 +37,16 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("timestamp with time zone"); b.Property("FileName") - .HasMaxLength(512) - .HasColumnType("character varying(512)"); + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); b.Property("LanguageCode") .HasMaxLength(10) .HasColumnType("character varying(10)"); b.Property("MimeType") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); + .HasMaxLength(128) + .HasColumnType("character varying(128)"); b.Property("ModifiedBy") .HasMaxLength(64) @@ -59,13 +59,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired() .HasColumnType("character varying(128)"); - b.Property("Size") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); + b.Property("Size") + .HasColumnType("bigint"); b.Property("Url") - .HasMaxLength(2048) - .HasColumnType("character varying(2048)"); + .IsRequired() + .HasMaxLength(2083) + .HasColumnType("character varying(2083)"); b.HasKey("Id"); diff --git a/src/VirtoCommerce.NotificationsModule.Data.SqlServer/Migrations/20240401100631_ResizeEmailAttachmentEntityFields.Designer.cs b/src/VirtoCommerce.NotificationsModule.Data.SqlServer/Migrations/20240401100631_ResizeEmailAttachmentEntityFields.Designer.cs new file mode 100644 index 0000000..80721b1 --- /dev/null +++ b/src/VirtoCommerce.NotificationsModule.Data.SqlServer/Migrations/20240401100631_ResizeEmailAttachmentEntityFields.Designer.cs @@ -0,0 +1,501 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using VirtoCommerce.NotificationsModule.Data.Repositories; + +#nullable disable + +namespace VirtoCommerce.NotificationsModule.Data.SqlServer.VirtoCommerce.NotificationsModule.Data.SqlServer +{ + [DbContext(typeof(NotificationDbContext))] + [Migration("20240401100631_ResizeEmailAttachmentEntityFields")] + partial class ResizeEmailAttachmentEntityFields + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailAttachmentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("FileName") + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.Property("LanguageCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("MimeType") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("NotificationMessageId") + .IsRequired() + .HasColumnType("nvarchar(128)"); + + b.Property("Size") + .HasColumnType("bigint"); + + b.Property("Url") + .IsRequired() + .HasMaxLength(2083) + .HasColumnType("nvarchar(2083)"); + + b.HasKey("Id"); + + b.HasIndex("NotificationMessageId"); + + b.ToTable("NotificationEmailAttachment", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationEmailRecipientEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("EmailAddress") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("NotificationId") + .HasColumnType("nvarchar(128)"); + + b.Property("RecipientType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("NotificationId"); + + b.ToTable("NotificationEmailRecipient", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Kind") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("TenantId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("TenantType") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Type") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Type", "TenantId", "TenantType"); + + b.ToTable("Notification", (string)null); + + b.HasDiscriminator("Discriminator").HasValue("NotificationEntity"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationLayoutEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Template") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("NotificationLayout", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationMessageEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("LanguageCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("LastSendAttemptDate") + .HasColumnType("datetime2"); + + b.Property("LastSendError") + .HasColumnType("nvarchar(max)"); + + b.Property("MaxSendAttemptCount") + .HasColumnType("int"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("NotificationId") + .HasColumnType("nvarchar(128)"); + + b.Property("NotificationType") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("SendAttemptCount") + .HasColumnType("int"); + + b.Property("SendDate") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("TenantId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("TenantType") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("NotificationId"); + + b.ToTable("NotificationMessage", (string)null); + + b.HasDiscriminator("Discriminator").HasValue("NotificationMessageEntity"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationTemplateEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("LanguageCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("NotificationId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("NotificationId"); + + b.ToTable("NotificationTemplate", (string)null); + + b.HasDiscriminator("Discriminator").HasValue("NotificationTemplateEntity"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationEntity", b => + { + b.HasBaseType("VirtoCommerce.NotificationsModule.Data.Model.NotificationEntity"); + + b.Property("From") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("To") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.HasDiscriminator().HasValue("EmailNotificationEntity"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.SmsNotificationEntity", b => + { + b.HasBaseType("VirtoCommerce.NotificationsModule.Data.Model.NotificationEntity"); + + b.Property("Number") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.HasDiscriminator().HasValue("SmsNotificationEntity"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationMessageEntity", b => + { + b.HasBaseType("VirtoCommerce.NotificationsModule.Data.Model.NotificationMessageEntity"); + + b.Property("BCC") + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.Property("Body") + .HasColumnType("nvarchar(max)"); + + b.Property("CC") + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.Property("From") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Subject") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)"); + + b.Property("To") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.HasDiscriminator().HasValue("EmailNotificationMessageEntity"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.SmsNotificationMessageEntity", b => + { + b.HasBaseType("VirtoCommerce.NotificationsModule.Data.Model.NotificationMessageEntity"); + + b.Property("Message") + .HasColumnType("nvarchar(max)"); + + b.Property("Number") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.HasDiscriminator().HasValue("SmsNotificationMessageEntity"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationTemplateEntity", b => + { + b.HasBaseType("VirtoCommerce.NotificationsModule.Data.Model.NotificationTemplateEntity"); + + b.Property("Body") + .HasColumnType("nvarchar(max)"); + + b.Property("NotificationLayoutId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Sample") + .HasColumnType("nvarchar(max)"); + + b.Property("Subject") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)"); + + b.HasIndex("NotificationLayoutId"); + + b.HasDiscriminator().HasValue("EmailNotificationTemplateEntity"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.SmsNotificationTemplateEntity", b => + { + b.HasBaseType("VirtoCommerce.NotificationsModule.Data.Model.NotificationTemplateEntity"); + + b.Property("Message") + .HasColumnType("nvarchar(max)"); + + b.HasDiscriminator().HasValue("SmsNotificationTemplateEntity"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailAttachmentEntity", b => + { + b.HasOne("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationMessageEntity", "EmailNotificationMessage") + .WithMany("Attachments") + .HasForeignKey("NotificationMessageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EmailNotificationMessage"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationEmailRecipientEntity", b => + { + b.HasOne("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationEntity", "Notification") + .WithMany("Recipients") + .HasForeignKey("NotificationId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Notification"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationMessageEntity", b => + { + b.HasOne("VirtoCommerce.NotificationsModule.Data.Model.NotificationEntity", "Notification") + .WithMany() + .HasForeignKey("NotificationId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Notification"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationTemplateEntity", b => + { + b.HasOne("VirtoCommerce.NotificationsModule.Data.Model.NotificationEntity", "Notification") + .WithMany("Templates") + .HasForeignKey("NotificationId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Notification"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationTemplateEntity", b => + { + b.HasOne("VirtoCommerce.NotificationsModule.Data.Model.NotificationLayoutEntity", "NotificationLayout") + .WithMany() + .HasForeignKey("NotificationLayoutId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("NotificationLayout"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.NotificationEntity", b => + { + b.Navigation("Templates"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationEntity", b => + { + b.Navigation("Recipients"); + }); + + modelBuilder.Entity("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationMessageEntity", b => + { + b.Navigation("Attachments"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/VirtoCommerce.NotificationsModule.Data.SqlServer/Migrations/20240401100631_ResizeEmailAttachmentEntityFields.cs b/src/VirtoCommerce.NotificationsModule.Data.SqlServer/Migrations/20240401100631_ResizeEmailAttachmentEntityFields.cs new file mode 100644 index 0000000..606b6d0 --- /dev/null +++ b/src/VirtoCommerce.NotificationsModule.Data.SqlServer/Migrations/20240401100631_ResizeEmailAttachmentEntityFields.cs @@ -0,0 +1,104 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace VirtoCommerce.NotificationsModule.Data.SqlServer.VirtoCommerce.NotificationsModule.Data.SqlServer +{ + /// + public partial class ResizeEmailAttachmentEntityFields : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Url", + table: "NotificationEmailAttachment", + type: "nvarchar(2083)", + maxLength: 2083, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(2048)", + oldMaxLength: 2048, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Size", + table: "NotificationEmailAttachment", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(string), + oldType: "nvarchar(128)", + oldMaxLength: 128, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MimeType", + table: "NotificationEmailAttachment", + type: "nvarchar(128)", + maxLength: 128, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(50)", + oldMaxLength: 50, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FileName", + table: "NotificationEmailAttachment", + type: "nvarchar(1024)", + maxLength: 1024, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(512)", + oldMaxLength: 512, + oldNullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Url", + table: "NotificationEmailAttachment", + type: "nvarchar(2048)", + maxLength: 2048, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(2083)", + oldMaxLength: 2083); + + migrationBuilder.AlterColumn( + name: "Size", + table: "NotificationEmailAttachment", + type: "nvarchar(128)", + maxLength: 128, + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "MimeType", + table: "NotificationEmailAttachment", + type: "nvarchar(50)", + maxLength: 50, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(128)", + oldMaxLength: 128, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FileName", + table: "NotificationEmailAttachment", + type: "nvarchar(512)", + maxLength: 512, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(1024)", + oldMaxLength: 1024, + oldNullable: true); + } + } +} diff --git a/src/VirtoCommerce.NotificationsModule.Data.SqlServer/Migrations/NotificationDbContextModelSnapshot.cs b/src/VirtoCommerce.NotificationsModule.Data.SqlServer/Migrations/NotificationDbContextModelSnapshot.cs index bd2661e..cc449d8 100644 --- a/src/VirtoCommerce.NotificationsModule.Data.SqlServer/Migrations/NotificationDbContextModelSnapshot.cs +++ b/src/VirtoCommerce.NotificationsModule.Data.SqlServer/Migrations/NotificationDbContextModelSnapshot.cs @@ -37,16 +37,16 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("datetime2"); b.Property("FileName") - .HasMaxLength(512) - .HasColumnType("nvarchar(512)"); + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); b.Property("LanguageCode") .HasMaxLength(10) .HasColumnType("nvarchar(10)"); b.Property("MimeType") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); b.Property("ModifiedBy") .HasMaxLength(64) @@ -56,15 +56,16 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("datetime2"); b.Property("NotificationMessageId") + .IsRequired() .HasColumnType("nvarchar(128)"); - b.Property("Size") - .HasMaxLength(128) - .HasColumnType("nvarchar(128)"); + b.Property("Size") + .HasColumnType("bigint"); b.Property("Url") - .HasMaxLength(2048) - .HasColumnType("nvarchar(2048)"); + .IsRequired() + .HasMaxLength(2083) + .HasColumnType("nvarchar(2083)"); b.HasKey("Id"); @@ -431,7 +432,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasOne("VirtoCommerce.NotificationsModule.Data.Model.EmailNotificationMessageEntity", "EmailNotificationMessage") .WithMany("Attachments") .HasForeignKey("NotificationMessageId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.Navigation("EmailNotificationMessage"); }); diff --git a/src/VirtoCommerce.NotificationsModule.Data/Model/EmailAttachmentEntity.cs b/src/VirtoCommerce.NotificationsModule.Data/Model/EmailAttachmentEntity.cs index fe87ca4..6b7e2e6 100644 --- a/src/VirtoCommerce.NotificationsModule.Data/Model/EmailAttachmentEntity.cs +++ b/src/VirtoCommerce.NotificationsModule.Data/Model/EmailAttachmentEntity.cs @@ -13,26 +13,25 @@ public class EmailAttachmentEntity : AuditableEntity /// /// Name of Attachment /// - [StringLength(512)] + [StringLength(1024)] public string FileName { get; set; } /// /// Url of Attachment /// - [StringLength(2048)] + [Required, StringLength(2083)] public string Url { get; set; } /// /// MimeType of Attachment /// - [StringLength(50)] + [StringLength(128)] public string MimeType { get; set; } /// /// Size of Attachment /// - [StringLength(128)] - public string Size { get; set; } + public long Size { get; set; } /// /// Language of Attachment @@ -52,7 +51,8 @@ public class EmailAttachmentEntity : AuditableEntity public virtual EmailAttachment ToModel(EmailAttachment emailAttachment) { - if (emailAttachment == null) throw new ArgumentNullException(nameof(emailAttachment)); + ArgumentNullException.ThrowIfNull(emailAttachment); + emailAttachment.FileName = FileName; emailAttachment.Url = Url; emailAttachment.MimeType = MimeType; @@ -64,7 +64,8 @@ public virtual EmailAttachment ToModel(EmailAttachment emailAttachment) public virtual EmailAttachmentEntity FromModel(EmailAttachment emailAttachment) { - if (emailAttachment == null) throw new ArgumentNullException(nameof(emailAttachment)); + ArgumentNullException.ThrowIfNull(emailAttachment); + FileName = emailAttachment.FileName; Url = emailAttachment.Url; MimeType = emailAttachment.MimeType;