Skip to content

Commit

Permalink
VCST-1364: fix: Deleted setting values remained in the PlatformSettin…
Browse files Browse the repository at this point in the history
…gValue table (#2806)
  • Loading branch information
artem-dudarev committed Jun 14, 2024
1 parent 498b5b4 commit 9472944
Show file tree
Hide file tree
Showing 10 changed files with 1,566 additions and 9 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace VirtoCommerce.Platform.Data.MySql.Migrations.Data
{
/// <inheritdoc />
public partial class MakeSettingIdNotNullable : Migration
{
/// <inheritdoc />
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<string>(
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");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "SettingId",
table: "PlatformSettingValue",
type: "varchar(128)",
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(128)")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<string>("Id")
Expand Down Expand Up @@ -385,6 +388,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("datetime(6)");
b.Property<string>("SettingId")
.IsRequired()
.HasColumnType("varchar(128)");
b.Property<string>("ShortTextValue")
Expand Down Expand Up @@ -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");
});
Expand Down

0 comments on commit 9472944

Please sign in to comment.