201911010155297_InitCreate.cs 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784
  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 InitCreate : DbMigration
  8. {
  9. public override void Up()
  10. {
  11. CreateTable(
  12. "dbo.Sys_Permissions",
  13. c => new
  14. {
  15. Id = c.Long(nullable: false, identity: true),
  16. TenantId = c.Int(),
  17. Name = c.String(nullable: false, maxLength: 500),
  18. Master = c.Int(),
  19. MasterValue = c.String(maxLength: 100),
  20. Access = c.Int(),
  21. AccessValue = c.String(maxLength: 500),
  22. IsGranted = c.Boolean(nullable: false),
  23. CreationTime = c.DateTime(nullable: false),
  24. CreatorUserId = c.Long(),
  25. UserId = c.Long(),
  26. Discriminator = c.String(nullable: false, maxLength: 128),
  27. },
  28. annotations: new Dictionary<string, object>
  29. {
  30. { "DynamicFilter_DataPermission_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  31. { "DynamicFilter_PermissionSetting_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  32. { "DynamicFilter_RolePermissionSetting_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  33. { "DynamicFilter_UserPermissionSetting_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  34. })
  35. .PrimaryKey(t => t.Id)
  36. .Index(t => t.TenantId);
  37. CreateTable(
  38. "dbo.Sys_Notifications",
  39. c => new
  40. {
  41. Id = c.Guid(nullable: false),
  42. NotificationName = c.String(nullable: false, maxLength: 96),
  43. Data = c.String(),
  44. DataTypeName = c.String(maxLength: 512),
  45. EntityTypeName = c.String(maxLength: 250),
  46. EntityTypeAssemblyQualifiedName = c.String(maxLength: 512),
  47. EntityId = c.String(maxLength: 96),
  48. Severity = c.Byte(nullable: false),
  49. UserIds = c.String(),
  50. ExcludedUserIds = c.String(),
  51. TenantIds = c.String(),
  52. CreationTime = c.DateTime(nullable: false),
  53. CreatorUserId = c.Long(),
  54. })
  55. .PrimaryKey(t => t.Id);
  56. CreateTable(
  57. "dbo.Sys_NotificationSubscriptions",
  58. c => new
  59. {
  60. Id = c.Guid(nullable: false),
  61. TenantId = c.Int(),
  62. UserId = c.Long(nullable: false),
  63. NotificationName = c.String(maxLength: 96),
  64. EntityTypeName = c.String(maxLength: 250),
  65. EntityTypeAssemblyQualifiedName = c.String(maxLength: 512),
  66. EntityId = c.String(maxLength: 96),
  67. CreationTime = c.DateTime(nullable: false),
  68. CreatorUserId = c.Long(),
  69. },
  70. annotations: new Dictionary<string, object>
  71. {
  72. { "DynamicFilter_NotificationSubscriptionInfo_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  73. })
  74. .PrimaryKey(t => t.Id)
  75. .Index(t => t.TenantId)
  76. .Index(t => new { t.NotificationName, t.EntityTypeName, t.EntityId, t.UserId });
  77. CreateTable(
  78. "dbo.Sys_Roles",
  79. c => new
  80. {
  81. Id = c.Int(nullable: false, identity: true),
  82. Description = c.String(),
  83. NormalizedName = c.String(nullable: false, maxLength: 32),
  84. ConcurrencyStamp = c.String(maxLength: 128),
  85. TenantId = c.Int(),
  86. Name = c.String(nullable: false, maxLength: 32),
  87. RoleType = c.Int(nullable: false),
  88. AccountType = c.Int(),
  89. DisplayName = c.String(nullable: false, maxLength: 64),
  90. IsStatic = c.Boolean(nullable: false),
  91. IsDefault = c.Boolean(nullable: false),
  92. IsDeleted = c.Boolean(nullable: false),
  93. DeleterUserId = c.Long(),
  94. DeletionTime = c.DateTime(),
  95. LastModificationTime = c.DateTime(),
  96. LastModifierUserId = c.Long(),
  97. CreationTime = c.DateTime(nullable: false),
  98. CreatorUserId = c.Long(),
  99. },
  100. annotations: new Dictionary<string, object>
  101. {
  102. { "DynamicFilter_Role_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  103. { "DynamicFilter_Role_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  104. })
  105. .PrimaryKey(t => t.Id)
  106. .ForeignKey("dbo.Sys_Users", t => t.CreatorUserId)
  107. .ForeignKey("dbo.Sys_Users", t => t.DeleterUserId)
  108. .ForeignKey("dbo.Sys_Users", t => t.LastModifierUserId)
  109. .Index(t => t.TenantId)
  110. .Index(t => t.Name)
  111. .Index(t => t.RoleType)
  112. .Index(t => t.AccountType)
  113. .Index(t => t.IsDeleted)
  114. .Index(t => t.DeleterUserId)
  115. .Index(t => t.LastModifierUserId)
  116. .Index(t => t.CreatorUserId);
  117. CreateTable(
  118. "dbo.Sys_RoleClaims",
  119. c => new
  120. {
  121. Id = c.Long(nullable: false, identity: true),
  122. TenantId = c.Int(),
  123. RoleId = c.Int(nullable: false),
  124. ClaimType = c.String(maxLength: 256),
  125. ClaimValue = c.String(),
  126. CreationTime = c.DateTime(nullable: false),
  127. CreatorUserId = c.Long(),
  128. },
  129. annotations: new Dictionary<string, object>
  130. {
  131. { "DynamicFilter_RoleClaim_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  132. })
  133. .PrimaryKey(t => t.Id)
  134. .ForeignKey("dbo.Sys_Roles", t => t.RoleId, cascadeDelete: true)
  135. .Index(t => t.TenantId)
  136. .Index(t => t.RoleId);
  137. CreateTable(
  138. "dbo.Sys_Users",
  139. c => new
  140. {
  141. Id = c.Long(nullable: false, identity: true),
  142. NormalizedUserName = c.String(nullable: false, maxLength: 256),
  143. NormalizedEmailAddress = c.String(nullable: false, maxLength: 256),
  144. ConcurrencyStamp = c.String(maxLength: 128),
  145. AuthenticationSource = c.String(maxLength: 64),
  146. UserName = c.String(nullable: false, maxLength: 256),
  147. UserType = c.Int(nullable: false),
  148. AccountType = c.Int(),
  149. AccountNo = c.String(maxLength: 100),
  150. ImagePath = c.String(maxLength: 1000),
  151. TenantId = c.Int(),
  152. EmailAddress = c.String(nullable: false, maxLength: 256),
  153. Name = c.String(nullable: false, maxLength: 64),
  154. Surname = c.String(maxLength: 64),
  155. AvatarImagePath = c.String(maxLength: 500),
  156. Password = c.String(nullable: false, maxLength: 128),
  157. EmailConfirmationCode = c.String(maxLength: 328),
  158. PasswordResetCode = c.String(maxLength: 328),
  159. LockoutEndDateUtc = c.DateTime(),
  160. AccessFailedCount = c.Int(nullable: false),
  161. IsLockoutEnabled = c.Boolean(nullable: false),
  162. PhoneNumber = c.String(maxLength: 32),
  163. IsPhoneNumberConfirmed = c.Boolean(nullable: false),
  164. SecurityStamp = c.String(maxLength: 128),
  165. IsTwoFactorEnabled = c.Boolean(nullable: false),
  166. IsEmailConfirmed = c.Boolean(nullable: false),
  167. IsActive = c.Boolean(nullable: false),
  168. IsDeleted = c.Boolean(nullable: false),
  169. DeleterUserId = c.Long(),
  170. DeletionTime = c.DateTime(),
  171. LastModificationTime = c.DateTime(),
  172. LastModifierUserId = c.Long(),
  173. CreationTime = c.DateTime(nullable: false),
  174. CreatorUserId = c.Long(),
  175. },
  176. annotations: new Dictionary<string, object>
  177. {
  178. { "DynamicFilter_User_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  179. { "DynamicFilter_User_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  180. })
  181. .PrimaryKey(t => t.Id)
  182. .ForeignKey("dbo.Sys_Users", t => t.CreatorUserId)
  183. .ForeignKey("dbo.Sys_Users", t => t.DeleterUserId)
  184. .ForeignKey("dbo.Sys_Users", t => t.LastModifierUserId)
  185. .Index(t => t.UserName)
  186. .Index(t => t.UserType)
  187. .Index(t => t.AccountType)
  188. .Index(t => t.TenantId)
  189. .Index(t => t.EmailAddress)
  190. .Index(t => t.PhoneNumber)
  191. .Index(t => t.IsDeleted)
  192. .Index(t => t.DeleterUserId)
  193. .Index(t => t.LastModifierUserId)
  194. .Index(t => t.CreatorUserId);
  195. CreateTable(
  196. "dbo.Sys_UserClaims",
  197. c => new
  198. {
  199. Id = c.Long(nullable: false, identity: true),
  200. TenantId = c.Int(),
  201. UserId = c.Long(nullable: false),
  202. ClaimType = c.String(maxLength: 256),
  203. ClaimValue = c.String(),
  204. CreationTime = c.DateTime(nullable: false),
  205. CreatorUserId = c.Long(),
  206. },
  207. annotations: new Dictionary<string, object>
  208. {
  209. { "DynamicFilter_UserClaim_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  210. })
  211. .PrimaryKey(t => t.Id)
  212. .ForeignKey("dbo.Sys_Users", t => t.UserId, cascadeDelete: true)
  213. .Index(t => t.TenantId)
  214. .Index(t => t.UserId);
  215. CreateTable(
  216. "dbo.Sys_UserLogins",
  217. c => new
  218. {
  219. Id = c.Long(nullable: false, identity: true),
  220. TenantId = c.Int(),
  221. UserId = c.Long(nullable: false),
  222. LoginProvider = c.String(nullable: false, maxLength: 128),
  223. ProviderKey = c.String(nullable: false, maxLength: 256),
  224. },
  225. annotations: new Dictionary<string, object>
  226. {
  227. { "DynamicFilter_UserLogin_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  228. })
  229. .PrimaryKey(t => t.Id)
  230. .ForeignKey("dbo.Sys_Users", t => t.UserId, cascadeDelete: true)
  231. .Index(t => t.TenantId)
  232. .Index(t => t.UserId);
  233. CreateTable(
  234. "dbo.Sys_UserRoles",
  235. c => new
  236. {
  237. Id = c.Long(nullable: false, identity: true),
  238. TenantId = c.Int(),
  239. UserId = c.Long(nullable: false),
  240. RoleId = c.Int(nullable: false),
  241. CreationTime = c.DateTime(nullable: false),
  242. CreatorUserId = c.Long(),
  243. },
  244. annotations: new Dictionary<string, object>
  245. {
  246. { "DynamicFilter_UserRole_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  247. })
  248. .PrimaryKey(t => t.Id)
  249. .ForeignKey("dbo.Sys_Users", t => t.UserId, cascadeDelete: true)
  250. .Index(t => t.TenantId)
  251. .Index(t => t.UserId);
  252. CreateTable(
  253. "dbo.Sys_Settings",
  254. c => new
  255. {
  256. Id = c.Long(nullable: false, identity: true),
  257. TenantId = c.Int(),
  258. UserId = c.Long(),
  259. Name = c.String(nullable: false, maxLength: 256),
  260. Value = c.String(),
  261. DisplayName = c.String(maxLength: 50),
  262. Type = c.Int(),
  263. Description = c.String(maxLength: 500),
  264. Remark = c.String(maxLength: 500),
  265. LastModificationTime = c.DateTime(),
  266. LastModifierUserId = c.Long(),
  267. CreationTime = c.DateTime(nullable: false),
  268. CreatorUserId = c.Long(),
  269. },
  270. annotations: new Dictionary<string, object>
  271. {
  272. { "DynamicFilter_SysSetting_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  273. })
  274. .PrimaryKey(t => t.Id)
  275. .ForeignKey("dbo.Sys_Users", t => t.UserId)
  276. .Index(t => new { t.TenantId, t.Name, t.UserId }, unique: true);
  277. CreateTable(
  278. "dbo.Sys_AppGuids",
  279. c => new
  280. {
  281. Id = c.Int(nullable: false, identity: true),
  282. Step = c.Short(nullable: false),
  283. LastId = c.Int(nullable: false),
  284. IdType = c.Short(nullable: false),
  285. LastUseDate = c.DateTime(),
  286. })
  287. .PrimaryKey(t => t.Id)
  288. .Index(t => t.IdType);
  289. CreateTable(
  290. "dbo.Sys_AttachFiles",
  291. c => new
  292. {
  293. Id = c.Int(nullable: false, identity: true),
  294. AttachNo = c.String(maxLength: 32),
  295. TableName = c.String(maxLength: 50),
  296. ColumnName = c.String(maxLength: 50),
  297. SourceKey = c.String(maxLength: 50),
  298. FileTitle = c.String(maxLength: 50),
  299. FileName = c.String(maxLength: 50),
  300. FilePath = c.String(maxLength: 500),
  301. FileType = c.String(maxLength: 20),
  302. FileExt = c.String(maxLength: 10),
  303. Description = c.String(maxLength: 500),
  304. TenantId = c.Int(nullable: false),
  305. CreationTime = c.DateTime(nullable: false),
  306. CreatorUserId = c.Long(),
  307. },
  308. annotations: new Dictionary<string, object>
  309. {
  310. { "DynamicFilter_SysAttachFile_MustHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  311. })
  312. .PrimaryKey(t => t.Id)
  313. .ForeignKey("dbo.Sys_Users", t => t.CreatorUserId)
  314. .Index(t => t.TenantId)
  315. .Index(t => t.CreatorUserId);
  316. CreateTable(
  317. "dbo.Sys_Functions",
  318. c => new
  319. {
  320. Id = c.Int(nullable: false, identity: true),
  321. FunctionNo = c.String(maxLength: 100),
  322. ParentNo = c.String(maxLength: 100),
  323. FunctionName = c.String(maxLength: 100),
  324. PermissionName = c.String(maxLength: 500),
  325. FunctionType = c.Int(nullable: false),
  326. Action = c.String(maxLength: 50),
  327. Controller = c.String(maxLength: 50),
  328. Url = c.String(),
  329. Icon = c.String(maxLength: 20),
  330. Class = c.String(maxLength: 100),
  331. Script = c.String(),
  332. NeedAuth = c.Boolean(nullable: false),
  333. Sort = c.Int(nullable: false),
  334. Depth = c.Int(nullable: false),
  335. IsLeaf = c.Boolean(),
  336. IsDeleted = c.Boolean(nullable: false),
  337. DeleterUserId = c.Long(),
  338. DeletionTime = c.DateTime(),
  339. LastModificationTime = c.DateTime(),
  340. LastModifierUserId = c.Long(),
  341. CreationTime = c.DateTime(nullable: false),
  342. CreatorUserId = c.Long(),
  343. },
  344. annotations: new Dictionary<string, object>
  345. {
  346. { "DynamicFilter_SysFunction_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  347. })
  348. .PrimaryKey(t => t.Id)
  349. .ForeignKey("dbo.Sys_Users", t => t.CreatorUserId)
  350. .ForeignKey("dbo.Sys_Users", t => t.DeleterUserId)
  351. .ForeignKey("dbo.Sys_Users", t => t.LastModifierUserId)
  352. .Index(t => t.FunctionNo)
  353. .Index(t => t.PermissionName, unique: true)
  354. .Index(t => t.IsDeleted)
  355. .Index(t => t.DeleterUserId)
  356. .Index(t => t.LastModifierUserId)
  357. .Index(t => t.CreatorUserId);
  358. CreateTable(
  359. "dbo.Sys_SysHelps",
  360. c => new
  361. {
  362. Id = c.Int(nullable: false, identity: true),
  363. Classification = c.String(maxLength: 40),
  364. HelpTitle = c.String(nullable: false, maxLength: 50),
  365. HelpKeyWords = c.String(maxLength: 50),
  366. HelpContent = c.String(),
  367. FunctionNo = c.String(maxLength: 100),
  368. PermissionName = c.String(maxLength: 500),
  369. Sequence = c.Int(nullable: false),
  370. Description = c.String(),
  371. Remark = c.String(maxLength: 1000),
  372. IsDeleted = c.Boolean(nullable: false),
  373. DeleterUserId = c.Long(),
  374. DeletionTime = c.DateTime(),
  375. LastModificationTime = c.DateTime(),
  376. LastModifierUserId = c.Long(),
  377. CreationTime = c.DateTime(nullable: false),
  378. CreatorUserId = c.Long(),
  379. },
  380. annotations: new Dictionary<string, object>
  381. {
  382. { "DynamicFilter_SysHelp_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  383. })
  384. .PrimaryKey(t => t.Id)
  385. .ForeignKey("dbo.Sys_Users", t => t.CreatorUserId)
  386. .ForeignKey("dbo.Sys_Users", t => t.DeleterUserId)
  387. .ForeignKey("dbo.Sys_Users", t => t.LastModifierUserId)
  388. .Index(t => t.IsDeleted)
  389. .Index(t => t.DeleterUserId)
  390. .Index(t => t.LastModifierUserId)
  391. .Index(t => t.CreatorUserId);
  392. CreateTable(
  393. "dbo.Sys_AuditLogs",
  394. c => new
  395. {
  396. Id = c.Long(nullable: false, identity: true),
  397. TenantId = c.Int(nullable: false),
  398. UserId = c.Long(),
  399. UserName = c.String(),
  400. ServiceName = c.String(maxLength: 256),
  401. ServiceNameLang = c.String(),
  402. MethodName = c.String(maxLength: 256),
  403. MethodNameLang = c.String(),
  404. Parameters = c.String(maxLength: 1024),
  405. ExecutionTime = c.DateTime(nullable: false),
  406. ExecutionDuration = c.Int(nullable: false),
  407. ClientIpAddress = c.String(maxLength: 64),
  408. ClientName = c.String(maxLength: 128),
  409. BrowserInfo = c.String(maxLength: 512),
  410. Exception = c.String(maxLength: 2000),
  411. ImpersonatorUserId = c.Long(),
  412. ImpersonatorTenantId = c.Int(),
  413. CustomData = c.String(maxLength: 2000),
  414. LogType = c.Int(nullable: false),
  415. },
  416. annotations: new Dictionary<string, object>
  417. {
  418. { "DynamicFilter_SysLog_MustHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  419. })
  420. .PrimaryKey(t => t.Id)
  421. .Index(t => t.TenantId)
  422. .Index(t => t.UserId);
  423. CreateTable(
  424. "dbo.Sys_States",
  425. c => new
  426. {
  427. Id = c.Int(nullable: false, identity: true),
  428. StateNo = c.String(maxLength: 32),
  429. StateName = c.String(maxLength: 50),
  430. TableName = c.String(nullable: false, maxLength: 50),
  431. ColumnName = c.String(nullable: false, maxLength: 50),
  432. CodeValue = c.String(nullable: false, maxLength: 100),
  433. DisplayValue = c.String(nullable: false, maxLength: 100),
  434. IsDeleted = c.Boolean(nullable: false),
  435. DeleterUserId = c.Long(),
  436. DeletionTime = c.DateTime(),
  437. LastModificationTime = c.DateTime(),
  438. LastModifierUserId = c.Long(),
  439. CreationTime = c.DateTime(nullable: false),
  440. CreatorUserId = c.Long(),
  441. },
  442. annotations: new Dictionary<string, object>
  443. {
  444. { "DynamicFilter_SysState_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  445. })
  446. .PrimaryKey(t => t.Id)
  447. .ForeignKey("dbo.Sys_Users", t => t.CreatorUserId)
  448. .ForeignKey("dbo.Sys_Users", t => t.DeleterUserId)
  449. .ForeignKey("dbo.Sys_Users", t => t.LastModifierUserId)
  450. .Index(t => t.IsDeleted)
  451. .Index(t => t.DeleterUserId)
  452. .Index(t => t.LastModifierUserId)
  453. .Index(t => t.CreatorUserId);
  454. CreateTable(
  455. "dbo.Sys_NotificationTenants",
  456. c => new
  457. {
  458. Id = c.Guid(nullable: false),
  459. TenantId = c.Int(),
  460. NotificationName = c.String(nullable: false, maxLength: 96),
  461. Data = c.String(),
  462. DataTypeName = c.String(maxLength: 512),
  463. EntityTypeName = c.String(maxLength: 250),
  464. EntityTypeAssemblyQualifiedName = c.String(maxLength: 512),
  465. EntityId = c.String(maxLength: 96),
  466. Severity = c.Byte(nullable: false),
  467. CreationTime = c.DateTime(nullable: false),
  468. CreatorUserId = c.Long(),
  469. },
  470. annotations: new Dictionary<string, object>
  471. {
  472. { "DynamicFilter_TenantNotificationInfo_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  473. })
  474. .PrimaryKey(t => t.Id)
  475. .Index(t => t.TenantId);
  476. CreateTable(
  477. "dbo.Sys_Tenants",
  478. c => new
  479. {
  480. Id = c.Int(nullable: false, identity: true),
  481. TenancyName = c.String(nullable: false, maxLength: 64),
  482. Name = c.String(nullable: false, maxLength: 128),
  483. ConnectionString = c.String(maxLength: 1024),
  484. IsActive = c.Boolean(nullable: false),
  485. IsDeleted = c.Boolean(nullable: false),
  486. DeleterUserId = c.Long(),
  487. DeletionTime = c.DateTime(),
  488. LastModificationTime = c.DateTime(),
  489. LastModifierUserId = c.Long(),
  490. CreationTime = c.DateTime(nullable: false),
  491. CreatorUserId = c.Long(),
  492. },
  493. annotations: new Dictionary<string, object>
  494. {
  495. { "DynamicFilter_Tenant_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  496. })
  497. .PrimaryKey(t => t.Id)
  498. .ForeignKey("dbo.Sys_Users", t => t.CreatorUserId)
  499. .ForeignKey("dbo.Sys_Users", t => t.DeleterUserId)
  500. .ForeignKey("dbo.Sys_Users", t => t.LastModifierUserId)
  501. .Index(t => t.IsDeleted)
  502. .Index(t => t.DeleterUserId)
  503. .Index(t => t.LastModifierUserId)
  504. .Index(t => t.CreatorUserId);
  505. CreateTable(
  506. "dbo.Sys_UserAccounts",
  507. c => new
  508. {
  509. Id = c.Long(nullable: false, identity: true),
  510. TenantId = c.Int(),
  511. UserId = c.Long(nullable: false),
  512. UserLinkId = c.Long(),
  513. UserName = c.String(maxLength: 256),
  514. EmailAddress = c.String(maxLength: 256),
  515. IsDeleted = c.Boolean(nullable: false),
  516. DeleterUserId = c.Long(),
  517. DeletionTime = c.DateTime(),
  518. LastModificationTime = c.DateTime(),
  519. LastModifierUserId = c.Long(),
  520. CreationTime = c.DateTime(nullable: false),
  521. CreatorUserId = c.Long(),
  522. },
  523. annotations: new Dictionary<string, object>
  524. {
  525. { "DynamicFilter_UserAccount_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  526. })
  527. .PrimaryKey(t => t.Id)
  528. .Index(t => t.IsDeleted);
  529. CreateTable(
  530. "dbo.Sys_UserLoginAttempts",
  531. c => new
  532. {
  533. Id = c.Long(nullable: false, identity: true),
  534. TenantId = c.Int(),
  535. TenancyName = c.String(maxLength: 64),
  536. UserId = c.Long(),
  537. UserNameOrEmailAddress = c.String(maxLength: 255),
  538. ClientIpAddress = c.String(maxLength: 64),
  539. ClientName = c.String(maxLength: 128),
  540. BrowserInfo = c.String(maxLength: 512),
  541. Result = c.Byte(nullable: false),
  542. CreationTime = c.DateTime(nullable: false),
  543. },
  544. annotations: new Dictionary<string, object>
  545. {
  546. { "DynamicFilter_UserLoginAttempt_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  547. })
  548. .PrimaryKey(t => t.Id)
  549. .Index(t => t.TenantId)
  550. .Index(t => new { t.UserId, t.TenantId })
  551. .Index(t => new { t.TenancyName, t.UserNameOrEmailAddress, t.Result });
  552. CreateTable(
  553. "dbo.Sys_NotificationUsers",
  554. c => new
  555. {
  556. Id = c.Guid(nullable: false),
  557. TenantId = c.Int(),
  558. UserId = c.Long(nullable: false),
  559. TenantNotificationId = c.Guid(nullable: false),
  560. State = c.Int(nullable: false),
  561. CreationTime = c.DateTime(nullable: false),
  562. },
  563. annotations: new Dictionary<string, object>
  564. {
  565. { "DynamicFilter_UserNotificationInfo_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  566. })
  567. .PrimaryKey(t => t.Id)
  568. .Index(t => t.TenantId)
  569. .Index(t => new { t.UserId, t.State, t.CreationTime });
  570. }
  571. public override void Down()
  572. {
  573. DropForeignKey("dbo.Sys_Tenants", "LastModifierUserId", "dbo.Sys_Users");
  574. DropForeignKey("dbo.Sys_Tenants", "DeleterUserId", "dbo.Sys_Users");
  575. DropForeignKey("dbo.Sys_Tenants", "CreatorUserId", "dbo.Sys_Users");
  576. DropForeignKey("dbo.Sys_States", "LastModifierUserId", "dbo.Sys_Users");
  577. DropForeignKey("dbo.Sys_States", "DeleterUserId", "dbo.Sys_Users");
  578. DropForeignKey("dbo.Sys_States", "CreatorUserId", "dbo.Sys_Users");
  579. DropForeignKey("dbo.Sys_SysHelps", "LastModifierUserId", "dbo.Sys_Users");
  580. DropForeignKey("dbo.Sys_SysHelps", "DeleterUserId", "dbo.Sys_Users");
  581. DropForeignKey("dbo.Sys_SysHelps", "CreatorUserId", "dbo.Sys_Users");
  582. DropForeignKey("dbo.Sys_Functions", "LastModifierUserId", "dbo.Sys_Users");
  583. DropForeignKey("dbo.Sys_Functions", "DeleterUserId", "dbo.Sys_Users");
  584. DropForeignKey("dbo.Sys_Functions", "CreatorUserId", "dbo.Sys_Users");
  585. DropForeignKey("dbo.Sys_AttachFiles", "CreatorUserId", "dbo.Sys_Users");
  586. DropForeignKey("dbo.Sys_Roles", "LastModifierUserId", "dbo.Sys_Users");
  587. DropForeignKey("dbo.Sys_Roles", "DeleterUserId", "dbo.Sys_Users");
  588. DropForeignKey("dbo.Sys_Roles", "CreatorUserId", "dbo.Sys_Users");
  589. DropForeignKey("dbo.Sys_Settings", "UserId", "dbo.Sys_Users");
  590. DropForeignKey("dbo.Sys_UserRoles", "UserId", "dbo.Sys_Users");
  591. DropForeignKey("dbo.Sys_UserLogins", "UserId", "dbo.Sys_Users");
  592. DropForeignKey("dbo.Sys_Users", "LastModifierUserId", "dbo.Sys_Users");
  593. DropForeignKey("dbo.Sys_Users", "DeleterUserId", "dbo.Sys_Users");
  594. DropForeignKey("dbo.Sys_Users", "CreatorUserId", "dbo.Sys_Users");
  595. DropForeignKey("dbo.Sys_UserClaims", "UserId", "dbo.Sys_Users");
  596. DropForeignKey("dbo.Sys_RoleClaims", "RoleId", "dbo.Sys_Roles");
  597. DropIndex("dbo.Sys_NotificationUsers", new[] { "UserId", "State", "CreationTime" });
  598. DropIndex("dbo.Sys_NotificationUsers", new[] { "TenantId" });
  599. DropIndex("dbo.Sys_UserLoginAttempts", new[] { "TenancyName", "UserNameOrEmailAddress", "Result" });
  600. DropIndex("dbo.Sys_UserLoginAttempts", new[] { "UserId", "TenantId" });
  601. DropIndex("dbo.Sys_UserLoginAttempts", new[] { "TenantId" });
  602. DropIndex("dbo.Sys_UserAccounts", new[] { "IsDeleted" });
  603. DropIndex("dbo.Sys_Tenants", new[] { "CreatorUserId" });
  604. DropIndex("dbo.Sys_Tenants", new[] { "LastModifierUserId" });
  605. DropIndex("dbo.Sys_Tenants", new[] { "DeleterUserId" });
  606. DropIndex("dbo.Sys_Tenants", new[] { "IsDeleted" });
  607. DropIndex("dbo.Sys_NotificationTenants", new[] { "TenantId" });
  608. DropIndex("dbo.Sys_States", new[] { "CreatorUserId" });
  609. DropIndex("dbo.Sys_States", new[] { "LastModifierUserId" });
  610. DropIndex("dbo.Sys_States", new[] { "DeleterUserId" });
  611. DropIndex("dbo.Sys_States", new[] { "IsDeleted" });
  612. DropIndex("dbo.Sys_AuditLogs", new[] { "UserId" });
  613. DropIndex("dbo.Sys_AuditLogs", new[] { "TenantId" });
  614. DropIndex("dbo.Sys_SysHelps", new[] { "CreatorUserId" });
  615. DropIndex("dbo.Sys_SysHelps", new[] { "LastModifierUserId" });
  616. DropIndex("dbo.Sys_SysHelps", new[] { "DeleterUserId" });
  617. DropIndex("dbo.Sys_SysHelps", new[] { "IsDeleted" });
  618. DropIndex("dbo.Sys_Functions", new[] { "CreatorUserId" });
  619. DropIndex("dbo.Sys_Functions", new[] { "LastModifierUserId" });
  620. DropIndex("dbo.Sys_Functions", new[] { "DeleterUserId" });
  621. DropIndex("dbo.Sys_Functions", new[] { "IsDeleted" });
  622. DropIndex("dbo.Sys_Functions", new[] { "PermissionName" });
  623. DropIndex("dbo.Sys_Functions", new[] { "FunctionNo" });
  624. DropIndex("dbo.Sys_AttachFiles", new[] { "CreatorUserId" });
  625. DropIndex("dbo.Sys_AttachFiles", new[] { "TenantId" });
  626. DropIndex("dbo.Sys_AppGuids", new[] { "IdType" });
  627. DropIndex("dbo.Sys_Settings", new[] { "TenantId", "Name", "UserId" });
  628. DropIndex("dbo.Sys_UserRoles", new[] { "UserId" });
  629. DropIndex("dbo.Sys_UserRoles", new[] { "TenantId" });
  630. DropIndex("dbo.Sys_UserLogins", new[] { "UserId" });
  631. DropIndex("dbo.Sys_UserLogins", new[] { "TenantId" });
  632. DropIndex("dbo.Sys_UserClaims", new[] { "UserId" });
  633. DropIndex("dbo.Sys_UserClaims", new[] { "TenantId" });
  634. DropIndex("dbo.Sys_Users", new[] { "CreatorUserId" });
  635. DropIndex("dbo.Sys_Users", new[] { "LastModifierUserId" });
  636. DropIndex("dbo.Sys_Users", new[] { "DeleterUserId" });
  637. DropIndex("dbo.Sys_Users", new[] { "IsDeleted" });
  638. DropIndex("dbo.Sys_Users", new[] { "PhoneNumber" });
  639. DropIndex("dbo.Sys_Users", new[] { "EmailAddress" });
  640. DropIndex("dbo.Sys_Users", new[] { "TenantId" });
  641. DropIndex("dbo.Sys_Users", new[] { "AccountType" });
  642. DropIndex("dbo.Sys_Users", new[] { "UserType" });
  643. DropIndex("dbo.Sys_Users", new[] { "UserName" });
  644. DropIndex("dbo.Sys_RoleClaims", new[] { "RoleId" });
  645. DropIndex("dbo.Sys_RoleClaims", new[] { "TenantId" });
  646. DropIndex("dbo.Sys_Roles", new[] { "CreatorUserId" });
  647. DropIndex("dbo.Sys_Roles", new[] { "LastModifierUserId" });
  648. DropIndex("dbo.Sys_Roles", new[] { "DeleterUserId" });
  649. DropIndex("dbo.Sys_Roles", new[] { "IsDeleted" });
  650. DropIndex("dbo.Sys_Roles", new[] { "AccountType" });
  651. DropIndex("dbo.Sys_Roles", new[] { "RoleType" });
  652. DropIndex("dbo.Sys_Roles", new[] { "Name" });
  653. DropIndex("dbo.Sys_Roles", new[] { "TenantId" });
  654. DropIndex("dbo.Sys_NotificationSubscriptions", new[] { "NotificationName", "EntityTypeName", "EntityId", "UserId" });
  655. DropIndex("dbo.Sys_NotificationSubscriptions", new[] { "TenantId" });
  656. DropIndex("dbo.Sys_Permissions", new[] { "TenantId" });
  657. DropTable("dbo.Sys_NotificationUsers",
  658. removedAnnotations: new Dictionary<string, object>
  659. {
  660. { "DynamicFilter_UserNotificationInfo_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  661. });
  662. DropTable("dbo.Sys_UserLoginAttempts",
  663. removedAnnotations: new Dictionary<string, object>
  664. {
  665. { "DynamicFilter_UserLoginAttempt_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  666. });
  667. DropTable("dbo.Sys_UserAccounts",
  668. removedAnnotations: new Dictionary<string, object>
  669. {
  670. { "DynamicFilter_UserAccount_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  671. });
  672. DropTable("dbo.Sys_Tenants",
  673. removedAnnotations: new Dictionary<string, object>
  674. {
  675. { "DynamicFilter_Tenant_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  676. });
  677. DropTable("dbo.Sys_NotificationTenants",
  678. removedAnnotations: new Dictionary<string, object>
  679. {
  680. { "DynamicFilter_TenantNotificationInfo_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  681. });
  682. DropTable("dbo.Sys_States",
  683. removedAnnotations: new Dictionary<string, object>
  684. {
  685. { "DynamicFilter_SysState_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  686. });
  687. DropTable("dbo.Sys_AuditLogs",
  688. removedAnnotations: new Dictionary<string, object>
  689. {
  690. { "DynamicFilter_SysLog_MustHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  691. });
  692. DropTable("dbo.Sys_SysHelps",
  693. removedAnnotations: new Dictionary<string, object>
  694. {
  695. { "DynamicFilter_SysHelp_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  696. });
  697. DropTable("dbo.Sys_Functions",
  698. removedAnnotations: new Dictionary<string, object>
  699. {
  700. { "DynamicFilter_SysFunction_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  701. });
  702. DropTable("dbo.Sys_AttachFiles",
  703. removedAnnotations: new Dictionary<string, object>
  704. {
  705. { "DynamicFilter_SysAttachFile_MustHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  706. });
  707. DropTable("dbo.Sys_AppGuids");
  708. DropTable("dbo.Sys_Settings",
  709. removedAnnotations: new Dictionary<string, object>
  710. {
  711. { "DynamicFilter_SysSetting_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  712. });
  713. DropTable("dbo.Sys_UserRoles",
  714. removedAnnotations: new Dictionary<string, object>
  715. {
  716. { "DynamicFilter_UserRole_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  717. });
  718. DropTable("dbo.Sys_UserLogins",
  719. removedAnnotations: new Dictionary<string, object>
  720. {
  721. { "DynamicFilter_UserLogin_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  722. });
  723. DropTable("dbo.Sys_UserClaims",
  724. removedAnnotations: new Dictionary<string, object>
  725. {
  726. { "DynamicFilter_UserClaim_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  727. });
  728. DropTable("dbo.Sys_Users",
  729. removedAnnotations: new Dictionary<string, object>
  730. {
  731. { "DynamicFilter_User_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  732. { "DynamicFilter_User_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  733. });
  734. DropTable("dbo.Sys_RoleClaims",
  735. removedAnnotations: new Dictionary<string, object>
  736. {
  737. { "DynamicFilter_RoleClaim_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  738. });
  739. DropTable("dbo.Sys_Roles",
  740. removedAnnotations: new Dictionary<string, object>
  741. {
  742. { "DynamicFilter_Role_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  743. { "DynamicFilter_Role_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  744. });
  745. DropTable("dbo.Sys_NotificationSubscriptions",
  746. removedAnnotations: new Dictionary<string, object>
  747. {
  748. { "DynamicFilter_NotificationSubscriptionInfo_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  749. });
  750. DropTable("dbo.Sys_Notifications");
  751. DropTable("dbo.Sys_Permissions",
  752. removedAnnotations: new Dictionary<string, object>
  753. {
  754. { "DynamicFilter_DataPermission_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  755. { "DynamicFilter_PermissionSetting_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  756. { "DynamicFilter_RolePermissionSetting_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  757. { "DynamicFilter_UserPermissionSetting_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
  758. });
  759. }
  760. }
  761. }