irc-netcore-api/IRaCIS.Core.Infra.EFCore/Migrations/20260309095752_addDataSync.cs

168 lines
8.2 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace IRaCIS.Core.Infra.EFCore.Migrations
{
/// <inheritdoc />
public partial class addDataSync : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "TrialExtraConfigJsonStr",
table: "Trial",
type: "nvarchar(2000)",
maxLength: 2000,
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(1000)",
oldMaxLength: 1000);
migrationBuilder.AddColumn<int>(
name: "TrialDataStoreType",
table: "Trial",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "FileUploadRecord",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TrialId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
SubjectId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
SubjectVisitId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
FileName = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: false),
FileSize = table.Column<long>(type: "bigint", nullable: false),
FileType = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: false),
UploadRegion = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: false),
UploadFinishedTime = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "上传结束时间"),
Path = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: false),
FileMarkId = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: false, comment: "文件标识ID"),
IsNeedSync = table.Column<bool>(type: "bit", nullable: true, comment: "是否需要同步"),
IsSync = table.Column<bool>(type: "bit", nullable: true, comment: "是否已同步-最后一个任务的状态"),
syncFinishedTime = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "同步结束时间-最后一个任务的时间"),
IP = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: false),
CreateUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdateUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_FileUploadRecord", x => x.Id)
.Annotation("SqlServer:Clustered", false);
table.ForeignKey(
name: "FK_FileUploadRecord_SubjectVisit_SubjectVisitId",
column: x => x.SubjectVisitId,
principalTable: "SubjectVisit",
principalColumn: "Id");
table.ForeignKey(
name: "FK_FileUploadRecord_Subject_SubjectId",
column: x => x.SubjectId,
principalTable: "Subject",
principalColumn: "Id");
table.ForeignKey(
name: "FK_FileUploadRecord_Trial_TrialId",
column: x => x.TrialId,
principalTable: "Trial",
principalColumn: "Id");
table.ForeignKey(
name: "FK_FileUploadRecord_User_CreateUserId",
column: x => x.CreateUserId,
principalTable: "User",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
},
comment: "整个系统,上传记录表");
migrationBuilder.CreateTable(
name: "UploadFileSyncRecord",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
FileUploadRecordId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Priority = table.Column<int>(type: "int", nullable: false),
StartTime = table.Column<DateTime>(type: "datetime2", nullable: true),
EndTime = table.Column<DateTime>(type: "datetime2", nullable: true),
JobState = table.Column<int>(type: "int", nullable: false),
Msg = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: false),
CreateUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdateUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UploadFileSyncRecord", x => x.Id)
.Annotation("SqlServer:Clustered", false);
table.ForeignKey(
name: "FK_UploadFileSyncRecord_FileUploadRecord_FileUploadRecordId",
column: x => x.FileUploadRecordId,
principalTable: "FileUploadRecord",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UploadFileSyncRecord_User_CreateUserId",
column: x => x.CreateUserId,
principalTable: "User",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
},
comment: "同步任务记录表");
//migrationBuilder.CreateIndex(
// name: "IX_FileUploadRecord_CreateTime",
// table: "FileUploadRecord",
// column: "CreateTime")
// .Annotation("SqlServer:Clustered", true);
//migrationBuilder.CreateIndex(
// name: "IX_UploadFileSyncRecord_CreateTime",
// table: "UploadFileSyncRecord",
// column: "CreateTime")
// .Annotation("SqlServer:Clustered", true);
//migrationBuilder.AddForeignKey(
// name: "FK_Vacation_Doctor_DoctorId",
// table: "Vacation",
// column: "DoctorId",
// principalTable: "Doctor",
// principalColumn: "Id",
// onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Vacation_Doctor_DoctorId",
table: "Vacation");
migrationBuilder.DropTable(
name: "UploadFileSyncRecord");
migrationBuilder.DropTable(
name: "FileUploadRecord");
migrationBuilder.DropColumn(
name: "TrialDataStoreType",
table: "Trial");
migrationBuilder.AlterColumn<string>(
name: "TrialExtraConfigJsonStr",
table: "Trial",
type: "nvarchar(1000)",
maxLength: 1000,
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(2000)",
oldMaxLength: 2000);
}
}
}