202008011027534_AddEmergencyPlan.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 AddEmergencyPlan : DbMigration
  8. {
  9. public override void Up()
  10. {
  11. CreateTable(
  12. "dbo.WeLib_EmergencyPlanContents",
  13. c => new
  14. {
  15. Id = c.Int(nullable: false, identity: true),
  16. PlanNo = c.String(maxLength: 128),
  17. PlanContent = c.String(),
  18. Version = c.String(),
  19. IsUse = c.Boolean(nullable: false),
  20. Remark = c.String(maxLength: 500),
  21. CreationTime = c.DateTime(nullable: false),
  22. CreatorUserId = c.Long(),
  23. })
  24. .PrimaryKey(t => t.Id)
  25. .ForeignKey("dbo.Sys_Users", t => t.CreatorUserId)
  26. .ForeignKey("dbo.WeLib_EmergencyPlans", t => t.PlanNo)
  27. .Index(t => t.PlanNo)
  28. .Index(t => t.CreatorUserId);
  29. CreateTable(
  30. "dbo.WeLib_EmergencyPlans",
  31. c => new
  32. {
  33. Id = c.String(nullable: false, maxLength: 128),
  34. ParentNo = c.String(maxLength: 128),
  35. Name = c.String(maxLength: 50),
  36. Path = c.String(maxLength: 1000),
  37. Sort = c.Int(nullable: false),
  38. Description = c.String(maxLength: 500),
  39. Remark = c.String(maxLength: 500),
  40. IsDeleted = c.Boolean(nullable: false),
  41. DeleterUserId = c.Long(),
  42. DeletionTime = c.DateTime(),
  43. LastModificationTime = c.DateTime(),
  44. LastModifierUserId = c.Long(),
  45. CreationTime = c.DateTime(nullable: false),
  46. CreatorUserId = c.Long(),
  47. },
  48. annotations: new Dictionary<string, object>
  49. {
  50. { "DynamicFilter_EmergencyPlanInfo_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  51. })
  52. .PrimaryKey(t => t.Id)
  53. .ForeignKey("dbo.Sys_Users", t => t.CreatorUserId)
  54. .ForeignKey("dbo.Sys_Users", t => t.DeleterUserId)
  55. .ForeignKey("dbo.Sys_Users", t => t.LastModifierUserId)
  56. .ForeignKey("dbo.WeLib_EmergencyPlans", t => t.ParentNo)
  57. .Index(t => t.ParentNo)
  58. .Index(t => t.IsDeleted)
  59. .Index(t => t.DeleterUserId)
  60. .Index(t => t.LastModifierUserId)
  61. .Index(t => t.CreatorUserId);
  62. CreateTable(
  63. "dbo.WeLib_EmergencyResources",
  64. c => new
  65. {
  66. Id = c.String(nullable: false, maxLength: 128),
  67. Name = c.String(maxLength: 50),
  68. Quantity = c.Decimal(nullable: false, precision: 18, scale: 2),
  69. Type = c.Int(),
  70. Description = c.String(maxLength: 500),
  71. Remark = c.String(maxLength: 500),
  72. IsDeleted = c.Boolean(nullable: false),
  73. DeleterUserId = c.Long(),
  74. DeletionTime = c.DateTime(),
  75. LastModificationTime = c.DateTime(),
  76. LastModifierUserId = c.Long(),
  77. CreationTime = c.DateTime(nullable: false),
  78. CreatorUserId = c.Long(),
  79. },
  80. annotations: new Dictionary<string, object>
  81. {
  82. { "DynamicFilter_EmergencyResourceInfo_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  83. })
  84. .PrimaryKey(t => t.Id)
  85. .ForeignKey("dbo.Sys_Users", t => t.CreatorUserId)
  86. .ForeignKey("dbo.Sys_Users", t => t.DeleterUserId)
  87. .ForeignKey("dbo.Sys_Users", t => t.LastModifierUserId)
  88. .Index(t => t.IsDeleted)
  89. .Index(t => t.DeleterUserId)
  90. .Index(t => t.LastModifierUserId)
  91. .Index(t => t.CreatorUserId);
  92. CreateTable(
  93. "dbo.WeLib_KnowledgeRelatePlans",
  94. c => new
  95. {
  96. Id = c.Int(nullable: false, identity: true),
  97. KnowledgeNo = c.String(maxLength: 128),
  98. PlanNo = c.String(maxLength: 128),
  99. CreationTime = c.DateTime(nullable: false),
  100. CreatorUserId = c.Long(),
  101. })
  102. .PrimaryKey(t => t.Id)
  103. .ForeignKey("dbo.Sys_Users", t => t.CreatorUserId)
  104. .ForeignKey("dbo.WeLib_Knowledges", t => t.KnowledgeNo)
  105. .ForeignKey("dbo.WeLib_EmergencyPlans", t => t.PlanNo)
  106. .Index(t => t.KnowledgeNo)
  107. .Index(t => t.PlanNo)
  108. .Index(t => t.CreatorUserId);
  109. }
  110. public override void Down()
  111. {
  112. DropForeignKey("dbo.WeLib_KnowledgeRelatePlans", "PlanNo", "dbo.WeLib_EmergencyPlans");
  113. DropForeignKey("dbo.WeLib_KnowledgeRelatePlans", "KnowledgeNo", "dbo.WeLib_Knowledges");
  114. DropForeignKey("dbo.WeLib_KnowledgeRelatePlans", "CreatorUserId", "dbo.Sys_Users");
  115. DropForeignKey("dbo.WeLib_EmergencyResources", "LastModifierUserId", "dbo.Sys_Users");
  116. DropForeignKey("dbo.WeLib_EmergencyResources", "DeleterUserId", "dbo.Sys_Users");
  117. DropForeignKey("dbo.WeLib_EmergencyResources", "CreatorUserId", "dbo.Sys_Users");
  118. DropForeignKey("dbo.WeLib_EmergencyPlanContents", "PlanNo", "dbo.WeLib_EmergencyPlans");
  119. DropForeignKey("dbo.WeLib_EmergencyPlans", "ParentNo", "dbo.WeLib_EmergencyPlans");
  120. DropForeignKey("dbo.WeLib_EmergencyPlans", "LastModifierUserId", "dbo.Sys_Users");
  121. DropForeignKey("dbo.WeLib_EmergencyPlans", "DeleterUserId", "dbo.Sys_Users");
  122. DropForeignKey("dbo.WeLib_EmergencyPlans", "CreatorUserId", "dbo.Sys_Users");
  123. DropForeignKey("dbo.WeLib_EmergencyPlanContents", "CreatorUserId", "dbo.Sys_Users");
  124. DropIndex("dbo.WeLib_KnowledgeRelatePlans", new[] { "CreatorUserId" });
  125. DropIndex("dbo.WeLib_KnowledgeRelatePlans", new[] { "PlanNo" });
  126. DropIndex("dbo.WeLib_KnowledgeRelatePlans", new[] { "KnowledgeNo" });
  127. DropIndex("dbo.WeLib_EmergencyResources", new[] { "CreatorUserId" });
  128. DropIndex("dbo.WeLib_EmergencyResources", new[] { "LastModifierUserId" });
  129. DropIndex("dbo.WeLib_EmergencyResources", new[] { "DeleterUserId" });
  130. DropIndex("dbo.WeLib_EmergencyResources", new[] { "IsDeleted" });
  131. DropIndex("dbo.WeLib_EmergencyPlans", new[] { "CreatorUserId" });
  132. DropIndex("dbo.WeLib_EmergencyPlans", new[] { "LastModifierUserId" });
  133. DropIndex("dbo.WeLib_EmergencyPlans", new[] { "DeleterUserId" });
  134. DropIndex("dbo.WeLib_EmergencyPlans", new[] { "IsDeleted" });
  135. DropIndex("dbo.WeLib_EmergencyPlans", new[] { "ParentNo" });
  136. DropIndex("dbo.WeLib_EmergencyPlanContents", new[] { "CreatorUserId" });
  137. DropIndex("dbo.WeLib_EmergencyPlanContents", new[] { "PlanNo" });
  138. DropTable("dbo.WeLib_KnowledgeRelatePlans");
  139. DropTable("dbo.WeLib_EmergencyResources",
  140. removedAnnotations: new Dictionary<string, object>
  141. {
  142. { "DynamicFilter_EmergencyResourceInfo_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  143. });
  144. DropTable("dbo.WeLib_EmergencyPlans",
  145. removedAnnotations: new Dictionary<string, object>
  146. {
  147. { "DynamicFilter_EmergencyPlanInfo_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  148. });
  149. DropTable("dbo.WeLib_EmergencyPlanContents");
  150. }
  151. }
  152. }