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

20190904110840_Initial.cs 34KB

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