131 lines
4.7 KiB
C#
131 lines
4.7 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Lactose.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddIncrementalScanState : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Assets_FolderId",
|
|
table: "Assets");
|
|
|
|
migrationBuilder.AddColumn<DateTime>(
|
|
name: "LastDiscoveryScanAt",
|
|
table: "Folders",
|
|
type: "timestamp with time zone",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "LastDiscoveryScannedRegex",
|
|
table: "Folders",
|
|
type: "VARCHAR(2048)",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<DateTime>(
|
|
name: "LastFileScanAt",
|
|
table: "Folders",
|
|
type: "timestamp with time zone",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "AssetAlbumStaging",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
AssetId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
PersonName = table.Column<string>(type: "VARCHAR(255)", nullable: false),
|
|
AlbumName = table.Column<string>(type: "VARCHAR(255)", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_AssetAlbumStaging", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_AssetAlbumStaging_Assets_AssetId",
|
|
column: x => x.AssetId,
|
|
principalTable: "Assets",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "DirectoryScanStates",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
FolderId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Path = table.Column<string>(type: "VARCHAR(2048)", nullable: false),
|
|
LastMtime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_DirectoryScanStates", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_DirectoryScanStates_Folders_FolderId",
|
|
column: x => x.FolderId,
|
|
principalTable: "Folders",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Assets_FolderId_Id",
|
|
table: "Assets",
|
|
columns: new[] { "FolderId", "Id" },
|
|
filter: "\"DeletedAt\" IS NULL");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_AssetAlbumStaging_AssetId",
|
|
table: "AssetAlbumStaging",
|
|
column: "AssetId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_AssetAlbumStaging_PersonName",
|
|
table: "AssetAlbumStaging",
|
|
column: "PersonName");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DirectoryScanStates_FolderId_Path",
|
|
table: "DirectoryScanStates",
|
|
columns: new[] { "FolderId", "Path" },
|
|
unique: true);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "AssetAlbumStaging");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "DirectoryScanStates");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Assets_FolderId_Id",
|
|
table: "Assets");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "LastDiscoveryScanAt",
|
|
table: "Folders");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "LastDiscoveryScannedRegex",
|
|
table: "Folders");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "LastFileScanAt",
|
|
table: "Folders");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Assets_FolderId",
|
|
table: "Assets",
|
|
column: "FolderId");
|
|
}
|
|
}
|
|
}
|