API
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

20190828083244_1124.cs 34KB

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