From da1bb941f02679862f596ea1be299d615cefbb56 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Mon, 25 Jul 2022 19:03:49 +0200 Subject: [PATCH] Renamed settings name to code --- .../DataModel/Database/Common/DataContext.cs | 2 +- I18N Commander/DataModel/Database/Setting.cs | 2 +- ...0320_202207RenamedSettingsCode.Designer.cs | 201 ++++++++++++++++++ ...0220725170320_202207RenamedSettingsCode.cs | 35 +++ .../Migrations/DataContextModelSnapshot.cs | 14 +- 5 files changed, 245 insertions(+), 9 deletions(-) create mode 100644 I18N Commander/DataModel/Migrations/20220725170320_202207RenamedSettingsCode.Designer.cs create mode 100644 I18N Commander/DataModel/Migrations/20220725170320_202207RenamedSettingsCode.cs diff --git a/I18N Commander/DataModel/Database/Common/DataContext.cs b/I18N Commander/DataModel/Database/Common/DataContext.cs index 4d633ee..dc6e797 100644 --- a/I18N Commander/DataModel/Database/Common/DataContext.cs +++ b/I18N Commander/DataModel/Database/Common/DataContext.cs @@ -23,7 +23,7 @@ public sealed class DataContext : DbContext #region Settings modelBuilder.Entity().HasIndex(n => n.Id); - modelBuilder.Entity().HasIndex(n => n.Name).IsUnique(); + modelBuilder.Entity().HasIndex(n => n.Code).IsUnique(); modelBuilder.Entity().HasIndex(n => n.BoolValue); modelBuilder.Entity().HasIndex(n => n.GuidValue); modelBuilder.Entity().HasIndex(n => n.IntegerValue); diff --git a/I18N Commander/DataModel/Database/Setting.cs b/I18N Commander/DataModel/Database/Setting.cs index cf0dc62..8c2dc74 100644 --- a/I18N Commander/DataModel/Database/Setting.cs +++ b/I18N Commander/DataModel/Database/Setting.cs @@ -7,7 +7,7 @@ public sealed class Setting [Key] public int Id { get; set; } - public string Name { get; set; } = string.Empty; + public string Code { get; set; } = string.Empty; public string TextValue { get; set; } = string.Empty; diff --git a/I18N Commander/DataModel/Migrations/20220725170320_202207RenamedSettingsCode.Designer.cs b/I18N Commander/DataModel/Migrations/20220725170320_202207RenamedSettingsCode.Designer.cs new file mode 100644 index 0000000..20b0d4a --- /dev/null +++ b/I18N Commander/DataModel/Migrations/20220725170320_202207RenamedSettingsCode.Designer.cs @@ -0,0 +1,201 @@ +// +using System; +using DataModel.Database.Common; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace DataModel.Migrations +{ + [DbContext(typeof(DataContext))] + [Migration("20220725170320_202207RenamedSettingsCode")] + partial class _202207RenamedSettingsCode + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.5"); + + modelBuilder.Entity("DataModel.Database.Section", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DataKey") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Depth") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ParentId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("DataKey"); + + b.HasIndex("Depth"); + + b.HasIndex("Id"); + + b.HasIndex("Name"); + + b.HasIndex("ParentId"); + + b.ToTable("Sections"); + }); + + modelBuilder.Entity("DataModel.Database.Setting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("BoolValue") + .HasColumnType("INTEGER"); + + b.Property("Code") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("GuidValue") + .HasColumnType("TEXT"); + + b.Property("IntegerValue") + .HasColumnType("INTEGER"); + + b.Property("TextValue") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("BoolValue"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("GuidValue"); + + b.HasIndex("Id"); + + b.HasIndex("IntegerValue"); + + b.HasIndex("TextValue"); + + b.ToTable("Settings"); + }); + + modelBuilder.Entity("DataModel.Database.TextElement", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Code") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("SectionId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.HasIndex("Id"); + + b.HasIndex("Name"); + + b.HasIndex("SectionId"); + + b.ToTable("TextElements"); + }); + + modelBuilder.Entity("DataModel.Database.Translation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Culture") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Text") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("TextElementId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("Culture"); + + b.HasIndex("Id"); + + b.HasIndex("Text"); + + b.HasIndex("TextElementId"); + + b.ToTable("Translations"); + }); + + modelBuilder.Entity("DataModel.Database.Section", b => + { + b.HasOne("DataModel.Database.Section", "Parent") + .WithMany() + .HasForeignKey("ParentId"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("DataModel.Database.TextElement", b => + { + b.HasOne("DataModel.Database.Section", "Section") + .WithMany("TextElements") + .HasForeignKey("SectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Section"); + }); + + modelBuilder.Entity("DataModel.Database.Translation", b => + { + b.HasOne("DataModel.Database.TextElement", "TextElement") + .WithMany("Translations") + .HasForeignKey("TextElementId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TextElement"); + }); + + modelBuilder.Entity("DataModel.Database.Section", b => + { + b.Navigation("TextElements"); + }); + + modelBuilder.Entity("DataModel.Database.TextElement", b => + { + b.Navigation("Translations"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/I18N Commander/DataModel/Migrations/20220725170320_202207RenamedSettingsCode.cs b/I18N Commander/DataModel/Migrations/20220725170320_202207RenamedSettingsCode.cs new file mode 100644 index 0000000..7b753ab --- /dev/null +++ b/I18N Commander/DataModel/Migrations/20220725170320_202207RenamedSettingsCode.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DataModel.Migrations +{ + public partial class _202207RenamedSettingsCode : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "Name", + table: "Settings", + newName: "Code"); + + migrationBuilder.RenameIndex( + name: "IX_Settings_Name", + table: "Settings", + newName: "IX_Settings_Code"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "Code", + table: "Settings", + newName: "Name"); + + migrationBuilder.RenameIndex( + name: "IX_Settings_Code", + table: "Settings", + newName: "IX_Settings_Name"); + } + } +} diff --git a/I18N Commander/DataModel/Migrations/DataContextModelSnapshot.cs b/I18N Commander/DataModel/Migrations/DataContextModelSnapshot.cs index 616d211..a43e0c8 100644 --- a/I18N Commander/DataModel/Migrations/DataContextModelSnapshot.cs +++ b/I18N Commander/DataModel/Migrations/DataContextModelSnapshot.cs @@ -61,16 +61,16 @@ namespace DataModel.Migrations b.Property("BoolValue") .HasColumnType("INTEGER"); + b.Property("Code") + .IsRequired() + .HasColumnType("TEXT"); + b.Property("GuidValue") .HasColumnType("TEXT"); b.Property("IntegerValue") .HasColumnType("INTEGER"); - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - b.Property("TextValue") .IsRequired() .HasColumnType("TEXT"); @@ -79,15 +79,15 @@ namespace DataModel.Migrations b.HasIndex("BoolValue"); + b.HasIndex("Code") + .IsUnique(); + b.HasIndex("GuidValue"); b.HasIndex("Id"); b.HasIndex("IntegerValue"); - b.HasIndex("Name") - .IsUnique(); - b.HasIndex("TextValue"); b.ToTable("Settings");