using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace IRaCIS.Core.Infra.EFCore.Migrations { /// public partial class UserlogModifg7 : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_UserLog_User_LoginUserId", table: "UserLog"); migrationBuilder.DropForeignKey( name: "FK_UserLog_User_OptUserId", table: "UserLog"); //migrationBuilder.DropIndex( // name: "IX_UserLog_LoginUserId", // table: "UserLog"); //migrationBuilder.DropIndex( // name: "IX_UserLog_OptUserId", // table: "UserLog"); migrationBuilder.AlterColumn( name: "OptUserId", table: "UserLog", type: "uniqueidentifier", nullable: true, comment: "被操作的人,自己操作的就是自己--后续删除", oldClrType: typeof(Guid), oldType: "uniqueidentifier", oldNullable: true, oldComment: "被操作的人,自己操作的就是自己"); //migrationBuilder.AlterColumn( // name: "LoginUserId", // table: "UserLog", // type: "uniqueidentifier", // nullable: true, // comment: "后续删除", // oldClrType: typeof(Guid), // oldType: "uniqueidentifier", // oldNullable: true); migrationBuilder.AddColumn( name: "ActionIdentityUserId", table: "UserLog", type: "uniqueidentifier", nullable: true); migrationBuilder.AddColumn( name: "ActionUserName", table: "UserLog", type: "nvarchar(400)", maxLength: 400, nullable: false, defaultValue: ""); //migrationBuilder.AddColumn( // name: "JsonObj", // table: "UserLog", // type: "nvarchar(max)", // nullable: false, // defaultValue: ""); migrationBuilder.AddColumn( name: "TargetIdentityUserId", table: "UserLog", type: "uniqueidentifier", nullable: true, comment: "被操作的对象 admin 修改张三信息 张三是被操作对象"); //migrationBuilder.AlterColumn( // name: "SystemUserId", // table: "TrialSiteUserSurvey", // type: "uniqueidentifier", // nullable: true, // comment: "IdentityUser 表的用户Id", // oldClrType: typeof(Guid), // oldType: "uniqueidentifier", // oldNullable: true); //migrationBuilder.AlterColumn( // name: "SystemUserId", // table: "TrialExternalUser", // type: "uniqueidentifier", // nullable: false, // comment: "IdentityUser 表的用户Id", // oldClrType: typeof(Guid), // oldType: "uniqueidentifier"); //migrationBuilder.AlterColumn( // name: "AutoCutNextTask", // table: "IdentityUser", // type: "bit", // nullable: false, // comment: "这个字段废除,放在用户角色上面,后续删除", // oldClrType: typeof(bool), // oldType: "bit", // oldComment: "自动切换下一个任务"); //migrationBuilder.CreateIndex( // name: "IX_UserLog_TargetIdentityUserId", // table: "UserLog", // column: "TargetIdentityUserId"); //migrationBuilder.AddForeignKey( // name: "FK_UserLog_IdentityUser_TargetIdentityUserId", // table: "UserLog", // column: "TargetIdentityUserId", // principalTable: "IdentityUser", // principalColumn: "Id"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_UserLog_IdentityUser_TargetIdentityUserId", table: "UserLog"); migrationBuilder.DropIndex( name: "IX_UserLog_TargetIdentityUserId", table: "UserLog"); migrationBuilder.DropColumn( name: "ActionIdentityUserId", table: "UserLog"); migrationBuilder.DropColumn( name: "ActionUserName", table: "UserLog"); migrationBuilder.DropColumn( name: "JsonObj", table: "UserLog"); migrationBuilder.DropColumn( name: "TargetIdentityUserId", table: "UserLog"); migrationBuilder.AlterColumn( name: "OptUserId", table: "UserLog", type: "uniqueidentifier", nullable: true, comment: "被操作的人,自己操作的就是自己", oldClrType: typeof(Guid), oldType: "uniqueidentifier", oldNullable: true, oldComment: "被操作的人,自己操作的就是自己--后续删除"); migrationBuilder.AlterColumn( name: "LoginUserId", table: "UserLog", type: "uniqueidentifier", nullable: true, oldClrType: typeof(Guid), oldType: "uniqueidentifier", oldNullable: true, oldComment: "后续删除"); migrationBuilder.AlterColumn( name: "SystemUserId", table: "TrialSiteUserSurvey", type: "uniqueidentifier", nullable: true, oldClrType: typeof(Guid), oldType: "uniqueidentifier", oldNullable: true, oldComment: "IdentityUser 表的用户Id"); migrationBuilder.AlterColumn( name: "SystemUserId", table: "TrialExternalUser", type: "uniqueidentifier", nullable: false, oldClrType: typeof(Guid), oldType: "uniqueidentifier", oldComment: "IdentityUser 表的用户Id"); migrationBuilder.AlterColumn( name: "AutoCutNextTask", table: "IdentityUser", type: "bit", nullable: false, comment: "自动切换下一个任务", oldClrType: typeof(bool), oldType: "bit", oldComment: "这个字段废除,放在用户角色上面,后续删除"); migrationBuilder.CreateIndex( name: "IX_UserLog_LoginUserId", table: "UserLog", column: "LoginUserId"); migrationBuilder.CreateIndex( name: "IX_UserLog_OptUserId", table: "UserLog", column: "OptUserId"); migrationBuilder.AddForeignKey( name: "FK_UserLog_User_LoginUserId", table: "UserLog", column: "LoginUserId", principalTable: "User", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_UserLog_User_OptUserId", table: "UserLog", column: "OptUserId", principalTable: "User", principalColumn: "Id"); } } }