103 lines
5.4 KiB
C#
103 lines
5.4 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace FileShare_EFCore.Migrations.SQLite
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddFileLibrary : 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("Sqlite:Autoincrement", true),
|
|
path = table.Column<string>(type: "TEXT", maxLength: 1024, nullable: false),
|
|
displayname = table.Column<string>(name: "display-name", type: "TEXT", maxLength: 200, nullable: false),
|
|
isenabled = table.Column<bool>(name: "is-enabled", type: "INTEGER", nullable: false),
|
|
isavailable = table.Column<bool>(name: "is-available", type: "INTEGER", 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: "TEXT", nullable: true),
|
|
lastscancompletedat = table.Column<DateTime>(name: "last-scan-completed-at", type: "TEXT", nullable: true),
|
|
lastscanerror = table.Column<string>(name: "last-scan-error", type: "TEXT", maxLength: 2000, nullable: true),
|
|
createdat = table.Column<DateTime>(name: "created-at", type: "TEXT", nullable: false),
|
|
updatedat = table.Column<DateTime>(name: "updated-at", type: "TEXT", 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("Sqlite:Autoincrement", true),
|
|
libraryrootid = table.Column<int>(name: "library-root-id", type: "INTEGER", nullable: false),
|
|
filename = table.Column<string>(name: "file-name", type: "TEXT", maxLength: 260, nullable: false),
|
|
relativepath = table.Column<string>(name: "relative-path", type: "TEXT", maxLength: 1024, nullable: false),
|
|
absolutepath = table.Column<string>(name: "absolute-path", type: "TEXT", maxLength: 2048, nullable: false),
|
|
extension = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
|
|
sizebytes = table.Column<long>(name: "size-bytes", type: "INTEGER", nullable: false),
|
|
lastwritetimeutc = table.Column<DateTime>(name: "last-write-time-utc", type: "TEXT", nullable: false),
|
|
mediatype = table.Column<string>(name: "media-type", type: "TEXT", maxLength: 20, nullable: false),
|
|
contenttype = table.Column<string>(name: "content-type", type: "TEXT", maxLength: 100, nullable: false),
|
|
exists = table.Column<bool>(type: "INTEGER", nullable: false),
|
|
lastseenat = table.Column<DateTime>(name: "last-seen-at", type: "TEXT", nullable: false),
|
|
createdat = table.Column<DateTime>(name: "created-at", type: "TEXT", nullable: false),
|
|
updatedat = table.Column<DateTime>(name: "updated-at", type: "TEXT", 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-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");
|
|
}
|
|
}
|
|
}
|