20230207035121_init.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace AuthServer.Migrations
  5. {
  6. public partial class init : Migration
  7. {
  8. protected override void Up(MigrationBuilder migrationBuilder)
  9. {
  10. migrationBuilder.AlterDatabase()
  11. .Annotation("MySql:CharSet", "utf8mb4");
  12. migrationBuilder.CreateTable(
  13. name: "OpenIddictApplications",
  14. columns: table => new
  15. {
  16. Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
  17. ClientId = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
  18. .Annotation("MySql:CharSet", "utf8mb4"),
  19. ClientSecret = table.Column<string>(type: "longtext", nullable: true)
  20. .Annotation("MySql:CharSet", "utf8mb4"),
  21. ConsentType = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
  22. .Annotation("MySql:CharSet", "utf8mb4"),
  23. DisplayName = table.Column<string>(type: "longtext", nullable: true)
  24. .Annotation("MySql:CharSet", "utf8mb4"),
  25. DisplayNames = table.Column<string>(type: "longtext", nullable: true)
  26. .Annotation("MySql:CharSet", "utf8mb4"),
  27. Permissions = table.Column<string>(type: "longtext", nullable: true)
  28. .Annotation("MySql:CharSet", "utf8mb4"),
  29. PostLogoutRedirectUris = table.Column<string>(type: "longtext", nullable: true)
  30. .Annotation("MySql:CharSet", "utf8mb4"),
  31. Properties = table.Column<string>(type: "longtext", nullable: true)
  32. .Annotation("MySql:CharSet", "utf8mb4"),
  33. RedirectUris = table.Column<string>(type: "longtext", nullable: true)
  34. .Annotation("MySql:CharSet", "utf8mb4"),
  35. Requirements = table.Column<string>(type: "longtext", nullable: true)
  36. .Annotation("MySql:CharSet", "utf8mb4"),
  37. Type = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
  38. .Annotation("MySql:CharSet", "utf8mb4"),
  39. ClientUri = table.Column<string>(type: "longtext", nullable: true)
  40. .Annotation("MySql:CharSet", "utf8mb4"),
  41. LogoUri = table.Column<string>(type: "longtext", nullable: true)
  42. .Annotation("MySql:CharSet", "utf8mb4"),
  43. ExtraProperties = table.Column<string>(type: "longtext", nullable: true)
  44. .Annotation("MySql:CharSet", "utf8mb4"),
  45. ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true)
  46. .Annotation("MySql:CharSet", "utf8mb4"),
  47. CreationTime = table.Column<DateTime>(type: "datetime", nullable: false),
  48. CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
  49. LastModificationTime = table.Column<DateTime>(type: "datetime", nullable: true),
  50. LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
  51. IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
  52. DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
  53. DeletionTime = table.Column<DateTime>(type: "datetime", nullable: true)
  54. },
  55. constraints: table =>
  56. {
  57. table.PrimaryKey("PK_OpenIddictApplications", x => x.Id);
  58. })
  59. .Annotation("MySql:CharSet", "utf8mb4");
  60. migrationBuilder.CreateTable(
  61. name: "OpenIddictScopes",
  62. columns: table => new
  63. {
  64. Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
  65. Description = table.Column<string>(type: "longtext", nullable: true)
  66. .Annotation("MySql:CharSet", "utf8mb4"),
  67. Descriptions = table.Column<string>(type: "longtext", nullable: true)
  68. .Annotation("MySql:CharSet", "utf8mb4"),
  69. DisplayName = table.Column<string>(type: "longtext", nullable: true)
  70. .Annotation("MySql:CharSet", "utf8mb4"),
  71. DisplayNames = table.Column<string>(type: "longtext", nullable: true)
  72. .Annotation("MySql:CharSet", "utf8mb4"),
  73. Name = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
  74. .Annotation("MySql:CharSet", "utf8mb4"),
  75. Properties = table.Column<string>(type: "longtext", nullable: true)
  76. .Annotation("MySql:CharSet", "utf8mb4"),
  77. Resources = table.Column<string>(type: "longtext", nullable: true)
  78. .Annotation("MySql:CharSet", "utf8mb4"),
  79. ExtraProperties = table.Column<string>(type: "longtext", nullable: true)
  80. .Annotation("MySql:CharSet", "utf8mb4"),
  81. ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true)
  82. .Annotation("MySql:CharSet", "utf8mb4"),
  83. CreationTime = table.Column<DateTime>(type: "datetime", nullable: false),
  84. CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
  85. LastModificationTime = table.Column<DateTime>(type: "datetime", nullable: true),
  86. LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
  87. IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
  88. DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
  89. DeletionTime = table.Column<DateTime>(type: "datetime", nullable: true)
  90. },
  91. constraints: table =>
  92. {
  93. table.PrimaryKey("PK_OpenIddictScopes", x => x.Id);
  94. })
  95. .Annotation("MySql:CharSet", "utf8mb4");
  96. migrationBuilder.CreateTable(
  97. name: "OpenIddictAuthorizations",
  98. columns: table => new
  99. {
  100. Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
  101. ApplicationId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
  102. CreationDate = table.Column<DateTime>(type: "datetime", nullable: true),
  103. Properties = table.Column<string>(type: "longtext", nullable: true)
  104. .Annotation("MySql:CharSet", "utf8mb4"),
  105. Scopes = table.Column<string>(type: "longtext", nullable: true)
  106. .Annotation("MySql:CharSet", "utf8mb4"),
  107. Status = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
  108. .Annotation("MySql:CharSet", "utf8mb4"),
  109. Subject = table.Column<string>(type: "varchar(400)", maxLength: 400, nullable: true)
  110. .Annotation("MySql:CharSet", "utf8mb4"),
  111. Type = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
  112. .Annotation("MySql:CharSet", "utf8mb4"),
  113. ExtraProperties = table.Column<string>(type: "longtext", nullable: true)
  114. .Annotation("MySql:CharSet", "utf8mb4"),
  115. ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true)
  116. .Annotation("MySql:CharSet", "utf8mb4"),
  117. CreationTime = table.Column<DateTime>(type: "datetime", nullable: false),
  118. CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
  119. LastModificationTime = table.Column<DateTime>(type: "datetime", nullable: true),
  120. LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
  121. IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
  122. DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
  123. DeletionTime = table.Column<DateTime>(type: "datetime", nullable: true)
  124. },
  125. constraints: table =>
  126. {
  127. table.PrimaryKey("PK_OpenIddictAuthorizations", x => x.Id);
  128. table.ForeignKey(
  129. name: "FK_OpenIddictAuthorizations_OpenIddictApplications_ApplicationId",
  130. column: x => x.ApplicationId,
  131. principalTable: "OpenIddictApplications",
  132. principalColumn: "Id");
  133. })
  134. .Annotation("MySql:CharSet", "utf8mb4");
  135. migrationBuilder.CreateTable(
  136. name: "OpenIddictTokens",
  137. columns: table => new
  138. {
  139. Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
  140. ApplicationId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
  141. AuthorizationId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
  142. CreationDate = table.Column<DateTime>(type: "datetime", nullable: true),
  143. ExpirationDate = table.Column<DateTime>(type: "datetime", nullable: true),
  144. Payload = table.Column<string>(type: "longtext", nullable: true)
  145. .Annotation("MySql:CharSet", "utf8mb4"),
  146. Properties = table.Column<string>(type: "longtext", nullable: true)
  147. .Annotation("MySql:CharSet", "utf8mb4"),
  148. RedemptionDate = table.Column<DateTime>(type: "datetime", nullable: true),
  149. ReferenceId = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
  150. .Annotation("MySql:CharSet", "utf8mb4"),
  151. Status = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
  152. .Annotation("MySql:CharSet", "utf8mb4"),
  153. Subject = table.Column<string>(type: "varchar(400)", maxLength: 400, nullable: true)
  154. .Annotation("MySql:CharSet", "utf8mb4"),
  155. Type = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
  156. .Annotation("MySql:CharSet", "utf8mb4"),
  157. ExtraProperties = table.Column<string>(type: "longtext", nullable: true)
  158. .Annotation("MySql:CharSet", "utf8mb4"),
  159. ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true)
  160. .Annotation("MySql:CharSet", "utf8mb4"),
  161. CreationTime = table.Column<DateTime>(type: "datetime", nullable: false),
  162. CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
  163. LastModificationTime = table.Column<DateTime>(type: "datetime", nullable: true),
  164. LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
  165. IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
  166. DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
  167. DeletionTime = table.Column<DateTime>(type: "datetime", nullable: true)
  168. },
  169. constraints: table =>
  170. {
  171. table.PrimaryKey("PK_OpenIddictTokens", x => x.Id);
  172. table.ForeignKey(
  173. name: "FK_OpenIddictTokens_OpenIddictApplications_ApplicationId",
  174. column: x => x.ApplicationId,
  175. principalTable: "OpenIddictApplications",
  176. principalColumn: "Id");
  177. table.ForeignKey(
  178. name: "FK_OpenIddictTokens_OpenIddictAuthorizations_AuthorizationId",
  179. column: x => x.AuthorizationId,
  180. principalTable: "OpenIddictAuthorizations",
  181. principalColumn: "Id");
  182. })
  183. .Annotation("MySql:CharSet", "utf8mb4");
  184. migrationBuilder.CreateIndex(
  185. name: "IX_OpenIddictApplications_ClientId",
  186. table: "OpenIddictApplications",
  187. column: "ClientId");
  188. migrationBuilder.CreateIndex(
  189. name: "IX_OpenIddictAuthorizations_ApplicationId_Status_Subject_Type",
  190. table: "OpenIddictAuthorizations",
  191. columns: new[] { "ApplicationId", "Status", "Subject", "Type" });
  192. migrationBuilder.CreateIndex(
  193. name: "IX_OpenIddictScopes_Name",
  194. table: "OpenIddictScopes",
  195. column: "Name");
  196. migrationBuilder.CreateIndex(
  197. name: "IX_OpenIddictTokens_ApplicationId_Status_Subject_Type",
  198. table: "OpenIddictTokens",
  199. columns: new[] { "ApplicationId", "Status", "Subject", "Type" });
  200. migrationBuilder.CreateIndex(
  201. name: "IX_OpenIddictTokens_AuthorizationId",
  202. table: "OpenIddictTokens",
  203. column: "AuthorizationId");
  204. migrationBuilder.CreateIndex(
  205. name: "IX_OpenIddictTokens_ReferenceId",
  206. table: "OpenIddictTokens",
  207. column: "ReferenceId");
  208. }
  209. protected override void Down(MigrationBuilder migrationBuilder)
  210. {
  211. migrationBuilder.DropTable(
  212. name: "OpenIddictScopes");
  213. migrationBuilder.DropTable(
  214. name: "OpenIddictTokens");
  215. migrationBuilder.DropTable(
  216. name: "OpenIddictAuthorizations");
  217. migrationBuilder.DropTable(
  218. name: "OpenIddictApplications");
  219. }
  220. }
  221. }