FileShare/FileShare-EFCore/Migrations/PostgreSQL/20260522082843_AutoMigration_20260522162758.cs
luoqian 2c20f9bb54 feat: 视频缩略图生成、最近文件面板与前端视图重构
- 新增 VideoThumbnailService,基于 ffmpeg 截取视频缩略图,ffprobe 提取时长
  - 新增 ManagedThumbnailMap 模型及多数据库迁移,存储缩略图元数据
  - 新增 /api/thumbnails/{id} 缩略图流端点
  - 新增最近添加/最近播放 API 与前端面板,支持列表/网格双视图切换
  - FileRecordDto 扩展 thumbnailUrl、videoDuration、lastPlayedAt 字段
  - 前端新增文件库 Tab 导航、卡片网格视图、视频海报与时长信息栏
  - 添加文件库目录不再同步全量扫描,改为后台异步自动扫描
2026-05-22 17:01:49 +08:00

112 lines
6.4 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace FileShare_EFCore.Migrations.PostgreSQL
{
/// <inheritdoc />
public partial class AutoMigration_20260522162758 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "managed-library-root",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
path = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: false),
displayname = table.Column<string>(name: "display-name", type: "character varying(200)", maxLength: 200, nullable: false),
isenabled = table.Column<bool>(name: "is-enabled", type: "boolean", nullable: false),
isavailable = table.Column<bool>(name: "is-available", type: "boolean", nullable: false, defaultValue: true),
scanintervalminutes = table.Column<int>(name: "scan-interval-minutes", type: "integer", nullable: false),
lastscanstartedat = table.Column<DateTime>(name: "last-scan-started-at", type: "timestamp with time zone", nullable: true),
lastscancompletedat = table.Column<DateTime>(name: "last-scan-completed-at", type: "timestamp with time zone", nullable: true),
lastscanerror = table.Column<string>(name: "last-scan-error", type: "character varying(2000)", maxLength: 2000, nullable: true),
createdat = table.Column<DateTime>(name: "created-at", type: "timestamp with time zone", nullable: false),
updatedat = table.Column<DateTime>(name: "updated-at", type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk-managed-library-root", x => x.id);
},
comment: "文件库根目录");
migrationBuilder.CreateTable(
name: "managed-file-record",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
libraryrootid = table.Column<int>(name: "library-root-id", type: "integer", nullable: false),
filename = table.Column<string>(name: "file-name", type: "character varying(260)", maxLength: 260, nullable: false),
relativepath = table.Column<string>(name: "relative-path", type: "character varying(1024)", maxLength: 1024, nullable: false),
absolutepath = table.Column<string>(name: "absolute-path", type: "character varying(2048)", maxLength: 2048, nullable: false),
extension = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
sizebytes = table.Column<long>(name: "size-bytes", type: "bigint", nullable: false),
lastwritetimeutc = table.Column<DateTime>(name: "last-write-time-utc", type: "timestamp with time zone", nullable: false),
mediatype = table.Column<string>(name: "media-type", type: "character varying(20)", maxLength: 20, nullable: false),
contenttype = table.Column<string>(name: "content-type", type: "character varying(100)", maxLength: 100, nullable: false),
exists = table.Column<bool>(type: "boolean", nullable: false),
lastseenat = table.Column<DateTime>(name: "last-seen-at", type: "timestamp with time zone", nullable: false),
thumbnailpath = table.Column<string>(name: "thumbnail-path", type: "character varying(512)", maxLength: 512, nullable: true),
videoduration = table.Column<double>(name: "video-duration", type: "double precision", nullable: true),
lastplayedat = table.Column<DateTime>(name: "last-played-at", type: "timestamp with time zone", nullable: true),
createdat = table.Column<DateTime>(name: "created-at", type: "timestamp with time zone", nullable: false),
updatedat = table.Column<DateTime>(name: "updated-at", type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk-managed-file-record", x => x.id);
table.ForeignKey(
name: "FK_managed-file-record_managed-library-root_library-root-id",
column: x => x.libraryrootid,
principalTable: "managed-library-root",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
},
comment: "文件库文件记录");
migrationBuilder.CreateIndex(
name: "idx-managed-file-record-absolute-path",
table: "managed-file-record",
column: "absolute-path",
unique: true);
migrationBuilder.CreateIndex(
name: "idx-managed-file-record-last-played-at",
table: "managed-file-record",
column: "last-played-at");
migrationBuilder.CreateIndex(
name: "idx-managed-file-record-media-type-exists",
table: "managed-file-record",
columns: new[] { "media-type", "exists" });
migrationBuilder.CreateIndex(
name: "idx-managed-file-record-root-id",
table: "managed-file-record",
column: "library-root-id");
migrationBuilder.CreateIndex(
name: "idx-managed-library-root-path",
table: "managed-library-root",
column: "path",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "managed-file-record");
migrationBuilder.DropTable(
name: "managed-library-root");
}
}
}