mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 07:11:10 +00:00
Adds deletion and restore for music library items.
This commit is contained in:
1 parent
98515dc5e8
commit
f9ad8b2fc5
224 files changed
+22384
-1360
No files matched your search
@@ -130,6 +130,12 @@ public class AlbumConfiguration : IEntityTypeConfiguration<AlbumEntity>
|
||||
builder.Property(album => album.MetadataProvider)
|
||||
.HasMaxLength(100)
|
||||
.HasColumnOrder(38);
|
||||
builder.Property(album => album.IsDeleted)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false)
|
||||
.HasColumnOrder(39);
|
||||
builder.Property(album => album.DeletedOnUtc)
|
||||
.HasColumnOrder(40);
|
||||
|
||||
builder.HasOne(album => album.Artist)
|
||||
.WithMany(artist => artist.Albums)
|
||||
@@ -232,5 +238,9 @@ public class AlbumConfiguration : IEntityTypeConfiguration<AlbumEntity>
|
||||
|
||||
builder.HasIndex(album => new { album.ArtistId, album.Title });
|
||||
builder.HasIndex(album => new { album.LibraryId, album.Title });
|
||||
// The deleted items page filters by library and deletion state, and orders by the stored deletion time, the title and the Id, so the
|
||||
// filtered index follows the same order and no temporary B-tree is needed for the sort, while visible rows add no entries to it.
|
||||
builder.HasIndex(album => new { album.LibraryId, album.IsDeleted, album.DeletedOnUtc, album.Title, album.Id })
|
||||
.HasFilter("\"IsDeleted\" = 1");
|
||||
}
|
||||
}
|
||||
@@ -83,6 +83,12 @@ public class ArtistConfiguration : IEntityTypeConfiguration<ArtistEntity>
|
||||
builder.Property(artist => artist.MetadataProvider)
|
||||
.HasMaxLength(100)
|
||||
.HasColumnOrder(19);
|
||||
builder.Property(artist => artist.IsDeleted)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false)
|
||||
.HasColumnOrder(20);
|
||||
builder.Property(artist => artist.DeletedOnUtc)
|
||||
.HasColumnOrder(21);
|
||||
|
||||
// The areas are owned value objects that are never referenced on their own, so they are stored as JSON documents next to the artist.
|
||||
builder.OwnsOne(artist => artist.Area, areaBuilder => areaBuilder.ToJson());
|
||||
@@ -202,7 +208,14 @@ public class ArtistConfiguration : IEntityTypeConfiguration<ArtistEntity>
|
||||
.HasForeignKey(contributor => contributor.ArtistId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
// The same visible artist cannot appear twice in the same library, while a deleted artist does not block a new visible artist with the
|
||||
// same name, so that a new file of an artist the user deleted can still materialize as a new, visible artist.
|
||||
builder.HasIndex(artist => new { artist.LibraryId, artist.Name })
|
||||
.IsUnique(); // the same artist cannot appear twice in the same library
|
||||
.IsUnique()
|
||||
.HasFilter("\"IsDeleted\" = 0");
|
||||
// The deleted items page filters by library and deletion state, and orders by the stored deletion time, the name and the Id, so the
|
||||
// filtered index follows the same order and no temporary B-tree is needed for the sort, while visible rows add no entries to it.
|
||||
builder.HasIndex(artist => new { artist.LibraryId, artist.IsDeleted, artist.DeletedOnUtc, artist.Name, artist.Id })
|
||||
.HasFilter("\"IsDeleted\" = 1");
|
||||
}
|
||||
}
|
||||
@@ -155,6 +155,12 @@ public class TrackConfiguration : IEntityTypeConfiguration<TrackEntity>
|
||||
builder.Property(track => track.Container)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnOrder(49);
|
||||
builder.Property(track => track.IsDeleted)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false)
|
||||
.HasColumnOrder(50);
|
||||
builder.Property(track => track.DeletedOnUtc)
|
||||
.HasColumnOrder(51);
|
||||
|
||||
builder.HasOne(track => track.Album)
|
||||
.WithMany(album => album.Tracks)
|
||||
@@ -291,5 +297,9 @@ public class TrackConfiguration : IEntityTypeConfiguration<TrackEntity>
|
||||
builder.HasIndex(track => new { track.AlbumId, track.TrackNumber });
|
||||
builder.HasIndex(track => new { track.LibraryId, track.Path })
|
||||
.IsUnique(); // the same physical track file cannot appear twice in the same library
|
||||
// The deleted items page filters by library and deletion state, and orders by the stored deletion time, the title and the Id, so the
|
||||
// filtered index follows the same order and no temporary B-tree is needed for the sort, while visible rows add no entries to it.
|
||||
builder.HasIndex(track => new { track.LibraryId, track.IsDeleted, track.DeletedOnUtc, track.Title, track.Id })
|
||||
.HasFilter("\"IsDeleted\" = 1");
|
||||
}
|
||||
}
|
||||
+3956
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,139 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Lumina.DataAccess.Common.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddsMusicDeletionState : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Artists_LibraryId_Name",
|
||||
table: "Artists");
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "DeletedOnUtc",
|
||||
table: "Tracks",
|
||||
type: "TEXT",
|
||||
nullable: true)
|
||||
.Annotation("Relational:ColumnOrder", 51);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsDeleted",
|
||||
table: "Tracks",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: false)
|
||||
.Annotation("Relational:ColumnOrder", 50);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "DeletedOnUtc",
|
||||
table: "Artists",
|
||||
type: "TEXT",
|
||||
nullable: true)
|
||||
.Annotation("Relational:ColumnOrder", 21);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsDeleted",
|
||||
table: "Artists",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: false)
|
||||
.Annotation("Relational:ColumnOrder", 20);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "DeletedOnUtc",
|
||||
table: "Albums",
|
||||
type: "TEXT",
|
||||
nullable: true)
|
||||
.Annotation("Relational:ColumnOrder", 40);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsDeleted",
|
||||
table: "Albums",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: false)
|
||||
.Annotation("Relational:ColumnOrder", 39);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Tracks_LibraryId_IsDeleted_DeletedOnUtc_Title_Id",
|
||||
table: "Tracks",
|
||||
columns: new[] { "LibraryId", "IsDeleted", "DeletedOnUtc", "Title", "Id" },
|
||||
filter: "\"IsDeleted\" = 1");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Artists_LibraryId_IsDeleted_DeletedOnUtc_Name_Id",
|
||||
table: "Artists",
|
||||
columns: new[] { "LibraryId", "IsDeleted", "DeletedOnUtc", "Name", "Id" },
|
||||
filter: "\"IsDeleted\" = 1");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Artists_LibraryId_Name",
|
||||
table: "Artists",
|
||||
columns: new[] { "LibraryId", "Name" },
|
||||
unique: true,
|
||||
filter: "\"IsDeleted\" = 0");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Albums_LibraryId_IsDeleted_DeletedOnUtc_Title_Id",
|
||||
table: "Albums",
|
||||
columns: new[] { "LibraryId", "IsDeleted", "DeletedOnUtc", "Title", "Id" },
|
||||
filter: "\"IsDeleted\" = 1");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Tracks_LibraryId_IsDeleted_DeletedOnUtc_Title_Id",
|
||||
table: "Tracks");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Artists_LibraryId_IsDeleted_DeletedOnUtc_Name_Id",
|
||||
table: "Artists");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Artists_LibraryId_Name",
|
||||
table: "Artists");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Albums_LibraryId_IsDeleted_DeletedOnUtc_Title_Id",
|
||||
table: "Albums");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DeletedOnUtc",
|
||||
table: "Tracks");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsDeleted",
|
||||
table: "Tracks");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DeletedOnUtc",
|
||||
table: "Artists");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsDeleted",
|
||||
table: "Artists");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DeletedOnUtc",
|
||||
table: "Albums");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsDeleted",
|
||||
table: "Albums");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Artists_LibraryId_Name",
|
||||
table: "Artists",
|
||||
columns: new[] { "LibraryId", "Name" },
|
||||
unique: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -652,6 +652,10 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(32);
|
||||
|
||||
b.Property<DateTime?>("DeletedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(40);
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("TEXT")
|
||||
@@ -662,6 +666,12 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(6);
|
||||
|
||||
b.Property<bool>("IsDeleted")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasDefaultValue(false)
|
||||
.HasColumnOrder(39);
|
||||
|
||||
b.Property<string>("Label")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("TEXT")
|
||||
@@ -807,6 +817,9 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
|
||||
b.HasIndex("LibraryId", "Title");
|
||||
|
||||
b.HasIndex("LibraryId", "IsDeleted", "DeletedOnUtc", "Title", "Id")
|
||||
.HasFilter("\"IsDeleted\" = 1");
|
||||
|
||||
b.ToTable("Albums", (string)null);
|
||||
});
|
||||
|
||||
@@ -875,6 +888,10 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(13);
|
||||
|
||||
b.Property<DateTime?>("DeletedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(21);
|
||||
|
||||
b.Property<string>("Disambiguation")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("TEXT")
|
||||
@@ -885,6 +902,12 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(6);
|
||||
|
||||
b.Property<bool>("IsDeleted")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasDefaultValue(false)
|
||||
.HasColumnOrder(20);
|
||||
|
||||
b.Property<bool>("IsEnded")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnOrder(10);
|
||||
@@ -954,7 +977,11 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("LibraryId", "Name")
|
||||
.IsUnique();
|
||||
.IsUnique()
|
||||
.HasFilter("\"IsDeleted\" = 0");
|
||||
|
||||
b.HasIndex("LibraryId", "IsDeleted", "DeletedOnUtc", "Name", "Id")
|
||||
.HasFilter("\"IsDeleted\" = 1");
|
||||
|
||||
b.ToTable("Artists", (string)null);
|
||||
});
|
||||
@@ -1279,6 +1306,10 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(37);
|
||||
|
||||
b.Property<DateTime?>("DeletedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(51);
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("TEXT")
|
||||
@@ -1297,6 +1328,12 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnOrder(20);
|
||||
|
||||
b.Property<bool>("IsDeleted")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasDefaultValue(false)
|
||||
.HasColumnOrder(50);
|
||||
|
||||
b.Property<bool>("IsVideo")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnOrder(31);
|
||||
@@ -1459,6 +1496,9 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
b.HasIndex("LibraryId", "Path")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("LibraryId", "IsDeleted", "DeletedOnUtc", "Title", "Id")
|
||||
.HasFilter("\"IsDeleted\" = 1");
|
||||
|
||||
b.ToTable("Tracks", (string)null);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user