using System;
using Microsoft.EntityFrameworkCore.Migrations;
using MySql.EntityFrameworkCore.Metadata;
#nullable disable
namespace FileShare_EFCore.Migrations.MySQL
{
///
public partial class AddThumbnailMap : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "thumbnail-path",
table: "managed-file-record");
migrationBuilder.AddColumn(
name: "thumbnail-id",
table: "managed-file-record",
type: "int",
nullable: true);
migrationBuilder.CreateTable(
name: "managed-thumbnail-map",
columns: table => new
{
id = table.Column(type: "int", nullable: false)
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
libraryrootid = table.Column(name: "library-root-id", type: "int", nullable: false),
relativepath = table.Column(name: "relative-path", type: "varchar(1024)", maxLength: 1024, nullable: false),
contenttype = table.Column(name: "content-type", type: "varchar(100)", maxLength: 100, nullable: false),
createdat = table.Column(name: "created-at", type: "datetime(6)", nullable: false),
updatedat = table.Column(name: "updated-at", type: "datetime(6)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk-managed-thumbnail-map", x => x.id);
table.ForeignKey(
name: "FK_managed-thumbnail-map_managed-library-root_library-root-id",
column: x => x.libraryrootid,
principalTable: "managed-library-root",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
},
comment: "文件缩略图映射记录")
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateIndex(
name: "idx-managed-file-record-thumbnail-id",
table: "managed-file-record",
column: "thumbnail-id");
migrationBuilder.CreateIndex(
name: "idx-managed-thumbnail-map-relative-path",
table: "managed-thumbnail-map",
column: "relative-path",
unique: true);
migrationBuilder.CreateIndex(
name: "idx-managed-thumbnail-map-root-id",
table: "managed-thumbnail-map",
column: "library-root-id");
migrationBuilder.AddForeignKey(
name: "FK_managed-file-record_managed-thumbnail-map_thumbnail-id",
table: "managed-file-record",
column: "thumbnail-id",
principalTable: "managed-thumbnail-map",
principalColumn: "id",
onDelete: ReferentialAction.SetNull);
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_managed-file-record_managed-thumbnail-map_thumbnail-id",
table: "managed-file-record");
migrationBuilder.DropTable(
name: "managed-thumbnail-map");
migrationBuilder.DropIndex(
name: "idx-managed-file-record-thumbnail-id",
table: "managed-file-record");
migrationBuilder.DropColumn(
name: "thumbnail-id",
table: "managed-file-record");
migrationBuilder.AddColumn(
name: "thumbnail-path",
table: "managed-file-record",
type: "varchar(512)",
maxLength: 512,
nullable: true);
}
}
}