using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace IRaCIS.Core.Infra.EFCore.Migrations
{
    /// <inheritdoc />
    public partial class SegmentationVersion : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<long>(
                name: "FileSize",
                table: "Segmentation",
                type: "bigint",
                nullable: false,
                defaultValue: 0L);

            migrationBuilder.CreateTable(
                name: "SegmentationVersion",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    SegmentationId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Version = table.Column<int>(type: "int", nullable: false),
                    SegmentationJson = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    SEGUrl = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    FileSize = table.Column<long>(type: "bigint", nullable: false),
                    CreateUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SegmentationVersion", x => x.Id)
                        .Annotation("SqlServer:Clustered", false);
                
                },
                comment: "分割文件版本");

            migrationBuilder.CreateIndex(
                name: "IX_SegmentationVersion_CreateTime",
                table: "SegmentationVersion",
                column: "CreateTime")
                .Annotation("SqlServer:Clustered", true);

            migrationBuilder.AddForeignKey(
                name: "FK_Segmentation_VisitTask_VisitTaskId",
                table: "Segmentation",
                column: "VisitTaskId",
                principalTable: "VisitTask",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Segmentation_VisitTask_VisitTaskId",
                table: "Segmentation");

            migrationBuilder.DropTable(
                name: "SegmentationVersion");

            migrationBuilder.DropColumn(
                name: "FileSize",
                table: "Segmentation");
        }
    }
}
