From 4f36e985881cc00c3e340b4b4b8958d22f8bd767 Mon Sep 17 00:00:00 2001 From: artem-dudarev Date: Tue, 11 Jun 2024 14:38:46 +0200 Subject: [PATCH] fix: Deleted setting values remained in the PlatformSettingValue table --- ...91800_MakeSettingIdNotNullable.Designer.cs | 473 +++++++++++++++++ ...20240611091800_MakeSettingIdNotNullable.cs | 48 ++ .../Data/PlatformDbContextModelSnapshot.cs | 9 +- ...91908_MakeSettingIdNotNullable.Designer.cs | 473 +++++++++++++++++ ...20240611091908_MakeSettingIdNotNullable.cs | 38 ++ .../Data/PlatformDbContextModelSnapshot.cs | 8 +- ...91951_MakeSettingIdNotNullable.Designer.cs | 477 ++++++++++++++++++ ...20240611091951_MakeSettingIdNotNullable.cs | 38 ++ .../Data/PlatformDbContextModelSnapshot.cs | 8 +- .../Repositories/PlatformDbContext.cs | 3 +- 10 files changed, 1566 insertions(+), 9 deletions(-) create mode 100644 src/VirtoCommerce.Platform.Data.MySql/Migrations/Data/20240611091800_MakeSettingIdNotNullable.Designer.cs create mode 100644 src/VirtoCommerce.Platform.Data.MySql/Migrations/Data/20240611091800_MakeSettingIdNotNullable.cs create mode 100644 src/VirtoCommerce.Platform.Data.PostgreSql/Migrations/Data/20240611091908_MakeSettingIdNotNullable.Designer.cs create mode 100644 src/VirtoCommerce.Platform.Data.PostgreSql/Migrations/Data/20240611091908_MakeSettingIdNotNullable.cs create mode 100644 src/VirtoCommerce.Platform.Data.SqlServer/Migrations/Data/20240611091951_MakeSettingIdNotNullable.Designer.cs create mode 100644 src/VirtoCommerce.Platform.Data.SqlServer/Migrations/Data/20240611091951_MakeSettingIdNotNullable.cs diff --git a/src/VirtoCommerce.Platform.Data.MySql/Migrations/Data/20240611091800_MakeSettingIdNotNullable.Designer.cs b/src/VirtoCommerce.Platform.Data.MySql/Migrations/Data/20240611091800_MakeSettingIdNotNullable.Designer.cs new file mode 100644 index 00000000000..81b374df95c --- /dev/null +++ b/src/VirtoCommerce.Platform.Data.MySql/Migrations/Data/20240611091800_MakeSettingIdNotNullable.Designer.cs @@ -0,0 +1,473 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using VirtoCommerce.Platform.Data.Repositories; + +#nullable disable + +namespace VirtoCommerce.Platform.Data.MySql.Migrations.Data +{ + [DbContext(typeof(PlatformDbContext))] + [Migration("20240611091800_MakeSettingIdNotNullable")] + partial class MakeSettingIdNotNullable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Localizations.LocalizedItemEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Alias") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("LanguageCode") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Value") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.HasKey("Id"); + + b.HasIndex("Name", "Alias") + .HasDatabaseName("IX_PlatformLocalizedItem_Name_Alias"); + + b.ToTable("PlatformLocalizedItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyDictionaryItemEntity", 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("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("PropertyId") + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("PropertyId", "Name") + .IsUnique() + .HasDatabaseName("IX_PlatformDynamicPropertyDictionaryItem_PropertyId_Name"); + + b.ToTable("PlatformDynamicPropertyDictionaryItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyDictionaryItemNameEntity", 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("DictionaryItemId") + .HasColumnType("varchar(128)"); + + b.Property("Locale") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.HasKey("Id"); + + b.HasIndex("DictionaryItemId", "Locale", "Name") + .IsUnique() + .HasDatabaseName("IX_PlatformDynamicPropertyDictionaryItemName_DictionaryItemId_Locale_Name"); + + b.ToTable("PlatformDynamicPropertyDictionaryItemName", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyEntity", 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("Description") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("DisplayOrder") + .HasColumnType("int"); + + b.Property("IsArray") + .HasColumnType("tinyint(1)"); + + b.Property("IsDictionary") + .HasColumnType("tinyint(1)"); + + b.Property("IsMultilingual") + .HasColumnType("tinyint(1)"); + + b.Property("IsRequired") + .HasColumnType("tinyint(1)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ObjectType") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ValueType") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("ObjectType", "Name") + .IsUnique() + .HasDatabaseName("IX_PlatformDynamicProperty_ObjectType_Name"); + + b.ToTable("PlatformDynamicProperty", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyNameEntity", 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("Locale") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("PropertyId") + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("PropertyId", "Locale", "Name") + .IsUnique() + .HasDatabaseName("IX_PlatformDynamicPropertyName_PropertyId_Locale_Name"); + + b.ToTable("PlatformDynamicPropertyName", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.OperationLogEntity", 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("Detail") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("ObjectId") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ObjectType") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("OperationType") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("ObjectType", "ObjectId") + .HasDatabaseName("IX_OperationLog_ObjectType_ObjectId"); + + b.ToTable("PlatformOperationLog", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.RawLicenseEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Data") + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("RawLicense", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.SettingEntity", 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("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ObjectId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ObjectType") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("ObjectType", "ObjectId") + .HasDatabaseName("IX_ObjectType_ObjectId"); + + b.ToTable("PlatformSetting", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.SettingValueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("BooleanValue") + .HasColumnType("tinyint(1)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("DateTimeValue") + .HasColumnType("datetime(6)"); + + b.Property("DecimalValue") + .HasColumnType("decimal(18,5)"); + + b.Property("IntegerValue") + .HasColumnType("int"); + + b.Property("LongTextValue") + .HasColumnType("longtext"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("SettingId") + .IsRequired() + .HasColumnType("varchar(128)"); + + b.Property("ShortTextValue") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("ValueType") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("SettingId"); + + b.ToTable("PlatformSettingValue", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyDictionaryItemEntity", b => + { + b.HasOne("VirtoCommerce.Platform.Data.Model.DynamicPropertyEntity", "Property") + .WithMany("DictionaryItems") + .HasForeignKey("PropertyId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Property"); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyDictionaryItemNameEntity", b => + { + b.HasOne("VirtoCommerce.Platform.Data.Model.DynamicPropertyDictionaryItemEntity", "DictionaryItem") + .WithMany("DisplayNames") + .HasForeignKey("DictionaryItemId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("DictionaryItem"); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyNameEntity", b => + { + b.HasOne("VirtoCommerce.Platform.Data.Model.DynamicPropertyEntity", "Property") + .WithMany("DisplayNames") + .HasForeignKey("PropertyId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Property"); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.SettingValueEntity", b => + { + b.HasOne("VirtoCommerce.Platform.Data.Model.SettingEntity", "Setting") + .WithMany("SettingValues") + .HasForeignKey("SettingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Setting"); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyDictionaryItemEntity", b => + { + b.Navigation("DisplayNames"); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyEntity", b => + { + b.Navigation("DictionaryItems"); + + b.Navigation("DisplayNames"); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.SettingEntity", b => + { + b.Navigation("SettingValues"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/VirtoCommerce.Platform.Data.MySql/Migrations/Data/20240611091800_MakeSettingIdNotNullable.cs b/src/VirtoCommerce.Platform.Data.MySql/Migrations/Data/20240611091800_MakeSettingIdNotNullable.cs new file mode 100644 index 00000000000..d92c055f7e2 --- /dev/null +++ b/src/VirtoCommerce.Platform.Data.MySql/Migrations/Data/20240611091800_MakeSettingIdNotNullable.cs @@ -0,0 +1,48 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace VirtoCommerce.Platform.Data.MySql.Migrations.Data +{ + /// + public partial class MakeSettingIdNotNullable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DELETE PlatformSettingValue WHERE SettingId IS NULL;"); + + migrationBuilder.UpdateData( + table: "PlatformSettingValue", + keyColumn: "SettingId", + keyValue: null, + column: "SettingId", + value: ""); + + migrationBuilder.AlterColumn( + name: "SettingId", + table: "PlatformSettingValue", + type: "varchar(128)", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(128)", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "SettingId", + table: "PlatformSettingValue", + type: "varchar(128)", + nullable: true, + oldClrType: typeof(string), + oldType: "varchar(128)") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + } + } +} diff --git a/src/VirtoCommerce.Platform.Data.MySql/Migrations/Data/PlatformDbContextModelSnapshot.cs b/src/VirtoCommerce.Platform.Data.MySql/Migrations/Data/PlatformDbContextModelSnapshot.cs index 5fadf09f8b4..5d1918af118 100644 --- a/src/VirtoCommerce.Platform.Data.MySql/Migrations/Data/PlatformDbContextModelSnapshot.cs +++ b/src/VirtoCommerce.Platform.Data.MySql/Migrations/Data/PlatformDbContextModelSnapshot.cs @@ -2,6 +2,7 @@ using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using VirtoCommerce.Platform.Data.Repositories; @@ -16,9 +17,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "6.0.13") + .HasAnnotation("ProductVersion", "8.0.2") .HasAnnotation("Relational:MaxIdentifierLength", 64); + MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + modelBuilder.Entity("VirtoCommerce.Platform.Data.Localizations.LocalizedItemEntity", b => { b.Property("Id") @@ -385,6 +388,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("datetime(6)"); b.Property("SettingId") + .IsRequired() .HasColumnType("varchar(128)"); b.Property("ShortTextValue") @@ -438,7 +442,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasOne("VirtoCommerce.Platform.Data.Model.SettingEntity", "Setting") .WithMany("SettingValues") .HasForeignKey("SettingId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.Navigation("Setting"); }); diff --git a/src/VirtoCommerce.Platform.Data.PostgreSql/Migrations/Data/20240611091908_MakeSettingIdNotNullable.Designer.cs b/src/VirtoCommerce.Platform.Data.PostgreSql/Migrations/Data/20240611091908_MakeSettingIdNotNullable.Designer.cs new file mode 100644 index 00000000000..f5fe8725702 --- /dev/null +++ b/src/VirtoCommerce.Platform.Data.PostgreSql/Migrations/Data/20240611091908_MakeSettingIdNotNullable.Designer.cs @@ -0,0 +1,473 @@ +// +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.Platform.Data.Repositories; + +#nullable disable + +namespace VirtoCommerce.Platform.Data.PostgreSql.Migrations.Data +{ + [DbContext(typeof(PlatformDbContext))] + [Migration("20240611091908_MakeSettingIdNotNullable")] + partial class MakeSettingIdNotNullable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Localizations.LocalizedItemEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Alias") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("LanguageCode") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Value") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.HasKey("Id"); + + b.HasIndex("Name", "Alias") + .HasDatabaseName("IX_PlatformLocalizedItem_Name_Alias"); + + b.ToTable("PlatformLocalizedItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyDictionaryItemEntity", 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("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("PropertyId") + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("PropertyId", "Name") + .IsUnique() + .HasDatabaseName("IX_PlatformDynamicPropertyDictionaryItem_PropertyId_Name"); + + b.ToTable("PlatformDynamicPropertyDictionaryItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyDictionaryItemNameEntity", 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("DictionaryItemId") + .HasColumnType("character varying(128)"); + + b.Property("Locale") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.HasKey("Id"); + + b.HasIndex("DictionaryItemId", "Locale", "Name") + .IsUnique() + .HasDatabaseName("IX_PlatformDynamicPropertyDictionaryItemName_DictionaryItemId_Locale_Name"); + + b.ToTable("PlatformDynamicPropertyDictionaryItemName", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyEntity", 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("Description") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("DisplayOrder") + .HasColumnType("integer"); + + b.Property("IsArray") + .HasColumnType("boolean"); + + b.Property("IsDictionary") + .HasColumnType("boolean"); + + b.Property("IsMultilingual") + .HasColumnType("boolean"); + + b.Property("IsRequired") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("ObjectType") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("ValueType") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.HasKey("Id"); + + b.HasIndex("ObjectType", "Name") + .IsUnique() + .HasDatabaseName("IX_PlatformDynamicProperty_ObjectType_Name"); + + b.ToTable("PlatformDynamicProperty", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyNameEntity", 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("Locale") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PropertyId") + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("PropertyId", "Locale", "Name") + .IsUnique() + .HasDatabaseName("IX_PlatformDynamicPropertyName_PropertyId_Locale_Name"); + + b.ToTable("PlatformDynamicPropertyName", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.OperationLogEntity", 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("Detail") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("ObjectId") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("ObjectType") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("OperationType") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.HasKey("Id"); + + b.HasIndex("ObjectType", "ObjectId") + .HasDatabaseName("IX_OperationLog_ObjectType_ObjectId"); + + b.ToTable("PlatformOperationLog", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.RawLicenseEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Data") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("RawLicense", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.SettingEntity", 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("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ObjectId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ObjectType") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("ObjectType", "ObjectId") + .HasDatabaseName("IX_ObjectType_ObjectId"); + + b.ToTable("PlatformSetting", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.SettingValueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("BooleanValue") + .HasColumnType("boolean"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("DateTimeValue") + .HasColumnType("timestamp with time zone"); + + b.Property("DecimalValue") + .HasColumnType("decimal(18,5)"); + + b.Property("IntegerValue") + .HasColumnType("integer"); + + b.Property("LongTextValue") + .HasColumnType("text"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("SettingId") + .IsRequired() + .HasColumnType("character varying(128)"); + + b.Property("ShortTextValue") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("ValueType") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.HasKey("Id"); + + b.HasIndex("SettingId"); + + b.ToTable("PlatformSettingValue", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyDictionaryItemEntity", b => + { + b.HasOne("VirtoCommerce.Platform.Data.Model.DynamicPropertyEntity", "Property") + .WithMany("DictionaryItems") + .HasForeignKey("PropertyId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Property"); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyDictionaryItemNameEntity", b => + { + b.HasOne("VirtoCommerce.Platform.Data.Model.DynamicPropertyDictionaryItemEntity", "DictionaryItem") + .WithMany("DisplayNames") + .HasForeignKey("DictionaryItemId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("DictionaryItem"); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyNameEntity", b => + { + b.HasOne("VirtoCommerce.Platform.Data.Model.DynamicPropertyEntity", "Property") + .WithMany("DisplayNames") + .HasForeignKey("PropertyId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Property"); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.SettingValueEntity", b => + { + b.HasOne("VirtoCommerce.Platform.Data.Model.SettingEntity", "Setting") + .WithMany("SettingValues") + .HasForeignKey("SettingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Setting"); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyDictionaryItemEntity", b => + { + b.Navigation("DisplayNames"); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyEntity", b => + { + b.Navigation("DictionaryItems"); + + b.Navigation("DisplayNames"); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.SettingEntity", b => + { + b.Navigation("SettingValues"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/VirtoCommerce.Platform.Data.PostgreSql/Migrations/Data/20240611091908_MakeSettingIdNotNullable.cs b/src/VirtoCommerce.Platform.Data.PostgreSql/Migrations/Data/20240611091908_MakeSettingIdNotNullable.cs new file mode 100644 index 00000000000..602063df8f9 --- /dev/null +++ b/src/VirtoCommerce.Platform.Data.PostgreSql/Migrations/Data/20240611091908_MakeSettingIdNotNullable.cs @@ -0,0 +1,38 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace VirtoCommerce.Platform.Data.PostgreSql.Migrations.Data +{ + /// + public partial class MakeSettingIdNotNullable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql(@"DELETE ""PlatformSettingValue"" WHERE ""SettingId"" IS NULL"); + + migrationBuilder.AlterColumn( + name: "SettingId", + table: "PlatformSettingValue", + type: "character varying(128)", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "character varying(128)", + oldNullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "SettingId", + table: "PlatformSettingValue", + type: "character varying(128)", + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(128)"); + } + } +} diff --git a/src/VirtoCommerce.Platform.Data.PostgreSql/Migrations/Data/PlatformDbContextModelSnapshot.cs b/src/VirtoCommerce.Platform.Data.PostgreSql/Migrations/Data/PlatformDbContextModelSnapshot.cs index 9dc16df51b9..f1314c4b0c9 100644 --- a/src/VirtoCommerce.Platform.Data.PostgreSql/Migrations/Data/PlatformDbContextModelSnapshot.cs +++ b/src/VirtoCommerce.Platform.Data.PostgreSql/Migrations/Data/PlatformDbContextModelSnapshot.cs @@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "6.0.13") + .HasAnnotation("ProductVersion", "8.0.2") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); @@ -372,7 +372,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("timestamp with time zone"); b.Property("DecimalValue") - .HasColumnType("numeric(18,5)"); + .HasColumnType("decimal(18,5)"); b.Property("IntegerValue") .HasColumnType("integer"); @@ -388,6 +388,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("timestamp with time zone"); b.Property("SettingId") + .IsRequired() .HasColumnType("character varying(128)"); b.Property("ShortTextValue") @@ -441,7 +442,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasOne("VirtoCommerce.Platform.Data.Model.SettingEntity", "Setting") .WithMany("SettingValues") .HasForeignKey("SettingId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.Navigation("Setting"); }); diff --git a/src/VirtoCommerce.Platform.Data.SqlServer/Migrations/Data/20240611091951_MakeSettingIdNotNullable.Designer.cs b/src/VirtoCommerce.Platform.Data.SqlServer/Migrations/Data/20240611091951_MakeSettingIdNotNullable.Designer.cs new file mode 100644 index 00000000000..8636a0ffbcf --- /dev/null +++ b/src/VirtoCommerce.Platform.Data.SqlServer/Migrations/Data/20240611091951_MakeSettingIdNotNullable.Designer.cs @@ -0,0 +1,477 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using VirtoCommerce.Platform.Data.Repositories; + +#nullable disable + +namespace VirtoCommerce.Platform.Data.SqlServer.Migrations.Data +{ + [DbContext(typeof(PlatformDbContext))] + [Migration("20240611091951_MakeSettingIdNotNullable")] + partial class MakeSettingIdNotNullable + { + /// + 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.Platform.Data.Localizations.LocalizedItemEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Alias") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("LanguageCode") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Value") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)"); + + b.HasKey("Id"); + + b.HasIndex("Name", "Alias") + .HasDatabaseName("IX_PlatformLocalizedItem_Name_Alias"); + + b.ToTable("PlatformLocalizedItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyDictionaryItemEntity", 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("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("nvarchar(512)"); + + b.Property("PropertyId") + .HasColumnType("nvarchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("PropertyId", "Name") + .IsUnique() + .HasDatabaseName("IX_PlatformDynamicPropertyDictionaryItem_PropertyId_Name") + .HasFilter("[PropertyId] IS NOT NULL"); + + b.ToTable("PlatformDynamicPropertyDictionaryItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyDictionaryItemNameEntity", 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("DictionaryItemId") + .HasColumnType("nvarchar(128)"); + + b.Property("Locale") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)"); + + b.HasKey("Id"); + + b.HasIndex("DictionaryItemId", "Locale", "Name") + .IsUnique() + .HasDatabaseName("IX_PlatformDynamicPropertyDictionaryItemName_DictionaryItemId_Locale_Name") + .HasFilter("[DictionaryItemId] IS NOT NULL AND [Locale] IS NOT NULL AND [Name] IS NOT NULL"); + + b.ToTable("PlatformDynamicPropertyDictionaryItemName", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyEntity", 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("Description") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("DisplayOrder") + .HasColumnType("int"); + + b.Property("IsArray") + .HasColumnType("bit"); + + b.Property("IsDictionary") + .HasColumnType("bit"); + + b.Property("IsMultilingual") + .HasColumnType("bit"); + + b.Property("IsRequired") + .HasColumnType("bit"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("ObjectType") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("ValueType") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("ObjectType", "Name") + .IsUnique() + .HasDatabaseName("IX_PlatformDynamicProperty_ObjectType_Name") + .HasFilter("[ObjectType] IS NOT NULL AND [Name] IS NOT NULL"); + + b.ToTable("PlatformDynamicProperty", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyNameEntity", 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("Locale") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PropertyId") + .HasColumnType("nvarchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("PropertyId", "Locale", "Name") + .IsUnique() + .HasDatabaseName("IX_PlatformDynamicPropertyName_PropertyId_Locale_Name") + .HasFilter("[PropertyId] IS NOT NULL AND [Locale] IS NOT NULL AND [Name] IS NOT NULL"); + + b.ToTable("PlatformDynamicPropertyName", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.OperationLogEntity", 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("Detail") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("ObjectId") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("ObjectType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("OperationType") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("ObjectType", "ObjectId") + .HasDatabaseName("IX_OperationLog_ObjectType_ObjectId"); + + b.ToTable("PlatformOperationLog", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.RawLicenseEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("RawLicense", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.SettingEntity", 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("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ObjectId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ObjectType") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("ObjectType", "ObjectId") + .HasDatabaseName("IX_ObjectType_ObjectId"); + + b.ToTable("PlatformSetting", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.SettingValueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("BooleanValue") + .HasColumnType("bit"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("DateTimeValue") + .HasColumnType("datetime2"); + + b.Property("DecimalValue") + .HasColumnType("decimal(18,5)"); + + b.Property("IntegerValue") + .HasColumnType("int"); + + b.Property("LongTextValue") + .HasColumnType("nvarchar(max)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("SettingId") + .IsRequired() + .HasColumnType("nvarchar(128)"); + + b.Property("ShortTextValue") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)"); + + b.Property("ValueType") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("SettingId"); + + b.ToTable("PlatformSettingValue", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyDictionaryItemEntity", b => + { + b.HasOne("VirtoCommerce.Platform.Data.Model.DynamicPropertyEntity", "Property") + .WithMany("DictionaryItems") + .HasForeignKey("PropertyId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Property"); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyDictionaryItemNameEntity", b => + { + b.HasOne("VirtoCommerce.Platform.Data.Model.DynamicPropertyDictionaryItemEntity", "DictionaryItem") + .WithMany("DisplayNames") + .HasForeignKey("DictionaryItemId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("DictionaryItem"); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyNameEntity", b => + { + b.HasOne("VirtoCommerce.Platform.Data.Model.DynamicPropertyEntity", "Property") + .WithMany("DisplayNames") + .HasForeignKey("PropertyId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Property"); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.SettingValueEntity", b => + { + b.HasOne("VirtoCommerce.Platform.Data.Model.SettingEntity", "Setting") + .WithMany("SettingValues") + .HasForeignKey("SettingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Setting"); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyDictionaryItemEntity", b => + { + b.Navigation("DisplayNames"); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.DynamicPropertyEntity", b => + { + b.Navigation("DictionaryItems"); + + b.Navigation("DisplayNames"); + }); + + modelBuilder.Entity("VirtoCommerce.Platform.Data.Model.SettingEntity", b => + { + b.Navigation("SettingValues"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/VirtoCommerce.Platform.Data.SqlServer/Migrations/Data/20240611091951_MakeSettingIdNotNullable.cs b/src/VirtoCommerce.Platform.Data.SqlServer/Migrations/Data/20240611091951_MakeSettingIdNotNullable.cs new file mode 100644 index 00000000000..03d5b6a3a3c --- /dev/null +++ b/src/VirtoCommerce.Platform.Data.SqlServer/Migrations/Data/20240611091951_MakeSettingIdNotNullable.cs @@ -0,0 +1,38 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace VirtoCommerce.Platform.Data.SqlServer.Migrations.Data +{ + /// + public partial class MakeSettingIdNotNullable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DELETE PlatformSettingValue WHERE SettingId IS NULL"); + + migrationBuilder.AlterColumn( + name: "SettingId", + table: "PlatformSettingValue", + type: "nvarchar(128)", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(128)", + oldNullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "SettingId", + table: "PlatformSettingValue", + type: "nvarchar(128)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(128)"); + } + } +} diff --git a/src/VirtoCommerce.Platform.Data.SqlServer/Migrations/Data/PlatformDbContextModelSnapshot.cs b/src/VirtoCommerce.Platform.Data.SqlServer/Migrations/Data/PlatformDbContextModelSnapshot.cs index 4e2cb91f40f..54b338bc96d 100644 --- a/src/VirtoCommerce.Platform.Data.SqlServer/Migrations/Data/PlatformDbContextModelSnapshot.cs +++ b/src/VirtoCommerce.Platform.Data.SqlServer/Migrations/Data/PlatformDbContextModelSnapshot.cs @@ -17,10 +17,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "6.0.13") + .HasAnnotation("ProductVersion", "8.0.0") .HasAnnotation("Relational:MaxIdentifierLength", 128); - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); modelBuilder.Entity("VirtoCommerce.Platform.Data.Localizations.LocalizedItemEntity", b => { @@ -392,6 +392,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("datetime2"); b.Property("SettingId") + .IsRequired() .HasColumnType("nvarchar(128)"); b.Property("ShortTextValue") @@ -445,7 +446,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasOne("VirtoCommerce.Platform.Data.Model.SettingEntity", "Setting") .WithMany("SettingValues") .HasForeignKey("SettingId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.Navigation("Setting"); }); diff --git a/src/VirtoCommerce.Platform.Data/Repositories/PlatformDbContext.cs b/src/VirtoCommerce.Platform.Data/Repositories/PlatformDbContext.cs index b3d08b2f8e5..aeb7f730e11 100644 --- a/src/VirtoCommerce.Platform.Data/Repositories/PlatformDbContext.cs +++ b/src/VirtoCommerce.Platform.Data/Repositories/PlatformDbContext.cs @@ -53,7 +53,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().HasOne(x => x.Setting) .WithMany(x => x.SettingValues) .HasForeignKey(x => x.SettingId) - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); modelBuilder.Entity() .Property(x => x.DecimalValue)