API
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20190903062247_initial.cs 34KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
  4. namespace UnivateProperties_API.Migrations
  5. {
  6. public partial class initial : Migration
  7. {
  8. protected override void Up(MigrationBuilder migrationBuilder)
  9. {
  10. migrationBuilder.CreateTable(
  11. name: "Agencies",
  12. columns: table => new
  13. {
  14. Id = table.Column<int>(nullable: false)
  15. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  16. Created = table.Column<DateTime>(nullable: false),
  17. Modified = table.Column<DateTime>(nullable: false),
  18. ModifiedBy = table.Column<string>(nullable: true),
  19. AgencyName = table.Column<string>(nullable: true),
  20. EAABEFFCNumber = table.Column<string>(nullable: true),
  21. CompanyRegNumber = table.Column<string>(nullable: true)
  22. },
  23. constraints: table =>
  24. {
  25. table.PrimaryKey("PK_Agencies", x => x.Id);
  26. });
  27. migrationBuilder.CreateTable(
  28. name: "Hosts",
  29. columns: table => new
  30. {
  31. Id = table.Column<int>(nullable: false)
  32. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  33. Created = table.Column<DateTime>(nullable: false),
  34. Modified = table.Column<DateTime>(nullable: false),
  35. ModifiedBy = table.Column<string>(nullable: true),
  36. Host = table.Column<string>(nullable: true),
  37. NeedsAuthorize = table.Column<bool>(nullable: false),
  38. User = table.Column<string>(nullable: true),
  39. Password = table.Column<string>(nullable: true),
  40. UseSSL = table.Column<bool>(nullable: false)
  41. },
  42. constraints: table =>
  43. {
  44. table.PrimaryKey("PK_Hosts", x => x.Id);
  45. });
  46. migrationBuilder.CreateTable(
  47. name: "PropertyTypes",
  48. columns: table => new
  49. {
  50. Id = table.Column<int>(nullable: false)
  51. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  52. Created = table.Column<DateTime>(nullable: false),
  53. Modified = table.Column<DateTime>(nullable: false),
  54. ModifiedBy = table.Column<string>(nullable: true),
  55. Description = table.Column<string>(nullable: true),
  56. UsageType = table.Column<int>(nullable: false)
  57. },
  58. constraints: table =>
  59. {
  60. table.PrimaryKey("PK_PropertyTypes", x => x.Id);
  61. });
  62. migrationBuilder.CreateTable(
  63. name: "Provinces",
  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. Description = table.Column<string>(nullable: true),
  72. Code = table.Column<string>(nullable: true)
  73. },
  74. constraints: table =>
  75. {
  76. table.PrimaryKey("PK_Provinces", x => x.Id);
  77. });
  78. migrationBuilder.CreateTable(
  79. name: "Seasons",
  80. columns: table => new
  81. {
  82. Id = table.Column<int>(nullable: false)
  83. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  84. Created = table.Column<DateTime>(nullable: false),
  85. Modified = table.Column<DateTime>(nullable: false),
  86. ModifiedBy = table.Column<string>(nullable: true),
  87. Name = table.Column<string>(nullable: true)
  88. },
  89. constraints: table =>
  90. {
  91. table.PrimaryKey("PK_Seasons", x => x.Id);
  92. });
  93. migrationBuilder.CreateTable(
  94. name: "Status",
  95. columns: table => new
  96. {
  97. Id = table.Column<int>(nullable: false)
  98. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  99. Created = table.Column<DateTime>(nullable: false),
  100. Modified = table.Column<DateTime>(nullable: false),
  101. ModifiedBy = table.Column<string>(nullable: true),
  102. Code = table.Column<string>(nullable: true),
  103. Description = table.Column<string>(nullable: true),
  104. StatusType = table.Column<int>(nullable: false)
  105. },
  106. constraints: table =>
  107. {
  108. table.PrimaryKey("PK_Status", x => x.Id);
  109. });
  110. migrationBuilder.CreateTable(
  111. name: "UnitConfigurations",
  112. columns: table => new
  113. {
  114. Id = table.Column<int>(nullable: false)
  115. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  116. Created = table.Column<DateTime>(nullable: false),
  117. Modified = table.Column<DateTime>(nullable: false),
  118. ModifiedBy = table.Column<string>(nullable: true),
  119. Code = table.Column<string>(nullable: true),
  120. Bedrooms = table.Column<int>(nullable: false),
  121. Adults = table.Column<int>(nullable: false),
  122. Children = table.Column<int>(nullable: false)
  123. },
  124. constraints: table =>
  125. {
  126. table.PrimaryKey("PK_UnitConfigurations", x => x.Id);
  127. });
  128. migrationBuilder.CreateTable(
  129. name: "UserDefinedGroups",
  130. columns: table => new
  131. {
  132. Id = table.Column<int>(nullable: false)
  133. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  134. Created = table.Column<DateTime>(nullable: false),
  135. Modified = table.Column<DateTime>(nullable: false),
  136. ModifiedBy = table.Column<string>(nullable: true),
  137. Description = table.Column<string>(nullable: true),
  138. UsageType = table.Column<int>(nullable: false),
  139. Rank = table.Column<int>(nullable: false)
  140. },
  141. constraints: table =>
  142. {
  143. table.PrimaryKey("PK_UserDefinedGroups", x => x.Id);
  144. });
  145. migrationBuilder.CreateTable(
  146. name: "Users",
  147. columns: table => new
  148. {
  149. Id = table.Column<int>(nullable: false)
  150. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  151. Created = table.Column<DateTime>(nullable: false),
  152. Modified = table.Column<DateTime>(nullable: false),
  153. ModifiedBy = table.Column<string>(nullable: true),
  154. Name = table.Column<string>(nullable: true),
  155. Surname = table.Column<string>(nullable: true),
  156. Username = table.Column<string>(nullable: true),
  157. Role = table.Column<string>(nullable: true),
  158. PasswordHash = table.Column<byte[]>(nullable: true),
  159. PasswordSalt = table.Column<byte[]>(nullable: true),
  160. Verified = table.Column<bool>(nullable: false),
  161. Token = table.Column<string>(nullable: true)
  162. },
  163. constraints: table =>
  164. {
  165. table.PrimaryKey("PK_Users", x => x.Id);
  166. });
  167. migrationBuilder.CreateTable(
  168. name: "Accounts",
  169. columns: table => new
  170. {
  171. Id = table.Column<int>(nullable: false)
  172. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  173. Created = table.Column<DateTime>(nullable: false),
  174. Modified = table.Column<DateTime>(nullable: false),
  175. ModifiedBy = table.Column<string>(nullable: true),
  176. Address = table.Column<string>(nullable: true),
  177. DisplayName = table.Column<string>(nullable: true),
  178. SMTPHostId = table.Column<int>(nullable: false)
  179. },
  180. constraints: table =>
  181. {
  182. table.PrimaryKey("PK_Accounts", x => x.Id);
  183. table.ForeignKey(
  184. name: "FK_Accounts_Hosts_SMTPHostId",
  185. column: x => x.SMTPHostId,
  186. principalTable: "Hosts",
  187. principalColumn: "Id",
  188. onDelete: ReferentialAction.Cascade);
  189. });
  190. migrationBuilder.CreateTable(
  191. name: "Cities",
  192. columns: table => new
  193. {
  194. Id = table.Column<int>(nullable: false)
  195. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  196. Created = table.Column<DateTime>(nullable: false),
  197. Modified = table.Column<DateTime>(nullable: false),
  198. ModifiedBy = table.Column<string>(nullable: true),
  199. ProvinceId = table.Column<int>(nullable: false),
  200. Description = table.Column<string>(nullable: true),
  201. Code = table.Column<string>(nullable: true)
  202. },
  203. constraints: table =>
  204. {
  205. table.PrimaryKey("PK_Cities", x => x.Id);
  206. table.ForeignKey(
  207. name: "FK_Cities_Provinces_ProvinceId",
  208. column: x => x.ProvinceId,
  209. principalTable: "Provinces",
  210. principalColumn: "Id",
  211. onDelete: ReferentialAction.Cascade);
  212. });
  213. migrationBuilder.CreateTable(
  214. name: "UnitConfigurationTypes",
  215. columns: table => new
  216. {
  217. Id = table.Column<int>(nullable: false)
  218. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  219. Created = table.Column<DateTime>(nullable: false),
  220. Modified = table.Column<DateTime>(nullable: false),
  221. ModifiedBy = table.Column<string>(nullable: true),
  222. Description = table.Column<string>(nullable: true),
  223. UnitConfigurationId = table.Column<int>(nullable: false)
  224. },
  225. constraints: table =>
  226. {
  227. table.PrimaryKey("PK_UnitConfigurationTypes", x => x.Id);
  228. table.ForeignKey(
  229. name: "FK_UnitConfigurationTypes_UnitConfigurations_UnitConfiguration~",
  230. column: x => x.UnitConfigurationId,
  231. principalTable: "UnitConfigurations",
  232. principalColumn: "Id",
  233. onDelete: ReferentialAction.Cascade);
  234. });
  235. migrationBuilder.CreateTable(
  236. name: "UserDefinedFields",
  237. columns: table => new
  238. {
  239. Id = table.Column<int>(nullable: false)
  240. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  241. Created = table.Column<DateTime>(nullable: false),
  242. Modified = table.Column<DateTime>(nullable: false),
  243. ModifiedBy = table.Column<string>(nullable: true),
  244. GroupId = table.Column<int>(nullable: false),
  245. FieldName = table.Column<string>(nullable: true),
  246. FieldType = table.Column<string>(nullable: true),
  247. Rank = table.Column<int>(nullable: false)
  248. },
  249. constraints: table =>
  250. {
  251. table.PrimaryKey("PK_UserDefinedFields", x => x.Id);
  252. table.ForeignKey(
  253. name: "FK_UserDefinedFields_UserDefinedGroups_GroupId",
  254. column: x => x.GroupId,
  255. principalTable: "UserDefinedGroups",
  256. principalColumn: "Id",
  257. onDelete: ReferentialAction.Cascade);
  258. });
  259. migrationBuilder.CreateTable(
  260. name: "Agents",
  261. columns: table => new
  262. {
  263. Id = table.Column<int>(nullable: false)
  264. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  265. Created = table.Column<DateTime>(nullable: false),
  266. Modified = table.Column<DateTime>(nullable: false),
  267. ModifiedBy = table.Column<string>(nullable: true),
  268. UserId = table.Column<int>(nullable: false),
  269. Name = table.Column<string>(nullable: true),
  270. Surname = table.Column<string>(nullable: true),
  271. Email = table.Column<string>(nullable: true),
  272. Telephone = table.Column<string>(nullable: true),
  273. CellNumber = table.Column<string>(nullable: true),
  274. AgencyId = table.Column<int>(nullable: true)
  275. },
  276. constraints: table =>
  277. {
  278. table.PrimaryKey("PK_Agents", x => x.Id);
  279. table.ForeignKey(
  280. name: "FK_Agents_Agencies_AgencyId",
  281. column: x => x.AgencyId,
  282. principalTable: "Agencies",
  283. principalColumn: "Id",
  284. onDelete: ReferentialAction.Restrict);
  285. table.ForeignKey(
  286. name: "FK_Agents_Users_UserId",
  287. column: x => x.UserId,
  288. principalTable: "Users",
  289. principalColumn: "Id",
  290. onDelete: ReferentialAction.Cascade);
  291. });
  292. migrationBuilder.CreateTable(
  293. name: "Individuals",
  294. columns: table => new
  295. {
  296. Id = table.Column<int>(nullable: false)
  297. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  298. Created = table.Column<DateTime>(nullable: false),
  299. Modified = table.Column<DateTime>(nullable: false),
  300. ModifiedBy = table.Column<string>(nullable: true),
  301. UserId = table.Column<int>(nullable: false),
  302. Name = table.Column<string>(nullable: true),
  303. Surname = table.Column<string>(nullable: true),
  304. Email = table.Column<string>(nullable: true),
  305. Telephone = table.Column<string>(nullable: true),
  306. CellNumber = table.Column<string>(nullable: true)
  307. },
  308. constraints: table =>
  309. {
  310. table.PrimaryKey("PK_Individuals", x => x.Id);
  311. table.ForeignKey(
  312. name: "FK_Individuals_Users_UserId",
  313. column: x => x.UserId,
  314. principalTable: "Users",
  315. principalColumn: "Id",
  316. onDelete: ReferentialAction.Cascade);
  317. });
  318. migrationBuilder.CreateTable(
  319. name: "Emails",
  320. columns: table => new
  321. {
  322. Id = table.Column<int>(nullable: false)
  323. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  324. Created = table.Column<DateTime>(nullable: false),
  325. Modified = table.Column<DateTime>(nullable: false),
  326. ModifiedBy = table.Column<string>(nullable: true),
  327. SenderId = table.Column<int>(nullable: false),
  328. Comment = table.Column<string>(nullable: true),
  329. Subject = table.Column<string>(nullable: true),
  330. IsBodyHtml = table.Column<bool>(nullable: false),
  331. CC = table.Column<string>(nullable: true),
  332. BCC = table.Column<string>(nullable: true),
  333. Body = table.Column<string>(nullable: true),
  334. To = table.Column<string>(nullable: true),
  335. ToDisplay = table.Column<string>(nullable: true)
  336. },
  337. constraints: table =>
  338. {
  339. table.PrimaryKey("PK_Emails", x => x.Id);
  340. table.ForeignKey(
  341. name: "FK_Emails_Accounts_SenderId",
  342. column: x => x.SenderId,
  343. principalTable: "Accounts",
  344. principalColumn: "Id",
  345. onDelete: ReferentialAction.Cascade);
  346. });
  347. migrationBuilder.CreateTable(
  348. name: "Suburbs",
  349. columns: table => new
  350. {
  351. Id = table.Column<int>(nullable: false)
  352. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  353. Created = table.Column<DateTime>(nullable: false),
  354. Modified = table.Column<DateTime>(nullable: false),
  355. ModifiedBy = table.Column<string>(nullable: true),
  356. CityId = table.Column<int>(nullable: false),
  357. Description = table.Column<string>(nullable: true),
  358. PostalCode = table.Column<string>(nullable: true)
  359. },
  360. constraints: table =>
  361. {
  362. table.PrimaryKey("PK_Suburbs", x => x.Id);
  363. table.ForeignKey(
  364. name: "FK_Suburbs_Cities_CityId",
  365. column: x => x.CityId,
  366. principalTable: "Cities",
  367. principalColumn: "Id",
  368. onDelete: ReferentialAction.Cascade);
  369. });
  370. migrationBuilder.CreateTable(
  371. name: "Weeks",
  372. columns: table => new
  373. {
  374. Id = table.Column<int>(nullable: false)
  375. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  376. Created = table.Column<DateTime>(nullable: false),
  377. Modified = table.Column<DateTime>(nullable: false),
  378. ModifiedBy = table.Column<string>(nullable: true),
  379. ReferedByAgent = table.Column<bool>(nullable: false),
  380. AgentId = table.Column<int>(nullable: true),
  381. AgencyId = table.Column<int>(nullable: true),
  382. OwnerId = table.Column<int>(nullable: false),
  383. OtherResort = table.Column<bool>(nullable: false),
  384. ResortCode = table.Column<string>(nullable: true),
  385. ResortName = table.Column<string>(nullable: true),
  386. RegionId = table.Column<int>(nullable: false),
  387. Season = table.Column<string>(nullable: true),
  388. Module = table.Column<string>(nullable: true),
  389. Bedrooms = table.Column<int>(nullable: false),
  390. MaxSleep = table.Column<int>(nullable: false),
  391. WeekNumber = table.Column<string>(nullable: true),
  392. LevyAmount = table.Column<double>(nullable: false),
  393. CurrentYearBanked = table.Column<bool>(nullable: false),
  394. BankedWith = table.Column<string>(nullable: true),
  395. LeviesPaidInFull = table.Column<bool>(nullable: false),
  396. WeekPlacedForRental = table.Column<bool>(nullable: false),
  397. OriginalPurchasePrice = table.Column<double>(nullable: false),
  398. OriginalPurchaseDate = table.Column<DateTime>(nullable: false),
  399. ArrivalDate = table.Column<DateTime>(nullable: false),
  400. DepartureDate = table.Column<DateTime>(nullable: false),
  401. StatusId = table.Column<int>(nullable: false)
  402. },
  403. constraints: table =>
  404. {
  405. table.PrimaryKey("PK_Weeks", x => x.Id);
  406. table.ForeignKey(
  407. name: "FK_Weeks_Agencies_AgencyId",
  408. column: x => x.AgencyId,
  409. principalTable: "Agencies",
  410. principalColumn: "Id",
  411. onDelete: ReferentialAction.Restrict);
  412. table.ForeignKey(
  413. name: "FK_Weeks_Agents_AgentId",
  414. column: x => x.AgentId,
  415. principalTable: "Agents",
  416. principalColumn: "Id",
  417. onDelete: ReferentialAction.Restrict);
  418. table.ForeignKey(
  419. name: "FK_Weeks_Users_OwnerId",
  420. column: x => x.OwnerId,
  421. principalTable: "Users",
  422. principalColumn: "Id",
  423. onDelete: ReferentialAction.Cascade);
  424. table.ForeignKey(
  425. name: "FK_Weeks_Provinces_RegionId",
  426. column: x => x.RegionId,
  427. principalTable: "Provinces",
  428. principalColumn: "Id",
  429. onDelete: ReferentialAction.Cascade);
  430. table.ForeignKey(
  431. name: "FK_Weeks_Status_StatusId",
  432. column: x => x.StatusId,
  433. principalTable: "Status",
  434. principalColumn: "Id",
  435. onDelete: ReferentialAction.Cascade);
  436. });
  437. migrationBuilder.CreateTable(
  438. name: "Properties",
  439. columns: table => new
  440. {
  441. Id = table.Column<int>(nullable: false)
  442. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  443. Created = table.Column<DateTime>(nullable: false),
  444. Modified = table.Column<DateTime>(nullable: false),
  445. ModifiedBy = table.Column<string>(nullable: true),
  446. CreatedBy = table.Column<string>(nullable: true),
  447. PropertyTypeId = table.Column<int>(nullable: false),
  448. PropertyName = table.Column<string>(nullable: true),
  449. Unit = table.Column<string>(nullable: true),
  450. OperationalCosts = table.Column<decimal>(nullable: false),
  451. Price = table.Column<decimal>(nullable: false),
  452. PricePer = table.Column<string>(nullable: true),
  453. IsSale = table.Column<bool>(nullable: false),
  454. Description = table.Column<string>(nullable: true),
  455. ShortDescription = table.Column<string>(nullable: true),
  456. AddressLine1 = table.Column<string>(nullable: true),
  457. AddressLine2 = table.Column<string>(nullable: true),
  458. AddressLine3 = table.Column<string>(nullable: true),
  459. SuburbId = table.Column<int>(nullable: false),
  460. CityId = table.Column<int>(nullable: false),
  461. ProvinceId = table.Column<int>(nullable: false),
  462. Published = table.Column<bool>(nullable: false)
  463. },
  464. constraints: table =>
  465. {
  466. table.PrimaryKey("PK_Properties", x => x.Id);
  467. table.ForeignKey(
  468. name: "FK_Properties_Cities_CityId",
  469. column: x => x.CityId,
  470. principalTable: "Cities",
  471. principalColumn: "Id",
  472. onDelete: ReferentialAction.Cascade);
  473. table.ForeignKey(
  474. name: "FK_Properties_PropertyTypes_PropertyTypeId",
  475. column: x => x.PropertyTypeId,
  476. principalTable: "PropertyTypes",
  477. principalColumn: "Id",
  478. onDelete: ReferentialAction.Cascade);
  479. table.ForeignKey(
  480. name: "FK_Properties_Provinces_ProvinceId",
  481. column: x => x.ProvinceId,
  482. principalTable: "Provinces",
  483. principalColumn: "Id",
  484. onDelete: ReferentialAction.Cascade);
  485. table.ForeignKey(
  486. name: "FK_Properties_Suburbs_SuburbId",
  487. column: x => x.SuburbId,
  488. principalTable: "Suburbs",
  489. principalColumn: "Id",
  490. onDelete: ReferentialAction.Cascade);
  491. });
  492. migrationBuilder.CreateTable(
  493. name: "PropertyImages",
  494. columns: table => new
  495. {
  496. Id = table.Column<int>(nullable: false)
  497. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  498. Created = table.Column<DateTime>(nullable: false),
  499. Modified = table.Column<DateTime>(nullable: false),
  500. ModifiedBy = table.Column<string>(nullable: true),
  501. PropertyId = table.Column<int>(nullable: false),
  502. Image = table.Column<string>(nullable: true),
  503. IsDefault = table.Column<bool>(nullable: false)
  504. },
  505. constraints: table =>
  506. {
  507. table.PrimaryKey("PK_PropertyImages", x => x.Id);
  508. table.ForeignKey(
  509. name: "FK_PropertyImages_Properties_PropertyId",
  510. column: x => x.PropertyId,
  511. principalTable: "Properties",
  512. principalColumn: "Id",
  513. onDelete: ReferentialAction.Cascade);
  514. });
  515. migrationBuilder.CreateTable(
  516. name: "PropertyUserFields",
  517. columns: table => new
  518. {
  519. Id = table.Column<int>(nullable: false)
  520. .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
  521. Created = table.Column<DateTime>(nullable: false),
  522. Modified = table.Column<DateTime>(nullable: false),
  523. ModifiedBy = table.Column<string>(nullable: true),
  524. PropertyId = table.Column<int>(nullable: false),
  525. UserDefinedFieldId = table.Column<int>(nullable: false),
  526. Value = table.Column<string>(nullable: true),
  527. Description = table.Column<string>(nullable: true)
  528. },
  529. constraints: table =>
  530. {
  531. table.PrimaryKey("PK_PropertyUserFields", x => x.Id);
  532. table.ForeignKey(
  533. name: "FK_PropertyUserFields_Properties_PropertyId",
  534. column: x => x.PropertyId,
  535. principalTable: "Properties",
  536. principalColumn: "Id",
  537. onDelete: ReferentialAction.Cascade);
  538. table.ForeignKey(
  539. name: "FK_PropertyUserFields_UserDefinedFields_UserDefinedFieldId",
  540. column: x => x.UserDefinedFieldId,
  541. principalTable: "UserDefinedFields",
  542. principalColumn: "Id",
  543. onDelete: ReferentialAction.Cascade);
  544. });
  545. migrationBuilder.CreateIndex(
  546. name: "IX_Accounts_SMTPHostId",
  547. table: "Accounts",
  548. column: "SMTPHostId");
  549. migrationBuilder.CreateIndex(
  550. name: "IX_Agents_AgencyId",
  551. table: "Agents",
  552. column: "AgencyId");
  553. migrationBuilder.CreateIndex(
  554. name: "IX_Agents_UserId",
  555. table: "Agents",
  556. column: "UserId");
  557. migrationBuilder.CreateIndex(
  558. name: "IX_Cities_ProvinceId",
  559. table: "Cities",
  560. column: "ProvinceId");
  561. migrationBuilder.CreateIndex(
  562. name: "IX_Emails_SenderId",
  563. table: "Emails",
  564. column: "SenderId");
  565. migrationBuilder.CreateIndex(
  566. name: "IX_Individuals_UserId",
  567. table: "Individuals",
  568. column: "UserId");
  569. migrationBuilder.CreateIndex(
  570. name: "IX_Properties_CityId",
  571. table: "Properties",
  572. column: "CityId");
  573. migrationBuilder.CreateIndex(
  574. name: "IX_Properties_PropertyTypeId",
  575. table: "Properties",
  576. column: "PropertyTypeId");
  577. migrationBuilder.CreateIndex(
  578. name: "IX_Properties_ProvinceId",
  579. table: "Properties",
  580. column: "ProvinceId");
  581. migrationBuilder.CreateIndex(
  582. name: "IX_Properties_SuburbId",
  583. table: "Properties",
  584. column: "SuburbId");
  585. migrationBuilder.CreateIndex(
  586. name: "IX_PropertyImages_PropertyId",
  587. table: "PropertyImages",
  588. column: "PropertyId");
  589. migrationBuilder.CreateIndex(
  590. name: "IX_PropertyUserFields_PropertyId",
  591. table: "PropertyUserFields",
  592. column: "PropertyId");
  593. migrationBuilder.CreateIndex(
  594. name: "IX_PropertyUserFields_UserDefinedFieldId",
  595. table: "PropertyUserFields",
  596. column: "UserDefinedFieldId");
  597. migrationBuilder.CreateIndex(
  598. name: "IX_Suburbs_CityId",
  599. table: "Suburbs",
  600. column: "CityId");
  601. migrationBuilder.CreateIndex(
  602. name: "IX_UnitConfigurations_Code",
  603. table: "UnitConfigurations",
  604. column: "Code",
  605. unique: true);
  606. migrationBuilder.CreateIndex(
  607. name: "IX_UnitConfigurationTypes_UnitConfigurationId",
  608. table: "UnitConfigurationTypes",
  609. column: "UnitConfigurationId");
  610. migrationBuilder.CreateIndex(
  611. name: "IX_UserDefinedFields_GroupId",
  612. table: "UserDefinedFields",
  613. column: "GroupId");
  614. migrationBuilder.CreateIndex(
  615. name: "IX_Weeks_AgencyId",
  616. table: "Weeks",
  617. column: "AgencyId");
  618. migrationBuilder.CreateIndex(
  619. name: "IX_Weeks_AgentId",
  620. table: "Weeks",
  621. column: "AgentId");
  622. migrationBuilder.CreateIndex(
  623. name: "IX_Weeks_OwnerId",
  624. table: "Weeks",
  625. column: "OwnerId");
  626. migrationBuilder.CreateIndex(
  627. name: "IX_Weeks_RegionId",
  628. table: "Weeks",
  629. column: "RegionId");
  630. migrationBuilder.CreateIndex(
  631. name: "IX_Weeks_StatusId",
  632. table: "Weeks",
  633. column: "StatusId");
  634. }
  635. protected override void Down(MigrationBuilder migrationBuilder)
  636. {
  637. migrationBuilder.DropTable(
  638. name: "Emails");
  639. migrationBuilder.DropTable(
  640. name: "Individuals");
  641. migrationBuilder.DropTable(
  642. name: "PropertyImages");
  643. migrationBuilder.DropTable(
  644. name: "PropertyUserFields");
  645. migrationBuilder.DropTable(
  646. name: "Seasons");
  647. migrationBuilder.DropTable(
  648. name: "UnitConfigurationTypes");
  649. migrationBuilder.DropTable(
  650. name: "Weeks");
  651. migrationBuilder.DropTable(
  652. name: "Accounts");
  653. migrationBuilder.DropTable(
  654. name: "Properties");
  655. migrationBuilder.DropTable(
  656. name: "UserDefinedFields");
  657. migrationBuilder.DropTable(
  658. name: "UnitConfigurations");
  659. migrationBuilder.DropTable(
  660. name: "Agents");
  661. migrationBuilder.DropTable(
  662. name: "Status");
  663. migrationBuilder.DropTable(
  664. name: "Hosts");
  665. migrationBuilder.DropTable(
  666. name: "PropertyTypes");
  667. migrationBuilder.DropTable(
  668. name: "Suburbs");
  669. migrationBuilder.DropTable(
  670. name: "UserDefinedGroups");
  671. migrationBuilder.DropTable(
  672. name: "Agencies");
  673. migrationBuilder.DropTable(
  674. name: "Users");
  675. migrationBuilder.DropTable(
  676. name: "Cities");
  677. migrationBuilder.DropTable(
  678. name: "Provinces");
  679. }
  680. }
  681. }