adds unique indices for images within album and album within server
This commit is contained in:
parent
2ceef99d1a
commit
f111df487d
159
PiwigoDirectorySync/Migrations/20230911213151_AlbumPathIsUniqueWithinServer.Designer.cs
generated
Normal file
159
PiwigoDirectorySync/Migrations/20230911213151_AlbumPathIsUniqueWithinServer.Designer.cs
generated
Normal file
@ -0,0 +1,159 @@
|
||||
// <auto-generated />
|
||||
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("20230911213151_AlbumPathIsUniqueWithinServer")]
|
||||
partial class AlbumPathIsUniqueWithinServer
|
||||
{
|
||||
/// <inheritdoc />
|
||||
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<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("ParentId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Path")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("ServerAlbumId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("ServerId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ParentId");
|
||||
|
||||
b.HasIndex("ServerAlbumId");
|
||||
|
||||
b.HasIndex("ServerId", "Path")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("PiwigoAlbums");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PiwigoDirectorySync.Persistence.ImageEntity", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("AlbumId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("DeleteRequired")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("FilePath")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("LastChange")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Md5Sum")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("ServerImageId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("UploadRequired")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ServerImageId");
|
||||
|
||||
b.HasIndex("AlbumId", "FilePath");
|
||||
|
||||
b.ToTable("PiwigoImages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PiwigoDirectorySync.Persistence.ServerEntity", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("RootDirectory")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("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
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PiwigoDirectorySync.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AlbumPathIsUniqueWithinServer : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_PiwigoAlbums_ServerId_Path",
|
||||
table: "PiwigoAlbums");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PiwigoAlbums_ServerId_Path",
|
||||
table: "PiwigoAlbums",
|
||||
columns: new[] { "ServerId", "Path" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_PiwigoAlbums_ServerId_Path",
|
||||
table: "PiwigoAlbums");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PiwigoAlbums_ServerId_Path",
|
||||
table: "PiwigoAlbums",
|
||||
columns: new[] { "ServerId", "Path" });
|
||||
}
|
||||
}
|
||||
}
|
160
PiwigoDirectorySync/Migrations/20230911213415_ImagePathIsUniqueWithinAlbum.Designer.cs
generated
Normal file
160
PiwigoDirectorySync/Migrations/20230911213415_ImagePathIsUniqueWithinAlbum.Designer.cs
generated
Normal file
@ -0,0 +1,160 @@
|
||||
// <auto-generated />
|
||||
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("20230911213415_ImagePathIsUniqueWithinAlbum")]
|
||||
partial class ImagePathIsUniqueWithinAlbum
|
||||
{
|
||||
/// <inheritdoc />
|
||||
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<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("ParentId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Path")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("ServerAlbumId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("ServerId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ParentId");
|
||||
|
||||
b.HasIndex("ServerAlbumId");
|
||||
|
||||
b.HasIndex("ServerId", "Path")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("PiwigoAlbums");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PiwigoDirectorySync.Persistence.ImageEntity", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("AlbumId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("DeleteRequired")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("FilePath")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("LastChange")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Md5Sum")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("ServerImageId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("UploadRequired")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ServerImageId");
|
||||
|
||||
b.HasIndex("AlbumId", "FilePath")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("PiwigoImages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PiwigoDirectorySync.Persistence.ServerEntity", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("RootDirectory")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("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
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PiwigoDirectorySync.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class ImagePathIsUniqueWithinAlbum : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_PiwigoImages_AlbumId_FilePath",
|
||||
table: "PiwigoImages");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PiwigoImages_AlbumId_FilePath",
|
||||
table: "PiwigoImages",
|
||||
columns: new[] { "AlbumId", "FilePath" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_PiwigoImages_AlbumId_FilePath",
|
||||
table: "PiwigoImages");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PiwigoImages_AlbumId_FilePath",
|
||||
table: "PiwigoImages",
|
||||
columns: new[] { "AlbumId", "FilePath" });
|
||||
}
|
||||
}
|
||||
}
|
@ -46,7 +46,8 @@ namespace PiwigoDirectorySync.Migrations
|
||||
|
||||
b.HasIndex("ServerAlbumId");
|
||||
|
||||
b.HasIndex("ServerId", "Path");
|
||||
b.HasIndex("ServerId", "Path")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("PiwigoAlbums");
|
||||
});
|
||||
@ -83,7 +84,8 @@ namespace PiwigoDirectorySync.Migrations
|
||||
|
||||
b.HasIndex("ServerImageId");
|
||||
|
||||
b.HasIndex("AlbumId", "FilePath");
|
||||
b.HasIndex("AlbumId", "FilePath")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("PiwigoImages");
|
||||
});
|
||||
|
@ -6,7 +6,7 @@ namespace PiwigoDirectorySync.Persistence;
|
||||
|
||||
[Index(nameof(ParentId))]
|
||||
[Index(nameof(ServerAlbumId))]
|
||||
[Index(nameof(ServerId), nameof(Path))]
|
||||
[Index(nameof(ServerId), nameof(Path), IsUnique = true)]
|
||||
public class AlbumEntity
|
||||
{
|
||||
[Key]
|
||||
|
14
PiwigoDirectorySync/Persistence/BloggingContextFactory.cs
Normal file
14
PiwigoDirectorySync/Persistence/BloggingContextFactory.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Design;
|
||||
|
||||
namespace PiwigoDirectorySync.Persistence;
|
||||
|
||||
public class BloggingContextFactory : IDesignTimeDbContextFactory<PersistenceContext>
|
||||
{
|
||||
public PersistenceContext CreateDbContext(string[] args)
|
||||
{
|
||||
var optionsBuilder = new DbContextOptionsBuilder<PersistenceContext>();
|
||||
optionsBuilder.UseSqlite("Data Source=piwigoSync.db");
|
||||
return new PersistenceContext(optionsBuilder.Options);
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace PiwigoDirectorySync.Persistence;
|
||||
|
||||
[Index(nameof(AlbumId), nameof(FilePath))]
|
||||
[Index(nameof(AlbumId), nameof(FilePath), IsUnique = true)]
|
||||
[Index(nameof(ServerImageId))]
|
||||
public class ImageEntity
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user