82 lines
3.3 KiB
C#
82 lines
3.3 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace PageManager.Api.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddBookFiles : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "book_files",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
book_id = table.Column<int>(type: "integer", nullable: true),
|
|
edition_id = table.Column<int>(type: "integer", nullable: true),
|
|
source_id = table.Column<string>(type: "text", nullable: true),
|
|
path = table.Column<string>(type: "text", nullable: false),
|
|
filename = table.Column<string>(type: "text", nullable: false),
|
|
size_bytes = table.Column<long>(type: "bigint", nullable: false),
|
|
format = table.Column<string>(type: "text", nullable: false),
|
|
hash = table.Column<string>(type: "text", nullable: true),
|
|
added_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("pk_book_files", x => x.id);
|
|
table.ForeignKey(
|
|
name: "fk_book_files_books_book_id",
|
|
column: x => x.book_id,
|
|
principalTable: "books",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
table.ForeignKey(
|
|
name: "fk_book_files_editions_edition_id",
|
|
column: x => x.edition_id,
|
|
principalTable: "editions",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
table.ForeignKey(
|
|
name: "fk_book_files_import_sources_source_id",
|
|
column: x => x.source_id,
|
|
principalTable: "import_sources",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "ix_book_files_book_id",
|
|
table: "book_files",
|
|
column: "book_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "ix_book_files_edition_id",
|
|
table: "book_files",
|
|
column: "edition_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "ix_book_files_hash",
|
|
table: "book_files",
|
|
column: "hash");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "ix_book_files_source_id",
|
|
table: "book_files",
|
|
column: "source_id");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(name: "book_files");
|
|
}
|
|
}
|
|
}
|