store local library folder hierarchy in db (#1616)

This commit is contained in:
Jason Dove
2024-02-16 06:16:19 -06:00
committed by GitHub
parent c490832f66
commit 71e9ea867a
38 changed files with 21317 additions and 191 deletions
@@ -0,0 +1,80 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ErsatzTV.Infrastructure.Sqlite.Migrations
{
/// <inheritdoc />
public partial class Rework_LibraryFolder : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "LibraryFolderId",
table: "MediaFile",
type: "INTEGER",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "ParentId",
table: "LibraryFolder",
type: "INTEGER",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_MediaFile_LibraryFolderId",
table: "MediaFile",
column: "LibraryFolderId");
migrationBuilder.CreateIndex(
name: "IX_LibraryFolder_ParentId",
table: "LibraryFolder",
column: "ParentId");
migrationBuilder.AddForeignKey(
name: "FK_LibraryFolder_LibraryFolder_ParentId",
table: "LibraryFolder",
column: "ParentId",
principalTable: "LibraryFolder",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_MediaFile_LibraryFolder_LibraryFolderId",
table: "MediaFile",
column: "LibraryFolderId",
principalTable: "LibraryFolder",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_LibraryFolder_LibraryFolder_ParentId",
table: "LibraryFolder");
migrationBuilder.DropForeignKey(
name: "FK_MediaFile_LibraryFolder_LibraryFolderId",
table: "MediaFile");
migrationBuilder.DropIndex(
name: "IX_MediaFile_LibraryFolderId",
table: "MediaFile");
migrationBuilder.DropIndex(
name: "IX_LibraryFolder_ParentId",
table: "LibraryFolder");
migrationBuilder.DropColumn(
name: "LibraryFolderId",
table: "MediaFile");
migrationBuilder.DropColumn(
name: "ParentId",
table: "LibraryFolder");
}
}
}