From 65902b44dfa69ba33f57cf13685425e701a3b237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=A4felfinger?= Date: Wed, 30 Aug 2023 23:40:00 +0200 Subject: [PATCH] adds additional index to album table --- ...s_serverId_path_index_to_album.Designer.cs | 158 ++++++++++++++++++ ...13947_Adds_serverId_path_index_to_album.cs | 36 ++++ .../PersistenceContextModelSnapshot.cs | 2 +- .../Persistence/AlbumEntity.cs | 1 + 4 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 PiwigoDirectorySync/Migrations/20230830213947_Adds_serverId_path_index_to_album.Designer.cs create mode 100644 PiwigoDirectorySync/Migrations/20230830213947_Adds_serverId_path_index_to_album.cs diff --git a/PiwigoDirectorySync/Migrations/20230830213947_Adds_serverId_path_index_to_album.Designer.cs b/PiwigoDirectorySync/Migrations/20230830213947_Adds_serverId_path_index_to_album.Designer.cs new file mode 100644 index 0000000..f2d9d39 --- /dev/null +++ b/PiwigoDirectorySync/Migrations/20230830213947_Adds_serverId_path_index_to_album.Designer.cs @@ -0,0 +1,158 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using PiwigoDirectorySync.Persistence; + +#nullable disable + +namespace PiwigoDirectorySync.Migrations +{ + [DbContext(typeof(PersistenceContext))] + [Migration("20230830213947_Adds_serverId_path_index_to_album")] + partial class Adds_serverId_path_index_to_album + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.10"); + + modelBuilder.Entity("PiwigoDirectorySync.Persistence.AlbumEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ParentId") + .HasColumnType("INTEGER"); + + b.Property("Path") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ServerAlbumId") + .HasColumnType("INTEGER"); + + b.Property("ServerId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.HasIndex("ServerAlbumId"); + + b.HasIndex("ServerId", "Path"); + + b.ToTable("PiwigoAlbums"); + }); + + modelBuilder.Entity("PiwigoDirectorySync.Persistence.ImageEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AlbumId") + .HasColumnType("INTEGER"); + + b.Property("DeleteRequired") + .HasColumnType("INTEGER"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("LastChange") + .HasColumnType("TEXT"); + + b.Property("Md5Sum") + .HasColumnType("TEXT"); + + b.Property("ServerImageId") + .HasColumnType("INTEGER"); + + b.Property("UploadRequired") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ServerImageId"); + + b.HasIndex("AlbumId", "FilePath"); + + b.ToTable("PiwigoImages"); + }); + + modelBuilder.Entity("PiwigoDirectorySync.Persistence.ServerEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Password") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("RootDirectory") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Url") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Username") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("PiwigoServers"); + }); + + modelBuilder.Entity("PiwigoDirectorySync.Persistence.AlbumEntity", b => + { + b.HasOne("PiwigoDirectorySync.Persistence.AlbumEntity", "Parent") + .WithMany() + .HasForeignKey("ParentId"); + + b.HasOne("PiwigoDirectorySync.Persistence.ServerEntity", "Server") + .WithMany() + .HasForeignKey("ServerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Parent"); + + b.Navigation("Server"); + }); + + modelBuilder.Entity("PiwigoDirectorySync.Persistence.ImageEntity", b => + { + b.HasOne("PiwigoDirectorySync.Persistence.AlbumEntity", "Album") + .WithMany() + .HasForeignKey("AlbumId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Album"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/PiwigoDirectorySync/Migrations/20230830213947_Adds_serverId_path_index_to_album.cs b/PiwigoDirectorySync/Migrations/20230830213947_Adds_serverId_path_index_to_album.cs new file mode 100644 index 0000000..51899d3 --- /dev/null +++ b/PiwigoDirectorySync/Migrations/20230830213947_Adds_serverId_path_index_to_album.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace PiwigoDirectorySync.Migrations +{ + /// + public partial class Adds_serverId_path_index_to_album : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_PiwigoAlbums_ServerId", + table: "PiwigoAlbums"); + + migrationBuilder.CreateIndex( + name: "IX_PiwigoAlbums_ServerId_Path", + table: "PiwigoAlbums", + columns: new[] { "ServerId", "Path" }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_PiwigoAlbums_ServerId_Path", + table: "PiwigoAlbums"); + + migrationBuilder.CreateIndex( + name: "IX_PiwigoAlbums_ServerId", + table: "PiwigoAlbums", + column: "ServerId"); + } + } +} diff --git a/PiwigoDirectorySync/Migrations/PersistenceContextModelSnapshot.cs b/PiwigoDirectorySync/Migrations/PersistenceContextModelSnapshot.cs index a04fa60..bb27dde 100644 --- a/PiwigoDirectorySync/Migrations/PersistenceContextModelSnapshot.cs +++ b/PiwigoDirectorySync/Migrations/PersistenceContextModelSnapshot.cs @@ -46,7 +46,7 @@ namespace PiwigoDirectorySync.Migrations b.HasIndex("ServerAlbumId"); - b.HasIndex("ServerId"); + b.HasIndex("ServerId", "Path"); b.ToTable("PiwigoAlbums"); }); diff --git a/PiwigoDirectorySync/Persistence/AlbumEntity.cs b/PiwigoDirectorySync/Persistence/AlbumEntity.cs index a645fa6..9466c3d 100644 --- a/PiwigoDirectorySync/Persistence/AlbumEntity.cs +++ b/PiwigoDirectorySync/Persistence/AlbumEntity.cs @@ -6,6 +6,7 @@ namespace PiwigoDirectorySync.Persistence; [Index(nameof(ParentId))] [Index(nameof(ServerAlbumId))] +[Index(nameof(ServerId), nameof(Path))] public class AlbumEntity { [Key]