using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace IRaCIS.Core.Infra.EFCore.Migrations { /// public partial class addDataSync : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterColumn( name: "TrialExtraConfigJsonStr", table: "Trial", type: "nvarchar(2000)", maxLength: 2000, nullable: false, oldClrType: typeof(string), oldType: "nvarchar(1000)", oldMaxLength: 1000); migrationBuilder.AddColumn( name: "TrialDataStoreType", table: "Trial", type: "int", nullable: false, defaultValue: 0); migrationBuilder.CreateTable( name: "FileUploadRecord", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), TrialId = table.Column(type: "uniqueidentifier", nullable: true), SubjectId = table.Column(type: "uniqueidentifier", nullable: true), SubjectVisitId = table.Column(type: "uniqueidentifier", nullable: true), FileName = table.Column(type: "nvarchar(400)", maxLength: 400, nullable: false), FileSize = table.Column(type: "bigint", nullable: false), FileType = table.Column(type: "nvarchar(400)", maxLength: 400, nullable: false), UploadRegion = table.Column(type: "nvarchar(400)", maxLength: 400, nullable: false), UploadFinishedTime = table.Column(type: "datetime2", nullable: false, comment: "上传结束时间"), Path = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: false), FileMarkId = table.Column(type: "nvarchar(400)", maxLength: 400, nullable: false, comment: "文件标识ID"), IsNeedSync = table.Column(type: "bit", nullable: true, comment: "是否需要同步"), IsSync = table.Column(type: "bit", nullable: true, comment: "是否已同步-最后一个任务的状态"), syncFinishedTime = table.Column(type: "datetime2", nullable: true, comment: "同步结束时间-最后一个任务的时间"), IP = table.Column(type: "nvarchar(400)", maxLength: 400, nullable: false), CreateUserId = table.Column(type: "uniqueidentifier", nullable: false), CreateTime = table.Column(type: "datetime2", nullable: false), UpdateUserId = table.Column(type: "uniqueidentifier", nullable: false), UpdateTime = table.Column(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(type: "uniqueidentifier", nullable: false), FileUploadRecordId = table.Column(type: "uniqueidentifier", nullable: false), Priority = table.Column(type: "int", nullable: false), StartTime = table.Column(type: "datetime2", nullable: true), EndTime = table.Column(type: "datetime2", nullable: true), JobState = table.Column(type: "int", nullable: false), Msg = table.Column(type: "nvarchar(400)", maxLength: 400, nullable: false), CreateUserId = table.Column(type: "uniqueidentifier", nullable: false), CreateTime = table.Column(type: "datetime2", nullable: false), UpdateUserId = table.Column(type: "uniqueidentifier", nullable: false), UpdateTime = table.Column(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); } /// 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( name: "TrialExtraConfigJsonStr", table: "Trial", type: "nvarchar(1000)", maxLength: 1000, nullable: false, oldClrType: typeof(string), oldType: "nvarchar(2000)", oldMaxLength: 2000); } } }