API

20190905133540_BanksAddresses.cs 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
  4. namespace UnivateProperties_API.Migrations
  5. {
  6. public partial class BanksAddresses : Migration
  7. {
  8. protected override void Up(MigrationBuilder migrationBuilder)
  9. {
  10. migrationBuilder.DropForeignKey(
  11. name: "FK_Agents_Users_UserId",
  12. table: "Agents");
  13. migrationBuilder.DropForeignKey(
  14. name: "FK_Individuals_Users_UserId",
  15. table: "Individuals");
  16. migrationBuilder.AddColumn<int>(
  17. name: "AgencyId",
  18. table: "Properties",
  19. nullable: true);
  20. migrationBuilder.AddColumn<int>(
  21. name: "AgentId",
  22. table: "Properties",
  23. nullable: true);
  24. migrationBuilder.AddColumn<int>(
  25. name: "OwnerId",
  26. table: "Properties",
  27. nullable: true);
  28. migrationBuilder.AddColumn<int>(
  29. name: "StatusId",
  30. table: "Properties",
  31. nullable: true);
  32. migrationBuilder.AlterColumn<int>(
  33. name: "UserId",
  34. table: "Individuals",
  35. nullable: true,
  36. oldClrType: typeof(int));
  37. migrationBuilder.AddColumn<int>(
  38. name: "AddressId",
  39. table: "Individuals",
  40. nullable: true);
  41. migrationBuilder.AddColumn<string>(
  42. name: "CompanyRegNumber",
  43. table: "Individuals",
  44. nullable: true);
  45. migrationBuilder.AddColumn<string>(
  46. name: "IdNumber",
  47. table: "Individuals",
  48. nullable: true);
  49. migrationBuilder.AddColumn<string>(
  50. name: "IncomeTaxNumber",
  51. table: "Individuals",
  52. nullable: true);
  53. migrationBuilder.AddColumn<string>(
  54. name: "MaritalStatus",
  55. table: "Individuals",
  56. nullable: true);
  57. migrationBuilder.AlterColumn<int>(
  58. name: "UserId",
  59. table: "Agents",
  60. nullable: true,
  61. oldClrType: typeof(int));
  62. migrationBuilder.CreateTable(
  63. name: "Addresses",
  64. columns: table => new
  65. {
  66. Id = table.Column<int>(nullable: false)
  67. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  68. Created = table.Column<DateTime>(nullable: false),
  69. Modified = table.Column<DateTime>(nullable: false),
  70. ModifiedBy = table.Column<string>(nullable: true),
  71. StreetNumber = table.Column<string>(nullable: true),
  72. Street = table.Column<string>(nullable: true),
  73. Suburb = table.Column<string>(nullable: true),
  74. City = table.Column<string>(nullable: true),
  75. PostalCode = table.Column<string>(nullable: true)
  76. },
  77. constraints: table =>
  78. {
  79. table.PrimaryKey("PK_Addresses", x => x.Id);
  80. });
  81. migrationBuilder.CreateTable(
  82. name: "Banks",
  83. columns: table => new
  84. {
  85. Id = table.Column<int>(nullable: false)
  86. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  87. Created = table.Column<DateTime>(nullable: false),
  88. Modified = table.Column<DateTime>(nullable: false),
  89. ModifiedBy = table.Column<string>(nullable: true),
  90. Name = table.Column<string>(nullable: true),
  91. UniversalBranchCode = table.Column<string>(nullable: true)
  92. },
  93. constraints: table =>
  94. {
  95. table.PrimaryKey("PK_Banks", x => x.Id);
  96. });
  97. migrationBuilder.CreateTable(
  98. name: "ProcessFlows",
  99. columns: table => new
  100. {
  101. Id = table.Column<int>(nullable: false)
  102. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  103. Created = table.Column<DateTime>(nullable: false),
  104. Modified = table.Column<DateTime>(nullable: false),
  105. ModifiedBy = table.Column<string>(nullable: true),
  106. TimeshareID = table.Column<int>(nullable: true),
  107. PropertyID = table.Column<int>(nullable: true),
  108. StatusID = table.Column<int>(nullable: false)
  109. },
  110. constraints: table =>
  111. {
  112. table.PrimaryKey("PK_ProcessFlows", x => x.Id);
  113. table.ForeignKey(
  114. name: "FK_ProcessFlows_Properties_PropertyID",
  115. column: x => x.PropertyID,
  116. principalTable: "Properties",
  117. principalColumn: "Id",
  118. onDelete: ReferentialAction.Restrict);
  119. table.ForeignKey(
  120. name: "FK_ProcessFlows_Status_StatusID",
  121. column: x => x.StatusID,
  122. principalTable: "Status",
  123. principalColumn: "Id",
  124. onDelete: ReferentialAction.Cascade);
  125. table.ForeignKey(
  126. name: "FK_ProcessFlows_Weeks_TimeshareID",
  127. column: x => x.TimeshareID,
  128. principalTable: "Weeks",
  129. principalColumn: "Id",
  130. onDelete: ReferentialAction.Restrict);
  131. });
  132. migrationBuilder.CreateTable(
  133. name: "BankAccounts",
  134. columns: table => new
  135. {
  136. Id = table.Column<int>(nullable: false)
  137. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  138. Created = table.Column<DateTime>(nullable: false),
  139. Modified = table.Column<DateTime>(nullable: false),
  140. ModifiedBy = table.Column<string>(nullable: true),
  141. AccountHolder = table.Column<string>(nullable: true),
  142. AccountNumber = table.Column<string>(nullable: true),
  143. BankId = table.Column<int>(nullable: false),
  144. OwnerId = table.Column<int>(nullable: true)
  145. },
  146. constraints: table =>
  147. {
  148. table.PrimaryKey("PK_BankAccounts", x => x.Id);
  149. table.ForeignKey(
  150. name: "FK_BankAccounts_Banks_BankId",
  151. column: x => x.BankId,
  152. principalTable: "Banks",
  153. principalColumn: "Id",
  154. onDelete: ReferentialAction.Cascade);
  155. table.ForeignKey(
  156. name: "FK_BankAccounts_Individuals_OwnerId",
  157. column: x => x.OwnerId,
  158. principalTable: "Individuals",
  159. principalColumn: "Id",
  160. onDelete: ReferentialAction.Restrict);
  161. });
  162. migrationBuilder.CreateIndex(
  163. name: "IX_Properties_AgencyId",
  164. table: "Properties",
  165. column: "AgencyId");
  166. migrationBuilder.CreateIndex(
  167. name: "IX_Properties_AgentId",
  168. table: "Properties",
  169. column: "AgentId");
  170. migrationBuilder.CreateIndex(
  171. name: "IX_Properties_OwnerId",
  172. table: "Properties",
  173. column: "OwnerId");
  174. migrationBuilder.CreateIndex(
  175. name: "IX_Properties_StatusId",
  176. table: "Properties",
  177. column: "StatusId");
  178. migrationBuilder.CreateIndex(
  179. name: "IX_Individuals_AddressId",
  180. table: "Individuals",
  181. column: "AddressId");
  182. migrationBuilder.CreateIndex(
  183. name: "IX_BankAccounts_BankId",
  184. table: "BankAccounts",
  185. column: "BankId");
  186. migrationBuilder.CreateIndex(
  187. name: "IX_BankAccounts_OwnerId",
  188. table: "BankAccounts",
  189. column: "OwnerId");
  190. migrationBuilder.CreateIndex(
  191. name: "IX_ProcessFlows_PropertyID",
  192. table: "ProcessFlows",
  193. column: "PropertyID");
  194. migrationBuilder.CreateIndex(
  195. name: "IX_ProcessFlows_StatusID",
  196. table: "ProcessFlows",
  197. column: "StatusID");
  198. migrationBuilder.CreateIndex(
  199. name: "IX_ProcessFlows_TimeshareID",
  200. table: "ProcessFlows",
  201. column: "TimeshareID");
  202. migrationBuilder.AddForeignKey(
  203. name: "FK_Agents_Users_UserId",
  204. table: "Agents",
  205. column: "UserId",
  206. principalTable: "Users",
  207. principalColumn: "Id",
  208. onDelete: ReferentialAction.Restrict);
  209. migrationBuilder.AddForeignKey(
  210. name: "FK_Individuals_Addresses_AddressId",
  211. table: "Individuals",
  212. column: "AddressId",
  213. principalTable: "Addresses",
  214. principalColumn: "Id",
  215. onDelete: ReferentialAction.Restrict);
  216. migrationBuilder.AddForeignKey(
  217. name: "FK_Individuals_Users_UserId",
  218. table: "Individuals",
  219. column: "UserId",
  220. principalTable: "Users",
  221. principalColumn: "Id",
  222. onDelete: ReferentialAction.Restrict);
  223. migrationBuilder.AddForeignKey(
  224. name: "FK_Properties_Agencies_AgencyId",
  225. table: "Properties",
  226. column: "AgencyId",
  227. principalTable: "Agencies",
  228. principalColumn: "Id",
  229. onDelete: ReferentialAction.Restrict);
  230. migrationBuilder.AddForeignKey(
  231. name: "FK_Properties_Agents_AgentId",
  232. table: "Properties",
  233. column: "AgentId",
  234. principalTable: "Agents",
  235. principalColumn: "Id",
  236. onDelete: ReferentialAction.Restrict);
  237. migrationBuilder.AddForeignKey(
  238. name: "FK_Properties_Individuals_OwnerId",
  239. table: "Properties",
  240. column: "OwnerId",
  241. principalTable: "Individuals",
  242. principalColumn: "Id",
  243. onDelete: ReferentialAction.Restrict);
  244. migrationBuilder.AddForeignKey(
  245. name: "FK_Properties_Status_StatusId",
  246. table: "Properties",
  247. column: "StatusId",
  248. principalTable: "Status",
  249. principalColumn: "Id",
  250. onDelete: ReferentialAction.Restrict);
  251. }
  252. protected override void Down(MigrationBuilder migrationBuilder)
  253. {
  254. migrationBuilder.DropForeignKey(
  255. name: "FK_Agents_Users_UserId",
  256. table: "Agents");
  257. migrationBuilder.DropForeignKey(
  258. name: "FK_Individuals_Addresses_AddressId",
  259. table: "Individuals");
  260. migrationBuilder.DropForeignKey(
  261. name: "FK_Individuals_Users_UserId",
  262. table: "Individuals");
  263. migrationBuilder.DropForeignKey(
  264. name: "FK_Properties_Agencies_AgencyId",
  265. table: "Properties");
  266. migrationBuilder.DropForeignKey(
  267. name: "FK_Properties_Agents_AgentId",
  268. table: "Properties");
  269. migrationBuilder.DropForeignKey(
  270. name: "FK_Properties_Individuals_OwnerId",
  271. table: "Properties");
  272. migrationBuilder.DropForeignKey(
  273. name: "FK_Properties_Status_StatusId",
  274. table: "Properties");
  275. migrationBuilder.DropTable(
  276. name: "Addresses");
  277. migrationBuilder.DropTable(
  278. name: "BankAccounts");
  279. migrationBuilder.DropTable(
  280. name: "ProcessFlows");
  281. migrationBuilder.DropTable(
  282. name: "Banks");
  283. migrationBuilder.DropIndex(
  284. name: "IX_Properties_AgencyId",
  285. table: "Properties");
  286. migrationBuilder.DropIndex(
  287. name: "IX_Properties_AgentId",
  288. table: "Properties");
  289. migrationBuilder.DropIndex(
  290. name: "IX_Properties_OwnerId",
  291. table: "Properties");
  292. migrationBuilder.DropIndex(
  293. name: "IX_Properties_StatusId",
  294. table: "Properties");
  295. migrationBuilder.DropIndex(
  296. name: "IX_Individuals_AddressId",
  297. table: "Individuals");
  298. migrationBuilder.DropColumn(
  299. name: "AgencyId",
  300. table: "Properties");
  301. migrationBuilder.DropColumn(
  302. name: "AgentId",
  303. table: "Properties");
  304. migrationBuilder.DropColumn(
  305. name: "OwnerId",
  306. table: "Properties");
  307. migrationBuilder.DropColumn(
  308. name: "StatusId",
  309. table: "Properties");
  310. migrationBuilder.DropColumn(
  311. name: "AddressId",
  312. table: "Individuals");
  313. migrationBuilder.DropColumn(
  314. name: "CompanyRegNumber",
  315. table: "Individuals");
  316. migrationBuilder.DropColumn(
  317. name: "IdNumber",
  318. table: "Individuals");
  319. migrationBuilder.DropColumn(
  320. name: "IncomeTaxNumber",
  321. table: "Individuals");
  322. migrationBuilder.DropColumn(
  323. name: "MaritalStatus",
  324. table: "Individuals");
  325. migrationBuilder.AlterColumn<int>(
  326. name: "UserId",
  327. table: "Individuals",
  328. nullable: false,
  329. oldClrType: typeof(int),
  330. oldNullable: true);
  331. migrationBuilder.AlterColumn<int>(
  332. name: "UserId",
  333. table: "Agents",
  334. nullable: false,
  335. oldClrType: typeof(int),
  336. oldNullable: true);
  337. migrationBuilder.AddForeignKey(
  338. name: "FK_Agents_Users_UserId",
  339. table: "Agents",
  340. column: "UserId",
  341. principalTable: "Users",
  342. principalColumn: "Id",
  343. onDelete: ReferentialAction.Cascade);
  344. migrationBuilder.AddForeignKey(
  345. name: "FK_Individuals_Users_UserId",
  346. table: "Individuals",
  347. column: "UserId",
  348. principalTable: "Users",
  349. principalColumn: "Id",
  350. onDelete: ReferentialAction.Cascade);
  351. }
  352. }
  353. }