namespace WePlatform.Migrations { using System; using System.Collections.Generic; using System.Data.Entity.Infrastructure.Annotations; using System.Data.Entity.Migrations; public partial class UpdateRoleInfo : DbMigration { public override void Up() { DropForeignKey("dbo.WeBase_BehaviorRoles", "SceneCategory", "dbo.WeBase_SceneCategories"); DropIndex("dbo.WeBase_BehaviorRoles", new[] { "SceneCategory" }); CreateTable( "dbo.WeBase_BehaviorRoleRelateCategories", c => new { Id = c.Int(nullable: false, identity: true), RoleNo = c.String(maxLength: 128), CategoryNo = c.String(maxLength: 128), CreationTime = c.DateTime(nullable: false), CreatorUserId = c.Long(), }) .PrimaryKey(t => t.Id) .ForeignKey("dbo.Sys_Users", t => t.CreatorUserId) .ForeignKey("dbo.WeBase_BehaviorRoles", t => t.RoleNo) .ForeignKey("dbo.WeBase_SceneCategories", t => t.CategoryNo) .Index(t => t.RoleNo) .Index(t => t.CategoryNo) .Index(t => t.CreatorUserId); AlterTableAnnotations( "dbo.WeBase_BehaviorRoles", c => new { Id = c.String(nullable: false, maxLength: 128), RoleName = c.String(maxLength: 50), Description = c.String(maxLength: 500), Remark = c.String(maxLength: 500), IsDeleted = c.Boolean(nullable: false), DeleterUserId = c.Long(), DeletionTime = c.DateTime(), LastModificationTime = c.DateTime(), LastModifierUserId = c.Long(), CreationTime = c.DateTime(nullable: false), CreatorUserId = c.Long(), }, annotations: new Dictionary { { "DynamicFilter_BehaviorRoleInfo_SoftDelete", new AnnotationValues(oldValue: null, newValue: "EntityFramework.DynamicFilters.DynamicFilterDefinition") }, }); AddColumn("dbo.WeBase_BehaviorRoles", "IsDeleted", c => c.Boolean(nullable: false)); AddColumn("dbo.WeBase_BehaviorRoles", "DeleterUserId", c => c.Long()); AddColumn("dbo.WeBase_BehaviorRoles", "DeletionTime", c => c.DateTime()); CreateIndex("dbo.WeBase_BehaviorRoles", "IsDeleted"); CreateIndex("dbo.WeBase_BehaviorRoles", "DeleterUserId"); AddForeignKey("dbo.WeBase_BehaviorRoles", "DeleterUserId", "dbo.Sys_Users", "Id"); DropColumn("dbo.WeBase_BehaviorRoles", "SceneCategory"); } public override void Down() { AddColumn("dbo.WeBase_BehaviorRoles", "SceneCategory", c => c.String(maxLength: 128)); DropForeignKey("dbo.WeBase_BehaviorRoleRelateCategories", "CategoryNo", "dbo.WeBase_SceneCategories"); DropForeignKey("dbo.WeBase_BehaviorRoleRelateCategories", "RoleNo", "dbo.WeBase_BehaviorRoles"); DropForeignKey("dbo.WeBase_BehaviorRoleRelateCategories", "CreatorUserId", "dbo.Sys_Users"); DropForeignKey("dbo.WeBase_BehaviorRoles", "DeleterUserId", "dbo.Sys_Users"); DropIndex("dbo.WeBase_BehaviorRoleRelateCategories", new[] { "CreatorUserId" }); DropIndex("dbo.WeBase_BehaviorRoleRelateCategories", new[] { "CategoryNo" }); DropIndex("dbo.WeBase_BehaviorRoleRelateCategories", new[] { "RoleNo" }); DropIndex("dbo.WeBase_BehaviorRoles", new[] { "DeleterUserId" }); DropIndex("dbo.WeBase_BehaviorRoles", new[] { "IsDeleted" }); DropColumn("dbo.WeBase_BehaviorRoles", "DeletionTime"); DropColumn("dbo.WeBase_BehaviorRoles", "DeleterUserId"); DropColumn("dbo.WeBase_BehaviorRoles", "IsDeleted"); AlterTableAnnotations( "dbo.WeBase_BehaviorRoles", c => new { Id = c.String(nullable: false, maxLength: 128), RoleName = c.String(maxLength: 50), Description = c.String(maxLength: 500), Remark = c.String(maxLength: 500), IsDeleted = c.Boolean(nullable: false), DeleterUserId = c.Long(), DeletionTime = c.DateTime(), LastModificationTime = c.DateTime(), LastModifierUserId = c.Long(), CreationTime = c.DateTime(nullable: false), CreatorUserId = c.Long(), }, annotations: new Dictionary { { "DynamicFilter_BehaviorRoleInfo_SoftDelete", new AnnotationValues(oldValue: "EntityFramework.DynamicFilters.DynamicFilterDefinition", newValue: null) }, }); DropTable("dbo.WeBase_BehaviorRoleRelateCategories"); CreateIndex("dbo.WeBase_BehaviorRoles", "SceneCategory"); AddForeignKey("dbo.WeBase_BehaviorRoles", "SceneCategory", "dbo.WeBase_SceneCategories", "Id"); } } }