202006031658327_Update-database.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. namespace WePlatform.Migrations
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data.Entity.Infrastructure.Annotations;
  6. using System.Data.Entity.Migrations;
  7. public partial class Updatedatabase : DbMigration
  8. {
  9. public override void Up()
  10. {
  11. CreateTable(
  12. "dbo.WeBase_ThirdPartySystems",
  13. c => new
  14. {
  15. Id = c.String(nullable: false, maxLength: 128),
  16. Name = c.String(maxLength: 50),
  17. AppId = c.String(maxLength: 50),
  18. SecretKey = c.String(maxLength: 50),
  19. Description = c.String(maxLength: 500),
  20. IsSystem = c.Boolean(nullable: false),
  21. IsActive = c.Boolean(nullable: false),
  22. IsRegistered = c.Boolean(nullable: false),
  23. ExpiredDate = c.DateTime(),
  24. Remark = c.String(maxLength: 500),
  25. IsDeleted = c.Boolean(nullable: false),
  26. DeleterUserId = c.Long(),
  27. DeletionTime = c.DateTime(),
  28. LastModificationTime = c.DateTime(),
  29. LastModifierUserId = c.Long(),
  30. CreationTime = c.DateTime(nullable: false),
  31. CreatorUserId = c.Long(),
  32. },
  33. annotations: new Dictionary<string, object>
  34. {
  35. { "DynamicFilter_ThirdPartySystemInfo_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  36. })
  37. .PrimaryKey(t => t.Id)
  38. .ForeignKey("dbo.Sys_Users", t => t.CreatorUserId)
  39. .ForeignKey("dbo.Sys_Users", t => t.DeleterUserId)
  40. .ForeignKey("dbo.Sys_Users", t => t.LastModifierUserId)
  41. .Index(t => t.AppId, unique: true)
  42. .Index(t => t.IsDeleted)
  43. .Index(t => t.DeleterUserId)
  44. .Index(t => t.LastModifierUserId)
  45. .Index(t => t.CreatorUserId);
  46. AlterTableAnnotations(
  47. "dbo.Sys_AttachFiles",
  48. c => new
  49. {
  50. Id = c.Int(nullable: false, identity: true),
  51. AttachNo = c.String(maxLength: 32),
  52. TableName = c.String(maxLength: 50),
  53. ColumnName = c.String(maxLength: 50),
  54. SourceKey = c.String(maxLength: 50),
  55. FileTitle = c.String(maxLength: 50),
  56. FileName = c.String(maxLength: 50),
  57. FilePath = c.String(maxLength: 500),
  58. FileType = c.String(maxLength: 20),
  59. FileExt = c.String(maxLength: 10),
  60. Description = c.String(maxLength: 500),
  61. TenantId = c.Int(nullable: false),
  62. IsDeleted = c.Boolean(nullable: false),
  63. DeleterUserId = c.Long(),
  64. DeletionTime = c.DateTime(),
  65. LastModificationTime = c.DateTime(),
  66. LastModifierUserId = c.Long(),
  67. CreationTime = c.DateTime(nullable: false),
  68. CreatorUserId = c.Long(),
  69. },
  70. annotations: new Dictionary<string, AnnotationValues>
  71. {
  72. {
  73. "DynamicFilter_SysAttachFile_SoftDelete",
  74. new AnnotationValues(oldValue: null, newValue: "EntityFramework.DynamicFilters.DynamicFilterDefinition")
  75. },
  76. });
  77. AddColumn("dbo.WeLib_Packages", "AssessRoleNames", c => c.String(maxLength: 500));
  78. AddColumn("dbo.WeLib_PackagesXml", "AllRoles", c => c.String());
  79. AddColumn("dbo.Sys_AttachFiles", "IsDeleted", c => c.Boolean(nullable: false));
  80. AddColumn("dbo.Sys_AttachFiles", "DeleterUserId", c => c.Long());
  81. AddColumn("dbo.Sys_AttachFiles", "DeletionTime", c => c.DateTime());
  82. AddColumn("dbo.Sys_AttachFiles", "LastModificationTime", c => c.DateTime());
  83. AddColumn("dbo.Sys_AttachFiles", "LastModifierUserId", c => c.Long());
  84. AlterColumn("dbo.Sys_Functions", "Icon", c => c.String(maxLength: 50));
  85. CreateIndex("dbo.Sys_AttachFiles", "IsDeleted");
  86. CreateIndex("dbo.Sys_AttachFiles", "DeleterUserId");
  87. CreateIndex("dbo.Sys_AttachFiles", "LastModifierUserId");
  88. AddForeignKey("dbo.Sys_AttachFiles", "DeleterUserId", "dbo.Sys_Users", "Id");
  89. AddForeignKey("dbo.Sys_AttachFiles", "LastModifierUserId", "dbo.Sys_Users", "Id");
  90. }
  91. public override void Down()
  92. {
  93. DropForeignKey("dbo.WeBase_ThirdPartySystems", "LastModifierUserId", "dbo.Sys_Users");
  94. DropForeignKey("dbo.WeBase_ThirdPartySystems", "DeleterUserId", "dbo.Sys_Users");
  95. DropForeignKey("dbo.WeBase_ThirdPartySystems", "CreatorUserId", "dbo.Sys_Users");
  96. DropForeignKey("dbo.Sys_AttachFiles", "LastModifierUserId", "dbo.Sys_Users");
  97. DropForeignKey("dbo.Sys_AttachFiles", "DeleterUserId", "dbo.Sys_Users");
  98. DropIndex("dbo.WeBase_ThirdPartySystems", new[] { "CreatorUserId" });
  99. DropIndex("dbo.WeBase_ThirdPartySystems", new[] { "LastModifierUserId" });
  100. DropIndex("dbo.WeBase_ThirdPartySystems", new[] { "DeleterUserId" });
  101. DropIndex("dbo.WeBase_ThirdPartySystems", new[] { "IsDeleted" });
  102. DropIndex("dbo.WeBase_ThirdPartySystems", new[] { "AppId" });
  103. DropIndex("dbo.Sys_AttachFiles", new[] { "LastModifierUserId" });
  104. DropIndex("dbo.Sys_AttachFiles", new[] { "DeleterUserId" });
  105. DropIndex("dbo.Sys_AttachFiles", new[] { "IsDeleted" });
  106. AlterColumn("dbo.Sys_Functions", "Icon", c => c.String(maxLength: 20));
  107. DropColumn("dbo.Sys_AttachFiles", "LastModifierUserId");
  108. DropColumn("dbo.Sys_AttachFiles", "LastModificationTime");
  109. DropColumn("dbo.Sys_AttachFiles", "DeletionTime");
  110. DropColumn("dbo.Sys_AttachFiles", "DeleterUserId");
  111. DropColumn("dbo.Sys_AttachFiles", "IsDeleted");
  112. DropColumn("dbo.WeLib_PackagesXml", "AllRoles");
  113. DropColumn("dbo.WeLib_Packages", "AssessRoleNames");
  114. AlterTableAnnotations(
  115. "dbo.Sys_AttachFiles",
  116. c => new
  117. {
  118. Id = c.Int(nullable: false, identity: true),
  119. AttachNo = c.String(maxLength: 32),
  120. TableName = c.String(maxLength: 50),
  121. ColumnName = c.String(maxLength: 50),
  122. SourceKey = c.String(maxLength: 50),
  123. FileTitle = c.String(maxLength: 50),
  124. FileName = c.String(maxLength: 50),
  125. FilePath = c.String(maxLength: 500),
  126. FileType = c.String(maxLength: 20),
  127. FileExt = c.String(maxLength: 10),
  128. Description = c.String(maxLength: 500),
  129. TenantId = c.Int(nullable: false),
  130. IsDeleted = c.Boolean(nullable: false),
  131. DeleterUserId = c.Long(),
  132. DeletionTime = c.DateTime(),
  133. LastModificationTime = c.DateTime(),
  134. LastModifierUserId = c.Long(),
  135. CreationTime = c.DateTime(nullable: false),
  136. CreatorUserId = c.Long(),
  137. },
  138. annotations: new Dictionary<string, AnnotationValues>
  139. {
  140. {
  141. "DynamicFilter_SysAttachFile_SoftDelete",
  142. new AnnotationValues(oldValue: "EntityFramework.DynamicFilters.DynamicFilterDefinition", newValue: null)
  143. },
  144. });
  145. DropTable("dbo.WeBase_ThirdPartySystems",
  146. removedAnnotations: new Dictionary<string, object>
  147. {
  148. { "DynamicFilter_ThirdPartySystemInfo_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  149. });
  150. }
  151. }
  152. }