20230529172444_QAInit.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace AuthServer.Host.Migrations
  5. {
  6. public partial class QAInit : Migration
  7. {
  8. protected override void Up(MigrationBuilder migrationBuilder)
  9. {
  10. migrationBuilder.CreateTable(
  11. name: "IdentityServerApiResources",
  12. columns: table => new
  13. {
  14. Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  15. Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
  16. DisplayName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
  17. Description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
  18. Enabled = table.Column<bool>(type: "bit", nullable: false),
  19. AllowedAccessTokenSigningAlgorithms = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
  20. ShowInDiscoveryDocument = table.Column<bool>(type: "bit", nullable: false),
  21. ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
  22. ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
  23. CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
  24. CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
  25. LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
  26. LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
  27. IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
  28. DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
  29. DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true)
  30. },
  31. constraints: table =>
  32. {
  33. table.PrimaryKey("PK_IdentityServerApiResources", x => x.Id);
  34. });
  35. migrationBuilder.CreateTable(
  36. name: "IdentityServerApiScopes",
  37. columns: table => new
  38. {
  39. Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  40. Enabled = table.Column<bool>(type: "bit", nullable: false),
  41. Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
  42. DisplayName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
  43. Description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
  44. Required = table.Column<bool>(type: "bit", nullable: false),
  45. Emphasize = table.Column<bool>(type: "bit", nullable: false),
  46. ShowInDiscoveryDocument = table.Column<bool>(type: "bit", nullable: false),
  47. ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
  48. ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
  49. CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
  50. CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
  51. LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
  52. LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
  53. IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
  54. DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
  55. DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true)
  56. },
  57. constraints: table =>
  58. {
  59. table.PrimaryKey("PK_IdentityServerApiScopes", x => x.Id);
  60. });
  61. migrationBuilder.CreateTable(
  62. name: "IdentityServerClients",
  63. columns: table => new
  64. {
  65. Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  66. ClientId = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
  67. ClientName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
  68. Description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
  69. ClientUri = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true),
  70. LogoUri = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true),
  71. Enabled = table.Column<bool>(type: "bit", nullable: false),
  72. ProtocolType = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
  73. RequireClientSecret = table.Column<bool>(type: "bit", nullable: false),
  74. RequireConsent = table.Column<bool>(type: "bit", nullable: false),
  75. AllowRememberConsent = table.Column<bool>(type: "bit", nullable: false),
  76. AlwaysIncludeUserClaimsInIdToken = table.Column<bool>(type: "bit", nullable: false),
  77. RequirePkce = table.Column<bool>(type: "bit", nullable: false),
  78. AllowPlainTextPkce = table.Column<bool>(type: "bit", nullable: false),
  79. RequireRequestObject = table.Column<bool>(type: "bit", nullable: false),
  80. AllowAccessTokensViaBrowser = table.Column<bool>(type: "bit", nullable: false),
  81. FrontChannelLogoutUri = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true),
  82. FrontChannelLogoutSessionRequired = table.Column<bool>(type: "bit", nullable: false),
  83. BackChannelLogoutUri = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true),
  84. BackChannelLogoutSessionRequired = table.Column<bool>(type: "bit", nullable: false),
  85. AllowOfflineAccess = table.Column<bool>(type: "bit", nullable: false),
  86. IdentityTokenLifetime = table.Column<int>(type: "int", nullable: false),
  87. AllowedIdentityTokenSigningAlgorithms = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
  88. AccessTokenLifetime = table.Column<int>(type: "int", nullable: false),
  89. AuthorizationCodeLifetime = table.Column<int>(type: "int", nullable: false),
  90. ConsentLifetime = table.Column<int>(type: "int", nullable: true),
  91. AbsoluteRefreshTokenLifetime = table.Column<int>(type: "int", nullable: false),
  92. SlidingRefreshTokenLifetime = table.Column<int>(type: "int", nullable: false),
  93. RefreshTokenUsage = table.Column<int>(type: "int", nullable: false),
  94. UpdateAccessTokenClaimsOnRefresh = table.Column<bool>(type: "bit", nullable: false),
  95. RefreshTokenExpiration = table.Column<int>(type: "int", nullable: false),
  96. AccessTokenType = table.Column<int>(type: "int", nullable: false),
  97. EnableLocalLogin = table.Column<bool>(type: "bit", nullable: false),
  98. IncludeJwtId = table.Column<bool>(type: "bit", nullable: false),
  99. AlwaysSendClientClaims = table.Column<bool>(type: "bit", nullable: false),
  100. ClientClaimsPrefix = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
  101. PairWiseSubjectSalt = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
  102. UserSsoLifetime = table.Column<int>(type: "int", nullable: true),
  103. UserCodeType = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
  104. DeviceCodeLifetime = table.Column<int>(type: "int", nullable: false),
  105. ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
  106. ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
  107. CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
  108. CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
  109. LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
  110. LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
  111. IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
  112. DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
  113. DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true)
  114. },
  115. constraints: table =>
  116. {
  117. table.PrimaryKey("PK_IdentityServerClients", x => x.Id);
  118. });
  119. migrationBuilder.CreateTable(
  120. name: "IdentityServerDeviceFlowCodes",
  121. columns: table => new
  122. {
  123. Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  124. DeviceCode = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
  125. UserCode = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
  126. SubjectId = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
  127. SessionId = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
  128. ClientId = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
  129. Description = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
  130. Expiration = table.Column<DateTime>(type: "datetime2", nullable: false),
  131. Data = table.Column<string>(type: "nvarchar(max)", maxLength: 50000, nullable: false),
  132. ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
  133. ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
  134. CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
  135. CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
  136. },
  137. constraints: table =>
  138. {
  139. table.PrimaryKey("PK_IdentityServerDeviceFlowCodes", x => x.Id);
  140. });
  141. migrationBuilder.CreateTable(
  142. name: "IdentityServerIdentityResources",
  143. columns: table => new
  144. {
  145. Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  146. Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
  147. DisplayName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
  148. Description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
  149. Enabled = table.Column<bool>(type: "bit", nullable: false),
  150. Required = table.Column<bool>(type: "bit", nullable: false),
  151. Emphasize = table.Column<bool>(type: "bit", nullable: false),
  152. ShowInDiscoveryDocument = table.Column<bool>(type: "bit", nullable: false),
  153. ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
  154. ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
  155. CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
  156. CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
  157. LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
  158. LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
  159. IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
  160. DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
  161. DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true)
  162. },
  163. constraints: table =>
  164. {
  165. table.PrimaryKey("PK_IdentityServerIdentityResources", x => x.Id);
  166. });
  167. migrationBuilder.CreateTable(
  168. name: "IdentityServerPersistedGrants",
  169. columns: table => new
  170. {
  171. Key = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
  172. Type = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
  173. SubjectId = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
  174. SessionId = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
  175. ClientId = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
  176. Description = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
  177. CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
  178. Expiration = table.Column<DateTime>(type: "datetime2", nullable: true),
  179. ConsumedTime = table.Column<DateTime>(type: "datetime2", nullable: true),
  180. Data = table.Column<string>(type: "nvarchar(max)", maxLength: 50000, nullable: false),
  181. Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  182. ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
  183. ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true)
  184. },
  185. constraints: table =>
  186. {
  187. table.PrimaryKey("PK_IdentityServerPersistedGrants", x => x.Key);
  188. });
  189. migrationBuilder.CreateTable(
  190. name: "IdentityServerApiResourceClaims",
  191. columns: table => new
  192. {
  193. Type = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
  194. ApiResourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
  195. },
  196. constraints: table =>
  197. {
  198. table.PrimaryKey("PK_IdentityServerApiResourceClaims", x => new { x.ApiResourceId, x.Type });
  199. table.ForeignKey(
  200. name: "FK_IdentityServerApiResourceClaims_IdentityServerApiResources_ApiResourceId",
  201. column: x => x.ApiResourceId,
  202. principalTable: "IdentityServerApiResources",
  203. principalColumn: "Id",
  204. onDelete: ReferentialAction.Cascade);
  205. });
  206. migrationBuilder.CreateTable(
  207. name: "IdentityServerApiResourceProperties",
  208. columns: table => new
  209. {
  210. ApiResourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  211. Key = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  212. Value = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false)
  213. },
  214. constraints: table =>
  215. {
  216. table.PrimaryKey("PK_IdentityServerApiResourceProperties", x => new { x.ApiResourceId, x.Key, x.Value });
  217. table.ForeignKey(
  218. name: "FK_IdentityServerApiResourceProperties_IdentityServerApiResources_ApiResourceId",
  219. column: x => x.ApiResourceId,
  220. principalTable: "IdentityServerApiResources",
  221. principalColumn: "Id",
  222. onDelete: ReferentialAction.Cascade);
  223. });
  224. migrationBuilder.CreateTable(
  225. name: "IdentityServerApiResourceScopes",
  226. columns: table => new
  227. {
  228. ApiResourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  229. Scope = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false)
  230. },
  231. constraints: table =>
  232. {
  233. table.PrimaryKey("PK_IdentityServerApiResourceScopes", x => new { x.ApiResourceId, x.Scope });
  234. table.ForeignKey(
  235. name: "FK_IdentityServerApiResourceScopes_IdentityServerApiResources_ApiResourceId",
  236. column: x => x.ApiResourceId,
  237. principalTable: "IdentityServerApiResources",
  238. principalColumn: "Id",
  239. onDelete: ReferentialAction.Cascade);
  240. });
  241. migrationBuilder.CreateTable(
  242. name: "IdentityServerApiResourceSecrets",
  243. columns: table => new
  244. {
  245. Type = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  246. Value = table.Column<string>(type: "nvarchar(4000)", maxLength: 4000, nullable: false),
  247. ApiResourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  248. Description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
  249. Expiration = table.Column<DateTime>(type: "datetime2", nullable: true)
  250. },
  251. constraints: table =>
  252. {
  253. table.PrimaryKey("PK_IdentityServerApiResourceSecrets", x => new { x.ApiResourceId, x.Type, x.Value });
  254. table.ForeignKey(
  255. name: "FK_IdentityServerApiResourceSecrets_IdentityServerApiResources_ApiResourceId",
  256. column: x => x.ApiResourceId,
  257. principalTable: "IdentityServerApiResources",
  258. principalColumn: "Id",
  259. onDelete: ReferentialAction.Cascade);
  260. });
  261. migrationBuilder.CreateTable(
  262. name: "IdentityServerApiScopeClaims",
  263. columns: table => new
  264. {
  265. Type = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
  266. ApiScopeId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
  267. },
  268. constraints: table =>
  269. {
  270. table.PrimaryKey("PK_IdentityServerApiScopeClaims", x => new { x.ApiScopeId, x.Type });
  271. table.ForeignKey(
  272. name: "FK_IdentityServerApiScopeClaims_IdentityServerApiScopes_ApiScopeId",
  273. column: x => x.ApiScopeId,
  274. principalTable: "IdentityServerApiScopes",
  275. principalColumn: "Id",
  276. onDelete: ReferentialAction.Cascade);
  277. });
  278. migrationBuilder.CreateTable(
  279. name: "IdentityServerApiScopeProperties",
  280. columns: table => new
  281. {
  282. ApiScopeId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  283. Key = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  284. Value = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false)
  285. },
  286. constraints: table =>
  287. {
  288. table.PrimaryKey("PK_IdentityServerApiScopeProperties", x => new { x.ApiScopeId, x.Key, x.Value });
  289. table.ForeignKey(
  290. name: "FK_IdentityServerApiScopeProperties_IdentityServerApiScopes_ApiScopeId",
  291. column: x => x.ApiScopeId,
  292. principalTable: "IdentityServerApiScopes",
  293. principalColumn: "Id",
  294. onDelete: ReferentialAction.Cascade);
  295. });
  296. migrationBuilder.CreateTable(
  297. name: "IdentityServerClientClaims",
  298. columns: table => new
  299. {
  300. ClientId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  301. Type = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  302. Value = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false)
  303. },
  304. constraints: table =>
  305. {
  306. table.PrimaryKey("PK_IdentityServerClientClaims", x => new { x.ClientId, x.Type, x.Value });
  307. table.ForeignKey(
  308. name: "FK_IdentityServerClientClaims_IdentityServerClients_ClientId",
  309. column: x => x.ClientId,
  310. principalTable: "IdentityServerClients",
  311. principalColumn: "Id",
  312. onDelete: ReferentialAction.Cascade);
  313. });
  314. migrationBuilder.CreateTable(
  315. name: "IdentityServerClientCorsOrigins",
  316. columns: table => new
  317. {
  318. ClientId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  319. Origin = table.Column<string>(type: "nvarchar(150)", maxLength: 150, nullable: false)
  320. },
  321. constraints: table =>
  322. {
  323. table.PrimaryKey("PK_IdentityServerClientCorsOrigins", x => new { x.ClientId, x.Origin });
  324. table.ForeignKey(
  325. name: "FK_IdentityServerClientCorsOrigins_IdentityServerClients_ClientId",
  326. column: x => x.ClientId,
  327. principalTable: "IdentityServerClients",
  328. principalColumn: "Id",
  329. onDelete: ReferentialAction.Cascade);
  330. });
  331. migrationBuilder.CreateTable(
  332. name: "IdentityServerClientGrantTypes",
  333. columns: table => new
  334. {
  335. ClientId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  336. GrantType = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false)
  337. },
  338. constraints: table =>
  339. {
  340. table.PrimaryKey("PK_IdentityServerClientGrantTypes", x => new { x.ClientId, x.GrantType });
  341. table.ForeignKey(
  342. name: "FK_IdentityServerClientGrantTypes_IdentityServerClients_ClientId",
  343. column: x => x.ClientId,
  344. principalTable: "IdentityServerClients",
  345. principalColumn: "Id",
  346. onDelete: ReferentialAction.Cascade);
  347. });
  348. migrationBuilder.CreateTable(
  349. name: "IdentityServerClientIdPRestrictions",
  350. columns: table => new
  351. {
  352. ClientId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  353. Provider = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false)
  354. },
  355. constraints: table =>
  356. {
  357. table.PrimaryKey("PK_IdentityServerClientIdPRestrictions", x => new { x.ClientId, x.Provider });
  358. table.ForeignKey(
  359. name: "FK_IdentityServerClientIdPRestrictions_IdentityServerClients_ClientId",
  360. column: x => x.ClientId,
  361. principalTable: "IdentityServerClients",
  362. principalColumn: "Id",
  363. onDelete: ReferentialAction.Cascade);
  364. });
  365. migrationBuilder.CreateTable(
  366. name: "IdentityServerClientPostLogoutRedirectUris",
  367. columns: table => new
  368. {
  369. ClientId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  370. PostLogoutRedirectUri = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false)
  371. },
  372. constraints: table =>
  373. {
  374. table.PrimaryKey("PK_IdentityServerClientPostLogoutRedirectUris", x => new { x.ClientId, x.PostLogoutRedirectUri });
  375. table.ForeignKey(
  376. name: "FK_IdentityServerClientPostLogoutRedirectUris_IdentityServerClients_ClientId",
  377. column: x => x.ClientId,
  378. principalTable: "IdentityServerClients",
  379. principalColumn: "Id",
  380. onDelete: ReferentialAction.Cascade);
  381. });
  382. migrationBuilder.CreateTable(
  383. name: "IdentityServerClientProperties",
  384. columns: table => new
  385. {
  386. ClientId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  387. Key = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  388. Value = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false)
  389. },
  390. constraints: table =>
  391. {
  392. table.PrimaryKey("PK_IdentityServerClientProperties", x => new { x.ClientId, x.Key, x.Value });
  393. table.ForeignKey(
  394. name: "FK_IdentityServerClientProperties_IdentityServerClients_ClientId",
  395. column: x => x.ClientId,
  396. principalTable: "IdentityServerClients",
  397. principalColumn: "Id",
  398. onDelete: ReferentialAction.Cascade);
  399. });
  400. migrationBuilder.CreateTable(
  401. name: "IdentityServerClientRedirectUris",
  402. columns: table => new
  403. {
  404. ClientId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  405. RedirectUri = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false)
  406. },
  407. constraints: table =>
  408. {
  409. table.PrimaryKey("PK_IdentityServerClientRedirectUris", x => new { x.ClientId, x.RedirectUri });
  410. table.ForeignKey(
  411. name: "FK_IdentityServerClientRedirectUris_IdentityServerClients_ClientId",
  412. column: x => x.ClientId,
  413. principalTable: "IdentityServerClients",
  414. principalColumn: "Id",
  415. onDelete: ReferentialAction.Cascade);
  416. });
  417. migrationBuilder.CreateTable(
  418. name: "IdentityServerClientScopes",
  419. columns: table => new
  420. {
  421. ClientId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  422. Scope = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false)
  423. },
  424. constraints: table =>
  425. {
  426. table.PrimaryKey("PK_IdentityServerClientScopes", x => new { x.ClientId, x.Scope });
  427. table.ForeignKey(
  428. name: "FK_IdentityServerClientScopes_IdentityServerClients_ClientId",
  429. column: x => x.ClientId,
  430. principalTable: "IdentityServerClients",
  431. principalColumn: "Id",
  432. onDelete: ReferentialAction.Cascade);
  433. });
  434. migrationBuilder.CreateTable(
  435. name: "IdentityServerClientSecrets",
  436. columns: table => new
  437. {
  438. Type = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  439. Value = table.Column<string>(type: "nvarchar(4000)", maxLength: 4000, nullable: false),
  440. ClientId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  441. Description = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true),
  442. Expiration = table.Column<DateTime>(type: "datetime2", nullable: true)
  443. },
  444. constraints: table =>
  445. {
  446. table.PrimaryKey("PK_IdentityServerClientSecrets", x => new { x.ClientId, x.Type, x.Value });
  447. table.ForeignKey(
  448. name: "FK_IdentityServerClientSecrets_IdentityServerClients_ClientId",
  449. column: x => x.ClientId,
  450. principalTable: "IdentityServerClients",
  451. principalColumn: "Id",
  452. onDelete: ReferentialAction.Cascade);
  453. });
  454. migrationBuilder.CreateTable(
  455. name: "IdentityServerIdentityResourceClaims",
  456. columns: table => new
  457. {
  458. Type = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
  459. IdentityResourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
  460. },
  461. constraints: table =>
  462. {
  463. table.PrimaryKey("PK_IdentityServerIdentityResourceClaims", x => new { x.IdentityResourceId, x.Type });
  464. table.ForeignKey(
  465. name: "FK_IdentityServerIdentityResourceClaims_IdentityServerIdentityResources_IdentityResourceId",
  466. column: x => x.IdentityResourceId,
  467. principalTable: "IdentityServerIdentityResources",
  468. principalColumn: "Id",
  469. onDelete: ReferentialAction.Cascade);
  470. });
  471. migrationBuilder.CreateTable(
  472. name: "IdentityServerIdentityResourceProperties",
  473. columns: table => new
  474. {
  475. IdentityResourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  476. Key = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  477. Value = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false)
  478. },
  479. constraints: table =>
  480. {
  481. table.PrimaryKey("PK_IdentityServerIdentityResourceProperties", x => new { x.IdentityResourceId, x.Key, x.Value });
  482. table.ForeignKey(
  483. name: "FK_IdentityServerIdentityResourceProperties_IdentityServerIdentityResources_IdentityResourceId",
  484. column: x => x.IdentityResourceId,
  485. principalTable: "IdentityServerIdentityResources",
  486. principalColumn: "Id",
  487. onDelete: ReferentialAction.Cascade);
  488. });
  489. migrationBuilder.CreateIndex(
  490. name: "IX_IdentityServerClients_ClientId",
  491. table: "IdentityServerClients",
  492. column: "ClientId");
  493. migrationBuilder.CreateIndex(
  494. name: "IX_IdentityServerDeviceFlowCodes_DeviceCode",
  495. table: "IdentityServerDeviceFlowCodes",
  496. column: "DeviceCode",
  497. unique: true);
  498. migrationBuilder.CreateIndex(
  499. name: "IX_IdentityServerDeviceFlowCodes_Expiration",
  500. table: "IdentityServerDeviceFlowCodes",
  501. column: "Expiration");
  502. migrationBuilder.CreateIndex(
  503. name: "IX_IdentityServerDeviceFlowCodes_UserCode",
  504. table: "IdentityServerDeviceFlowCodes",
  505. column: "UserCode");
  506. migrationBuilder.CreateIndex(
  507. name: "IX_IdentityServerPersistedGrants_Expiration",
  508. table: "IdentityServerPersistedGrants",
  509. column: "Expiration");
  510. migrationBuilder.CreateIndex(
  511. name: "IX_IdentityServerPersistedGrants_SubjectId_ClientId_Type",
  512. table: "IdentityServerPersistedGrants",
  513. columns: new[] { "SubjectId", "ClientId", "Type" });
  514. migrationBuilder.CreateIndex(
  515. name: "IX_IdentityServerPersistedGrants_SubjectId_SessionId_Type",
  516. table: "IdentityServerPersistedGrants",
  517. columns: new[] { "SubjectId", "SessionId", "Type" });
  518. }
  519. protected override void Down(MigrationBuilder migrationBuilder)
  520. {
  521. migrationBuilder.DropTable(
  522. name: "IdentityServerApiResourceClaims");
  523. migrationBuilder.DropTable(
  524. name: "IdentityServerApiResourceProperties");
  525. migrationBuilder.DropTable(
  526. name: "IdentityServerApiResourceScopes");
  527. migrationBuilder.DropTable(
  528. name: "IdentityServerApiResourceSecrets");
  529. migrationBuilder.DropTable(
  530. name: "IdentityServerApiScopeClaims");
  531. migrationBuilder.DropTable(
  532. name: "IdentityServerApiScopeProperties");
  533. migrationBuilder.DropTable(
  534. name: "IdentityServerClientClaims");
  535. migrationBuilder.DropTable(
  536. name: "IdentityServerClientCorsOrigins");
  537. migrationBuilder.DropTable(
  538. name: "IdentityServerClientGrantTypes");
  539. migrationBuilder.DropTable(
  540. name: "IdentityServerClientIdPRestrictions");
  541. migrationBuilder.DropTable(
  542. name: "IdentityServerClientPostLogoutRedirectUris");
  543. migrationBuilder.DropTable(
  544. name: "IdentityServerClientProperties");
  545. migrationBuilder.DropTable(
  546. name: "IdentityServerClientRedirectUris");
  547. migrationBuilder.DropTable(
  548. name: "IdentityServerClientScopes");
  549. migrationBuilder.DropTable(
  550. name: "IdentityServerClientSecrets");
  551. migrationBuilder.DropTable(
  552. name: "IdentityServerDeviceFlowCodes");
  553. migrationBuilder.DropTable(
  554. name: "IdentityServerIdentityResourceClaims");
  555. migrationBuilder.DropTable(
  556. name: "IdentityServerIdentityResourceProperties");
  557. migrationBuilder.DropTable(
  558. name: "IdentityServerPersistedGrants");
  559. migrationBuilder.DropTable(
  560. name: "IdentityServerApiResources");
  561. migrationBuilder.DropTable(
  562. name: "IdentityServerApiScopes");
  563. migrationBuilder.DropTable(
  564. name: "IdentityServerClients");
  565. migrationBuilder.DropTable(
  566. name: "IdentityServerIdentityResources");
  567. }
  568. }
  569. }