67 lines
2.4 KiB
C#
67 lines
2.4 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using NodaTime;
|
|
|
|
#nullable disable
|
|
|
|
namespace DysonNetwork.Drive.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddFileIndex : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "path",
|
|
table: "tasks",
|
|
type: "text",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "file_indexes",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
path = table.Column<string>(type: "character varying(8192)", maxLength: 8192, nullable: false),
|
|
file_id = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
|
|
account_id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
|
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
|
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("pk_file_indexes", x => x.id);
|
|
table.ForeignKey(
|
|
name: "fk_file_indexes_files_file_id",
|
|
column: x => x.file_id,
|
|
principalTable: "files",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "ix_file_indexes_file_id",
|
|
table: "file_indexes",
|
|
column: "file_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "ix_file_indexes_path_account_id",
|
|
table: "file_indexes",
|
|
columns: new[] { "path", "account_id" });
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "file_indexes");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "path",
|
|
table: "tasks");
|
|
}
|
|
}
|
|
}
|