API

20200625115738_SQL_DB_Create.cs 68KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Metadata;
  3. using Microsoft.EntityFrameworkCore.Migrations;
  4. namespace UnivateProperties_API.Migrations
  5. {
  6. public partial class SQL_DB_Create : 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("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  16. Created = table.Column<DateTime>(nullable: false),
  17. Modified = table.Column<DateTime>(nullable: false),
  18. ModifiedBy = table.Column<string>(nullable: true),
  19. IsDeleted = table.Column<bool>(nullable: false),
  20. AgencyName = table.Column<string>(nullable: true),
  21. EAABEFFCNumber = table.Column<string>(nullable: true),
  22. CompanyRegNumber = table.Column<string>(nullable: true)
  23. },
  24. constraints: table =>
  25. {
  26. table.PrimaryKey("PK_Agencies", x => x.Id);
  27. });
  28. migrationBuilder.CreateTable(
  29. name: "Banks",
  30. columns: table => new
  31. {
  32. Id = table.Column<int>(nullable: false)
  33. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  34. Created = table.Column<DateTime>(nullable: false),
  35. Modified = table.Column<DateTime>(nullable: false),
  36. ModifiedBy = table.Column<string>(nullable: true),
  37. IsDeleted = table.Column<bool>(nullable: false),
  38. Name = table.Column<string>(nullable: true),
  39. UniversalBranchCode = table.Column<string>(nullable: true)
  40. },
  41. constraints: table =>
  42. {
  43. table.PrimaryKey("PK_Banks", x => x.Id);
  44. });
  45. migrationBuilder.CreateTable(
  46. name: "Campaigns",
  47. columns: table => new
  48. {
  49. Id = table.Column<int>(nullable: false)
  50. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  51. Created = table.Column<DateTime>(nullable: false),
  52. Modified = table.Column<DateTime>(nullable: false),
  53. ModifiedBy = table.Column<string>(nullable: true),
  54. IsDeleted = table.Column<bool>(nullable: false),
  55. StartDate = table.Column<DateTime>(nullable: false),
  56. EndDate = table.Column<DateTime>(nullable: false),
  57. Name = table.Column<string>(nullable: true),
  58. Subject = table.Column<string>(nullable: true),
  59. Body = table.Column<string>(nullable: true),
  60. ItemBody = table.Column<string>(nullable: true),
  61. ItemsPerRow = table.Column<int>(nullable: false)
  62. },
  63. constraints: table =>
  64. {
  65. table.PrimaryKey("PK_Campaigns", x => x.Id);
  66. });
  67. migrationBuilder.CreateTable(
  68. name: "Carousel",
  69. columns: table => new
  70. {
  71. Id = table.Column<int>(nullable: false)
  72. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  73. Created = table.Column<DateTime>(nullable: false),
  74. Modified = table.Column<DateTime>(nullable: false),
  75. ModifiedBy = table.Column<string>(nullable: true),
  76. IsDeleted = table.Column<bool>(nullable: false),
  77. PropertyId = table.Column<int>(nullable: false),
  78. TimeshareId = table.Column<int>(nullable: false),
  79. Header = table.Column<string>(nullable: true),
  80. Image = table.Column<string>(nullable: true)
  81. },
  82. constraints: table =>
  83. {
  84. table.PrimaryKey("PK_Carousel", x => x.Id);
  85. });
  86. migrationBuilder.CreateTable(
  87. name: "Defaults",
  88. columns: table => new
  89. {
  90. Id = table.Column<string>(nullable: false),
  91. Value = table.Column<string>(nullable: true)
  92. },
  93. constraints: table =>
  94. {
  95. table.PrimaryKey("PK_Defaults", x => x.Id);
  96. });
  97. migrationBuilder.CreateTable(
  98. name: "Hosts",
  99. columns: table => new
  100. {
  101. Id = table.Column<int>(nullable: false)
  102. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  103. Created = table.Column<DateTime>(nullable: false),
  104. Modified = table.Column<DateTime>(nullable: false),
  105. ModifiedBy = table.Column<string>(nullable: true),
  106. IsDeleted = table.Column<bool>(nullable: false),
  107. Host = table.Column<string>(nullable: true),
  108. NeedsAuthorize = table.Column<bool>(nullable: false),
  109. User = table.Column<string>(nullable: true),
  110. Password = table.Column<string>(nullable: true),
  111. UseSSL = table.Column<bool>(nullable: false)
  112. },
  113. constraints: table =>
  114. {
  115. table.PrimaryKey("PK_Hosts", x => x.Id);
  116. });
  117. migrationBuilder.CreateTable(
  118. name: "Location",
  119. columns: table => new
  120. {
  121. Id = table.Column<int>(nullable: false)
  122. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  123. Created = table.Column<DateTime>(nullable: false),
  124. Modified = table.Column<DateTime>(nullable: false),
  125. ModifiedBy = table.Column<string>(nullable: true),
  126. IsDeleted = table.Column<bool>(nullable: false),
  127. IsTesting = table.Column<bool>(nullable: false),
  128. PropertyImageLocation = table.Column<string>(nullable: true)
  129. },
  130. constraints: table =>
  131. {
  132. table.PrimaryKey("PK_Location", x => x.Id);
  133. });
  134. migrationBuilder.CreateTable(
  135. name: "PlaceHolderFormats",
  136. columns: table => new
  137. {
  138. Id = table.Column<int>(nullable: false)
  139. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  140. Created = table.Column<DateTime>(nullable: false),
  141. Modified = table.Column<DateTime>(nullable: false),
  142. ModifiedBy = table.Column<string>(nullable: true),
  143. IsDeleted = table.Column<bool>(nullable: false),
  144. DisplayName = table.Column<string>(nullable: true),
  145. Format = table.Column<string>(nullable: true)
  146. },
  147. constraints: table =>
  148. {
  149. table.PrimaryKey("PK_PlaceHolderFormats", x => x.Id);
  150. });
  151. migrationBuilder.CreateTable(
  152. name: "PropertyTypes",
  153. columns: table => new
  154. {
  155. Id = table.Column<int>(nullable: false)
  156. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  157. Created = table.Column<DateTime>(nullable: false),
  158. Modified = table.Column<DateTime>(nullable: false),
  159. ModifiedBy = table.Column<string>(nullable: true),
  160. IsDeleted = table.Column<bool>(nullable: false),
  161. Description = table.Column<string>(nullable: true),
  162. UsageType = table.Column<int>(nullable: false)
  163. },
  164. constraints: table =>
  165. {
  166. table.PrimaryKey("PK_PropertyTypes", x => x.Id);
  167. });
  168. migrationBuilder.CreateTable(
  169. name: "Provinces",
  170. columns: table => new
  171. {
  172. Id = table.Column<int>(nullable: false)
  173. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  174. Created = table.Column<DateTime>(nullable: false),
  175. Modified = table.Column<DateTime>(nullable: false),
  176. ModifiedBy = table.Column<string>(nullable: true),
  177. IsDeleted = table.Column<bool>(nullable: false),
  178. Description = table.Column<string>(nullable: true),
  179. Code = table.Column<string>(nullable: true)
  180. },
  181. constraints: table =>
  182. {
  183. table.PrimaryKey("PK_Provinces", x => x.Id);
  184. });
  185. migrationBuilder.CreateTable(
  186. name: "SearchLogs",
  187. columns: table => new
  188. {
  189. Id = table.Column<int>(nullable: false)
  190. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  191. Created = table.Column<DateTime>(nullable: false),
  192. Modified = table.Column<DateTime>(nullable: false),
  193. ModifiedBy = table.Column<string>(nullable: true),
  194. IsDeleted = table.Column<bool>(nullable: false),
  195. Type = table.Column<string>(nullable: true),
  196. Search = table.Column<string>(nullable: true)
  197. },
  198. constraints: table =>
  199. {
  200. table.PrimaryKey("PK_SearchLogs", x => x.Id);
  201. });
  202. migrationBuilder.CreateTable(
  203. name: "Seasons",
  204. columns: table => new
  205. {
  206. Id = table.Column<int>(nullable: false)
  207. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  208. Created = table.Column<DateTime>(nullable: false),
  209. Modified = table.Column<DateTime>(nullable: false),
  210. ModifiedBy = table.Column<string>(nullable: true),
  211. IsDeleted = table.Column<bool>(nullable: false),
  212. Name = table.Column<string>(nullable: true)
  213. },
  214. constraints: table =>
  215. {
  216. table.PrimaryKey("PK_Seasons", x => x.Id);
  217. });
  218. migrationBuilder.CreateTable(
  219. name: "Status",
  220. columns: table => new
  221. {
  222. Id = table.Column<int>(nullable: false)
  223. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  224. Created = table.Column<DateTime>(nullable: false),
  225. Modified = table.Column<DateTime>(nullable: false),
  226. ModifiedBy = table.Column<string>(nullable: true),
  227. IsDeleted = table.Column<bool>(nullable: false),
  228. Code = table.Column<string>(nullable: true),
  229. Description = table.Column<string>(nullable: true),
  230. StatusType = table.Column<int>(nullable: false)
  231. },
  232. constraints: table =>
  233. {
  234. table.PrimaryKey("PK_Status", x => x.Id);
  235. });
  236. migrationBuilder.CreateTable(
  237. name: "UnitConfigurations",
  238. columns: table => new
  239. {
  240. Id = table.Column<int>(nullable: false)
  241. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  242. Created = table.Column<DateTime>(nullable: false),
  243. Modified = table.Column<DateTime>(nullable: false),
  244. ModifiedBy = table.Column<string>(nullable: true),
  245. IsDeleted = table.Column<bool>(nullable: false),
  246. Code = table.Column<string>(nullable: true),
  247. Bedrooms = table.Column<int>(nullable: false),
  248. Adults = table.Column<int>(nullable: false),
  249. Children = table.Column<int>(nullable: false)
  250. },
  251. constraints: table =>
  252. {
  253. table.PrimaryKey("PK_UnitConfigurations", x => x.Id);
  254. });
  255. migrationBuilder.CreateTable(
  256. name: "UserDefinedGroups",
  257. columns: table => new
  258. {
  259. Id = table.Column<int>(nullable: false)
  260. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  261. Created = table.Column<DateTime>(nullable: false),
  262. Modified = table.Column<DateTime>(nullable: false),
  263. ModifiedBy = table.Column<string>(nullable: true),
  264. IsDeleted = table.Column<bool>(nullable: false),
  265. Description = table.Column<string>(nullable: true),
  266. UsageType = table.Column<int>(nullable: false),
  267. Rank = table.Column<int>(nullable: false)
  268. },
  269. constraints: table =>
  270. {
  271. table.PrimaryKey("PK_UserDefinedGroups", x => x.Id);
  272. });
  273. migrationBuilder.CreateTable(
  274. name: "Users",
  275. columns: table => new
  276. {
  277. Id = table.Column<int>(nullable: false)
  278. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  279. Created = table.Column<DateTime>(nullable: false),
  280. Modified = table.Column<DateTime>(nullable: false),
  281. ModifiedBy = table.Column<string>(nullable: true),
  282. IsDeleted = table.Column<bool>(nullable: false),
  283. Username = table.Column<string>(nullable: true),
  284. Role = table.Column<string>(nullable: true),
  285. PasswordHash = table.Column<byte[]>(nullable: true),
  286. PasswordSalt = table.Column<byte[]>(nullable: true),
  287. Verified = table.Column<bool>(nullable: false),
  288. Token = table.Column<string>(nullable: true)
  289. },
  290. constraints: table =>
  291. {
  292. table.PrimaryKey("PK_Users", x => x.Id);
  293. });
  294. migrationBuilder.CreateTable(
  295. name: "CampaignPlaceHolders",
  296. columns: table => new
  297. {
  298. Id = table.Column<int>(nullable: false)
  299. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  300. Created = table.Column<DateTime>(nullable: false),
  301. Modified = table.Column<DateTime>(nullable: false),
  302. ModifiedBy = table.Column<string>(nullable: true),
  303. IsDeleted = table.Column<bool>(nullable: false),
  304. Name = table.Column<string>(nullable: true),
  305. BoundToClass = table.Column<string>(nullable: true),
  306. BoundToClassDisplay = table.Column<string>(nullable: true),
  307. BoundTo = table.Column<string>(nullable: true),
  308. Format = table.Column<string>(nullable: true),
  309. CampaignId = table.Column<int>(nullable: false)
  310. },
  311. constraints: table =>
  312. {
  313. table.PrimaryKey("PK_CampaignPlaceHolders", x => x.Id);
  314. table.ForeignKey(
  315. name: "FK_CampaignPlaceHolders_Campaigns_CampaignId",
  316. column: x => x.CampaignId,
  317. principalTable: "Campaigns",
  318. principalColumn: "Id",
  319. onDelete: ReferentialAction.Cascade);
  320. });
  321. migrationBuilder.CreateTable(
  322. name: "Accounts",
  323. columns: table => new
  324. {
  325. Id = table.Column<int>(nullable: false)
  326. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  327. Created = table.Column<DateTime>(nullable: false),
  328. Modified = table.Column<DateTime>(nullable: false),
  329. ModifiedBy = table.Column<string>(nullable: true),
  330. IsDeleted = table.Column<bool>(nullable: false),
  331. Address = table.Column<string>(nullable: true),
  332. DisplayName = table.Column<string>(nullable: true),
  333. Default = table.Column<bool>(nullable: false),
  334. SMTPHostId = table.Column<int>(nullable: false)
  335. },
  336. constraints: table =>
  337. {
  338. table.PrimaryKey("PK_Accounts", x => x.Id);
  339. table.ForeignKey(
  340. name: "FK_Accounts_Hosts_SMTPHostId",
  341. column: x => x.SMTPHostId,
  342. principalTable: "Hosts",
  343. principalColumn: "Id",
  344. onDelete: ReferentialAction.Cascade);
  345. });
  346. migrationBuilder.CreateTable(
  347. name: "Cities",
  348. columns: table => new
  349. {
  350. Id = table.Column<int>(nullable: false)
  351. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  352. Created = table.Column<DateTime>(nullable: false),
  353. Modified = table.Column<DateTime>(nullable: false),
  354. ModifiedBy = table.Column<string>(nullable: true),
  355. IsDeleted = table.Column<bool>(nullable: false),
  356. ProvinceId = table.Column<int>(nullable: false),
  357. Description = table.Column<string>(nullable: true),
  358. Code = table.Column<string>(nullable: true)
  359. },
  360. constraints: table =>
  361. {
  362. table.PrimaryKey("PK_Cities", x => x.Id);
  363. table.ForeignKey(
  364. name: "FK_Cities_Provinces_ProvinceId",
  365. column: x => x.ProvinceId,
  366. principalTable: "Provinces",
  367. principalColumn: "Id",
  368. onDelete: ReferentialAction.Cascade);
  369. });
  370. migrationBuilder.CreateTable(
  371. name: "UnitConfigurationTypes",
  372. columns: table => new
  373. {
  374. Id = table.Column<int>(nullable: false)
  375. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  376. Created = table.Column<DateTime>(nullable: false),
  377. Modified = table.Column<DateTime>(nullable: false),
  378. ModifiedBy = table.Column<string>(nullable: true),
  379. IsDeleted = table.Column<bool>(nullable: false),
  380. Description = table.Column<string>(nullable: true),
  381. UnitConfigurationId = table.Column<int>(nullable: false)
  382. },
  383. constraints: table =>
  384. {
  385. table.PrimaryKey("PK_UnitConfigurationTypes", x => x.Id);
  386. table.ForeignKey(
  387. name: "FK_UnitConfigurationTypes_UnitConfigurations_UnitConfigurationId",
  388. column: x => x.UnitConfigurationId,
  389. principalTable: "UnitConfigurations",
  390. principalColumn: "Id",
  391. onDelete: ReferentialAction.Cascade);
  392. });
  393. migrationBuilder.CreateTable(
  394. name: "UserDefinedFields",
  395. columns: table => new
  396. {
  397. Id = table.Column<int>(nullable: false)
  398. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  399. Created = table.Column<DateTime>(nullable: false),
  400. Modified = table.Column<DateTime>(nullable: false),
  401. ModifiedBy = table.Column<string>(nullable: true),
  402. IsDeleted = table.Column<bool>(nullable: false),
  403. GroupId = table.Column<int>(nullable: false),
  404. FieldName = table.Column<string>(nullable: true),
  405. FieldType = table.Column<string>(nullable: true),
  406. Rank = table.Column<int>(nullable: false)
  407. },
  408. constraints: table =>
  409. {
  410. table.PrimaryKey("PK_UserDefinedFields", x => x.Id);
  411. table.ForeignKey(
  412. name: "FK_UserDefinedFields_UserDefinedGroups_GroupId",
  413. column: x => x.GroupId,
  414. principalTable: "UserDefinedGroups",
  415. principalColumn: "Id",
  416. onDelete: ReferentialAction.Cascade);
  417. });
  418. migrationBuilder.CreateTable(
  419. name: "Person",
  420. columns: table => new
  421. {
  422. Id = table.Column<int>(nullable: false)
  423. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  424. Created = table.Column<DateTime>(nullable: false),
  425. Modified = table.Column<DateTime>(nullable: false),
  426. ModifiedBy = table.Column<string>(nullable: true),
  427. IsDeleted = table.Column<bool>(nullable: false),
  428. UserId = table.Column<int>(nullable: true),
  429. Name = table.Column<string>(nullable: true),
  430. Surname = table.Column<string>(nullable: true),
  431. Email = table.Column<string>(nullable: true),
  432. Telephone = table.Column<string>(nullable: true),
  433. CellNumber = table.Column<string>(nullable: true)
  434. },
  435. constraints: table =>
  436. {
  437. table.PrimaryKey("PK_Person", x => x.Id);
  438. table.ForeignKey(
  439. name: "FK_Person_Users_UserId",
  440. column: x => x.UserId,
  441. principalTable: "Users",
  442. principalColumn: "Id",
  443. onDelete: ReferentialAction.Restrict);
  444. });
  445. migrationBuilder.CreateTable(
  446. name: "Emails",
  447. columns: table => new
  448. {
  449. Id = table.Column<int>(nullable: false)
  450. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  451. Created = table.Column<DateTime>(nullable: false),
  452. Modified = table.Column<DateTime>(nullable: false),
  453. ModifiedBy = table.Column<string>(nullable: true),
  454. IsDeleted = table.Column<bool>(nullable: false),
  455. SenderId = table.Column<int>(nullable: false),
  456. Comment = table.Column<string>(nullable: true),
  457. Subject = table.Column<string>(nullable: true),
  458. IsBodyHtml = table.Column<bool>(nullable: false),
  459. CC = table.Column<string>(nullable: true),
  460. BCC = table.Column<string>(nullable: true),
  461. Body = table.Column<string>(nullable: true),
  462. To = table.Column<string>(nullable: true),
  463. ToDisplay = table.Column<string>(nullable: true)
  464. },
  465. constraints: table =>
  466. {
  467. table.PrimaryKey("PK_Emails", x => x.Id);
  468. table.ForeignKey(
  469. name: "FK_Emails_Accounts_SenderId",
  470. column: x => x.SenderId,
  471. principalTable: "Accounts",
  472. principalColumn: "Id",
  473. onDelete: ReferentialAction.Cascade);
  474. });
  475. migrationBuilder.CreateTable(
  476. name: "Templates",
  477. columns: table => new
  478. {
  479. Id = table.Column<int>(nullable: false)
  480. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  481. Created = table.Column<DateTime>(nullable: false),
  482. Modified = table.Column<DateTime>(nullable: false),
  483. ModifiedBy = table.Column<string>(nullable: true),
  484. IsDeleted = table.Column<bool>(nullable: false),
  485. Name = table.Column<string>(nullable: true),
  486. Subject = table.Column<string>(nullable: true),
  487. Body = table.Column<string>(nullable: true),
  488. SenderId = table.Column<int>(nullable: true)
  489. },
  490. constraints: table =>
  491. {
  492. table.PrimaryKey("PK_Templates", x => x.Id);
  493. table.ForeignKey(
  494. name: "FK_Templates_Accounts_SenderId",
  495. column: x => x.SenderId,
  496. principalTable: "Accounts",
  497. principalColumn: "Id",
  498. onDelete: ReferentialAction.Restrict);
  499. });
  500. migrationBuilder.CreateTable(
  501. name: "Suburbs",
  502. columns: table => new
  503. {
  504. Id = table.Column<int>(nullable: false)
  505. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  506. Created = table.Column<DateTime>(nullable: false),
  507. Modified = table.Column<DateTime>(nullable: false),
  508. ModifiedBy = table.Column<string>(nullable: true),
  509. IsDeleted = table.Column<bool>(nullable: false),
  510. CityId = table.Column<int>(nullable: false),
  511. Description = table.Column<string>(nullable: true),
  512. PostalCode = table.Column<string>(nullable: true)
  513. },
  514. constraints: table =>
  515. {
  516. table.PrimaryKey("PK_Suburbs", x => x.Id);
  517. table.ForeignKey(
  518. name: "FK_Suburbs_Cities_CityId",
  519. column: x => x.CityId,
  520. principalTable: "Cities",
  521. principalColumn: "Id",
  522. onDelete: ReferentialAction.Cascade);
  523. });
  524. migrationBuilder.CreateTable(
  525. name: "Agents",
  526. columns: table => new
  527. {
  528. Id = table.Column<int>(nullable: false)
  529. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  530. Created = table.Column<DateTime>(nullable: false),
  531. Modified = table.Column<DateTime>(nullable: false),
  532. ModifiedBy = table.Column<string>(nullable: true),
  533. IsDeleted = table.Column<bool>(nullable: false),
  534. UserId = table.Column<int>(nullable: true),
  535. Name = table.Column<string>(nullable: true),
  536. Surname = table.Column<string>(nullable: true),
  537. Email = table.Column<string>(nullable: true),
  538. Telephone = table.Column<string>(nullable: true),
  539. CellNumber = table.Column<string>(nullable: true),
  540. AgencyId = table.Column<int>(nullable: true),
  541. TemplateId = table.Column<int>(nullable: true)
  542. },
  543. constraints: table =>
  544. {
  545. table.PrimaryKey("PK_Agents", x => x.Id);
  546. table.ForeignKey(
  547. name: "FK_Agents_Agencies_AgencyId",
  548. column: x => x.AgencyId,
  549. principalTable: "Agencies",
  550. principalColumn: "Id",
  551. onDelete: ReferentialAction.Restrict);
  552. table.ForeignKey(
  553. name: "FK_Agents_Templates_TemplateId",
  554. column: x => x.TemplateId,
  555. principalTable: "Templates",
  556. principalColumn: "Id",
  557. onDelete: ReferentialAction.Restrict);
  558. table.ForeignKey(
  559. name: "FK_Agents_Users_UserId",
  560. column: x => x.UserId,
  561. principalTable: "Users",
  562. principalColumn: "Id",
  563. onDelete: ReferentialAction.Restrict);
  564. });
  565. migrationBuilder.CreateTable(
  566. name: "PlaceHolders",
  567. columns: table => new
  568. {
  569. Id = table.Column<int>(nullable: false)
  570. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  571. Created = table.Column<DateTime>(nullable: false),
  572. Modified = table.Column<DateTime>(nullable: false),
  573. ModifiedBy = table.Column<string>(nullable: true),
  574. IsDeleted = table.Column<bool>(nullable: false),
  575. Name = table.Column<string>(nullable: true),
  576. BoundToClass = table.Column<string>(nullable: true),
  577. BoundToClassDisplay = table.Column<string>(nullable: true),
  578. BoundTo = table.Column<string>(nullable: true),
  579. TemplateId = table.Column<int>(nullable: false)
  580. },
  581. constraints: table =>
  582. {
  583. table.PrimaryKey("PK_PlaceHolders", x => x.Id);
  584. table.ForeignKey(
  585. name: "FK_PlaceHolders_Templates_TemplateId",
  586. column: x => x.TemplateId,
  587. principalTable: "Templates",
  588. principalColumn: "Id",
  589. onDelete: ReferentialAction.Cascade);
  590. });
  591. migrationBuilder.CreateTable(
  592. name: "Individuals",
  593. columns: table => new
  594. {
  595. Id = table.Column<int>(nullable: false)
  596. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  597. Created = table.Column<DateTime>(nullable: false),
  598. Modified = table.Column<DateTime>(nullable: false),
  599. ModifiedBy = table.Column<string>(nullable: true),
  600. IsDeleted = table.Column<bool>(nullable: false),
  601. UserId = table.Column<int>(nullable: true),
  602. Name = table.Column<string>(nullable: true),
  603. Surname = table.Column<string>(nullable: true),
  604. Email = table.Column<string>(nullable: true),
  605. Telephone = table.Column<string>(nullable: true),
  606. CellNumber = table.Column<string>(nullable: true),
  607. IdNumber = table.Column<string>(nullable: true),
  608. CompanyRegNumber = table.Column<string>(nullable: true),
  609. MaritalStatus = table.Column<string>(nullable: true),
  610. AddressId = table.Column<int>(nullable: true),
  611. IncomeTaxNumber = table.Column<string>(nullable: true),
  612. BankAccountId = table.Column<int>(nullable: true),
  613. TemplateId = table.Column<int>(nullable: true)
  614. },
  615. constraints: table =>
  616. {
  617. table.PrimaryKey("PK_Individuals", x => x.Id);
  618. table.ForeignKey(
  619. name: "FK_Individuals_Templates_TemplateId",
  620. column: x => x.TemplateId,
  621. principalTable: "Templates",
  622. principalColumn: "Id",
  623. onDelete: ReferentialAction.Restrict);
  624. table.ForeignKey(
  625. name: "FK_Individuals_Users_UserId",
  626. column: x => x.UserId,
  627. principalTable: "Users",
  628. principalColumn: "Id",
  629. onDelete: ReferentialAction.Restrict);
  630. });
  631. migrationBuilder.CreateTable(
  632. name: "Addresses",
  633. columns: table => new
  634. {
  635. Id = table.Column<int>(nullable: false)
  636. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  637. Created = table.Column<DateTime>(nullable: false),
  638. Modified = table.Column<DateTime>(nullable: false),
  639. ModifiedBy = table.Column<string>(nullable: true),
  640. IsDeleted = table.Column<bool>(nullable: false),
  641. StreetNumber = table.Column<string>(nullable: true),
  642. Street = table.Column<string>(nullable: true),
  643. Suburb = table.Column<string>(nullable: true),
  644. City = table.Column<string>(nullable: true),
  645. PostalCode = table.Column<string>(nullable: true),
  646. Province = table.Column<string>(nullable: true),
  647. OwnerId = table.Column<int>(nullable: true)
  648. },
  649. constraints: table =>
  650. {
  651. table.PrimaryKey("PK_Addresses", x => x.Id);
  652. table.ForeignKey(
  653. name: "FK_Addresses_Individuals_OwnerId",
  654. column: x => x.OwnerId,
  655. principalTable: "Individuals",
  656. principalColumn: "Id",
  657. onDelete: ReferentialAction.Restrict);
  658. });
  659. migrationBuilder.CreateTable(
  660. name: "BankAccounts",
  661. columns: table => new
  662. {
  663. Id = table.Column<int>(nullable: false)
  664. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  665. Created = table.Column<DateTime>(nullable: false),
  666. Modified = table.Column<DateTime>(nullable: false),
  667. ModifiedBy = table.Column<string>(nullable: true),
  668. IsDeleted = table.Column<bool>(nullable: false),
  669. AccountHolder = table.Column<string>(nullable: true),
  670. AccountNumber = table.Column<string>(nullable: true),
  671. BankId = table.Column<int>(nullable: true),
  672. OwnerId = table.Column<int>(nullable: true)
  673. },
  674. constraints: table =>
  675. {
  676. table.PrimaryKey("PK_BankAccounts", x => x.Id);
  677. table.ForeignKey(
  678. name: "FK_BankAccounts_Banks_BankId",
  679. column: x => x.BankId,
  680. principalTable: "Banks",
  681. principalColumn: "Id",
  682. onDelete: ReferentialAction.Restrict);
  683. table.ForeignKey(
  684. name: "FK_BankAccounts_Individuals_OwnerId",
  685. column: x => x.OwnerId,
  686. principalTable: "Individuals",
  687. principalColumn: "Id",
  688. onDelete: ReferentialAction.Restrict);
  689. });
  690. migrationBuilder.CreateTable(
  691. name: "Properties",
  692. columns: table => new
  693. {
  694. Id = table.Column<int>(nullable: false)
  695. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  696. Created = table.Column<DateTime>(nullable: false),
  697. Modified = table.Column<DateTime>(nullable: false),
  698. ModifiedBy = table.Column<string>(nullable: true),
  699. IsDeleted = table.Column<bool>(nullable: false),
  700. PropertyTypeId = table.Column<int>(nullable: false),
  701. PropertyName = table.Column<string>(nullable: true),
  702. Unit = table.Column<string>(nullable: true),
  703. OperationalCosts = table.Column<decimal>(nullable: false),
  704. Price = table.Column<decimal>(nullable: false),
  705. PricePer = table.Column<string>(nullable: true),
  706. IsSale = table.Column<bool>(nullable: false),
  707. Description = table.Column<string>(nullable: true),
  708. ShortDescription = table.Column<string>(nullable: true),
  709. AddressLine1 = table.Column<string>(nullable: true),
  710. AddressLine2 = table.Column<string>(nullable: true),
  711. AddressLine3 = table.Column<string>(nullable: true),
  712. SuburbId = table.Column<int>(nullable: false),
  713. CityId = table.Column<int>(nullable: false),
  714. ProvinceId = table.Column<int>(nullable: false),
  715. Published = table.Column<bool>(nullable: false),
  716. DatePublished = table.Column<DateTime>(nullable: false),
  717. VirtualTour = table.Column<string>(nullable: true),
  718. Video = table.Column<string>(nullable: true),
  719. StatusId = table.Column<int>(nullable: true),
  720. OwnerId = table.Column<int>(nullable: true),
  721. AgentId = table.Column<int>(nullable: true),
  722. AgencyId = table.Column<int>(nullable: true),
  723. DateAvailable = table.Column<DateTime>(nullable: false),
  724. StatusDate = table.Column<DateTime>(nullable: false)
  725. },
  726. constraints: table =>
  727. {
  728. table.PrimaryKey("PK_Properties", x => x.Id);
  729. table.ForeignKey(
  730. name: "FK_Properties_Agencies_AgencyId",
  731. column: x => x.AgencyId,
  732. principalTable: "Agencies",
  733. principalColumn: "Id",
  734. onDelete: ReferentialAction.Restrict);
  735. table.ForeignKey(
  736. name: "FK_Properties_Agents_AgentId",
  737. column: x => x.AgentId,
  738. principalTable: "Agents",
  739. principalColumn: "Id",
  740. onDelete: ReferentialAction.Restrict);
  741. table.ForeignKey(
  742. name: "FK_Properties_Individuals_OwnerId",
  743. column: x => x.OwnerId,
  744. principalTable: "Individuals",
  745. principalColumn: "Id",
  746. onDelete: ReferentialAction.Restrict);
  747. });
  748. migrationBuilder.CreateTable(
  749. name: "Weeks",
  750. columns: table => new
  751. {
  752. Id = table.Column<int>(nullable: false)
  753. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  754. Created = table.Column<DateTime>(nullable: false),
  755. Modified = table.Column<DateTime>(nullable: false),
  756. ModifiedBy = table.Column<string>(nullable: true),
  757. IsDeleted = table.Column<bool>(nullable: false),
  758. ReferedByAgent = table.Column<bool>(nullable: false),
  759. AgentId = table.Column<int>(nullable: true),
  760. AgencyId = table.Column<int>(nullable: true),
  761. OwnerId = table.Column<int>(nullable: false),
  762. AgentAsRep = table.Column<bool>(nullable: false),
  763. OtherResort = table.Column<bool>(nullable: false),
  764. OtherResortName = table.Column<string>(nullable: true),
  765. ResortCode = table.Column<string>(nullable: true),
  766. ResortName = table.Column<string>(nullable: true),
  767. RegionId = table.Column<int>(nullable: false),
  768. Season = table.Column<string>(nullable: true),
  769. Module = table.Column<string>(nullable: true),
  770. Bedrooms = table.Column<int>(nullable: false),
  771. MaxSleep = table.Column<int>(nullable: false),
  772. UnitNumber = table.Column<string>(nullable: true),
  773. WeekNumber = table.Column<string>(nullable: true),
  774. LevyAmount = table.Column<double>(nullable: false),
  775. CurrentYearBanked = table.Column<bool>(nullable: false),
  776. BankedWith = table.Column<string>(nullable: true),
  777. LeviesPaidInFull = table.Column<bool>(nullable: false),
  778. WeekPlacedForRental = table.Column<bool>(nullable: false),
  779. OriginalPurchasePrice = table.Column<double>(nullable: false),
  780. OriginalPurchaseDate = table.Column<DateTime>(nullable: false),
  781. ArrivalDate = table.Column<DateTime>(nullable: false),
  782. DepartureDate = table.Column<DateTime>(nullable: false),
  783. SellPrice = table.Column<double>(nullable: false),
  784. AgentCommision = table.Column<double>(nullable: false),
  785. Mandate = table.Column<string>(nullable: true),
  786. StatusId = table.Column<int>(nullable: false)
  787. },
  788. constraints: table =>
  789. {
  790. table.PrimaryKey("PK_Weeks", x => x.Id);
  791. table.ForeignKey(
  792. name: "FK_Weeks_Agencies_AgencyId",
  793. column: x => x.AgencyId,
  794. principalTable: "Agencies",
  795. principalColumn: "Id",
  796. onDelete: ReferentialAction.Restrict);
  797. table.ForeignKey(
  798. name: "FK_Weeks_Agents_AgentId",
  799. column: x => x.AgentId,
  800. principalTable: "Agents",
  801. principalColumn: "Id",
  802. onDelete: ReferentialAction.Restrict);
  803. table.ForeignKey(
  804. name: "FK_Weeks_Individuals_OwnerId",
  805. column: x => x.OwnerId,
  806. principalTable: "Individuals",
  807. principalColumn: "Id",
  808. onDelete: ReferentialAction.Cascade);
  809. table.ForeignKey(
  810. name: "FK_Weeks_Provinces_RegionId",
  811. column: x => x.RegionId,
  812. principalTable: "Provinces",
  813. principalColumn: "Id",
  814. onDelete: ReferentialAction.Cascade);
  815. table.ForeignKey(
  816. name: "FK_Weeks_Status_StatusId",
  817. column: x => x.StatusId,
  818. principalTable: "Status",
  819. principalColumn: "Id",
  820. onDelete: ReferentialAction.Cascade);
  821. });
  822. migrationBuilder.CreateTable(
  823. name: "PropertyImages",
  824. columns: table => new
  825. {
  826. Id = table.Column<int>(nullable: false)
  827. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  828. Created = table.Column<DateTime>(nullable: false),
  829. Modified = table.Column<DateTime>(nullable: false),
  830. ModifiedBy = table.Column<string>(nullable: true),
  831. IsDeleted = table.Column<bool>(nullable: false),
  832. PropertyId = table.Column<int>(nullable: false),
  833. Image = table.Column<string>(nullable: true),
  834. IsDefault = table.Column<bool>(nullable: false)
  835. },
  836. constraints: table =>
  837. {
  838. table.PrimaryKey("PK_PropertyImages", x => x.Id);
  839. table.ForeignKey(
  840. name: "FK_PropertyImages_Properties_PropertyId",
  841. column: x => x.PropertyId,
  842. principalTable: "Properties",
  843. principalColumn: "Id",
  844. onDelete: ReferentialAction.Cascade);
  845. });
  846. migrationBuilder.CreateTable(
  847. name: "PropertyUserFields",
  848. columns: table => new
  849. {
  850. Id = table.Column<int>(nullable: false)
  851. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  852. Created = table.Column<DateTime>(nullable: false),
  853. Modified = table.Column<DateTime>(nullable: false),
  854. ModifiedBy = table.Column<string>(nullable: true),
  855. IsDeleted = table.Column<bool>(nullable: false),
  856. PropertyId = table.Column<int>(nullable: false),
  857. UserDefinedFieldId = table.Column<int>(nullable: false),
  858. Value = table.Column<string>(nullable: true),
  859. Description = table.Column<string>(nullable: true)
  860. },
  861. constraints: table =>
  862. {
  863. table.PrimaryKey("PK_PropertyUserFields", x => x.Id);
  864. table.ForeignKey(
  865. name: "FK_PropertyUserFields_Properties_PropertyId",
  866. column: x => x.PropertyId,
  867. principalTable: "Properties",
  868. principalColumn: "Id",
  869. onDelete: ReferentialAction.Cascade);
  870. table.ForeignKey(
  871. name: "FK_PropertyUserFields_UserDefinedFields_UserDefinedFieldId",
  872. column: x => x.UserDefinedFieldId,
  873. principalTable: "UserDefinedFields",
  874. principalColumn: "Id",
  875. onDelete: ReferentialAction.Cascade);
  876. });
  877. migrationBuilder.CreateTable(
  878. name: "BidItems",
  879. columns: table => new
  880. {
  881. Id = table.Column<int>(nullable: false)
  882. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  883. Created = table.Column<DateTime>(nullable: false),
  884. Modified = table.Column<DateTime>(nullable: false),
  885. ModifiedBy = table.Column<string>(nullable: true),
  886. IsDeleted = table.Column<bool>(nullable: false),
  887. Amount = table.Column<double>(nullable: false),
  888. StatusId = table.Column<int>(nullable: true),
  889. BidMakerId = table.Column<int>(nullable: true),
  890. TimeshareWeekId = table.Column<int>(nullable: true),
  891. PropertyId = table.Column<int>(nullable: true),
  892. Comment = table.Column<string>(nullable: true),
  893. DeclinedReason = table.Column<string>(nullable: true)
  894. },
  895. constraints: table =>
  896. {
  897. table.PrimaryKey("PK_BidItems", x => x.Id);
  898. table.ForeignKey(
  899. name: "FK_BidItems_Individuals_BidMakerId",
  900. column: x => x.BidMakerId,
  901. principalTable: "Individuals",
  902. principalColumn: "Id",
  903. onDelete: ReferentialAction.Restrict);
  904. table.ForeignKey(
  905. name: "FK_BidItems_Properties_PropertyId",
  906. column: x => x.PropertyId,
  907. principalTable: "Properties",
  908. principalColumn: "Id",
  909. onDelete: ReferentialAction.Restrict);
  910. table.ForeignKey(
  911. name: "FK_BidItems_Status_StatusId",
  912. column: x => x.StatusId,
  913. principalTable: "Status",
  914. principalColumn: "Id",
  915. onDelete: ReferentialAction.Restrict);
  916. table.ForeignKey(
  917. name: "FK_BidItems_Weeks_TimeshareWeekId",
  918. column: x => x.TimeshareWeekId,
  919. principalTable: "Weeks",
  920. principalColumn: "Id",
  921. onDelete: ReferentialAction.Restrict);
  922. });
  923. migrationBuilder.CreateTable(
  924. name: "CampaignItems",
  925. columns: table => new
  926. {
  927. Id = table.Column<int>(nullable: false)
  928. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  929. Created = table.Column<DateTime>(nullable: false),
  930. Modified = table.Column<DateTime>(nullable: false),
  931. ModifiedBy = table.Column<string>(nullable: true),
  932. IsDeleted = table.Column<bool>(nullable: false),
  933. CampaignId = table.Column<int>(nullable: false),
  934. WeekId = table.Column<int>(nullable: false),
  935. Image = table.Column<string>(nullable: true)
  936. },
  937. constraints: table =>
  938. {
  939. table.PrimaryKey("PK_CampaignItems", x => x.Id);
  940. table.ForeignKey(
  941. name: "FK_CampaignItems_Campaigns_CampaignId",
  942. column: x => x.CampaignId,
  943. principalTable: "Campaigns",
  944. principalColumn: "Id",
  945. onDelete: ReferentialAction.Cascade);
  946. table.ForeignKey(
  947. name: "FK_CampaignItems_Weeks_WeekId",
  948. column: x => x.WeekId,
  949. principalTable: "Weeks",
  950. principalColumn: "Id",
  951. onDelete: ReferentialAction.Cascade);
  952. });
  953. migrationBuilder.CreateTable(
  954. name: "Payments",
  955. columns: table => new
  956. {
  957. Id = table.Column<int>(nullable: false)
  958. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  959. Created = table.Column<DateTime>(nullable: false),
  960. Modified = table.Column<DateTime>(nullable: false),
  961. ModifiedBy = table.Column<string>(nullable: true),
  962. IsDeleted = table.Column<bool>(nullable: false),
  963. TimeshareWeekId = table.Column<int>(nullable: true),
  964. PropertyId = table.Column<int>(nullable: true),
  965. CreatedById = table.Column<int>(nullable: false),
  966. Amount = table.Column<decimal>(nullable: false),
  967. PaymentStatus = table.Column<string>(nullable: true),
  968. PaymentToken = table.Column<string>(nullable: true)
  969. },
  970. constraints: table =>
  971. {
  972. table.PrimaryKey("PK_Payments", x => x.Id);
  973. table.ForeignKey(
  974. name: "FK_Payments_Users_CreatedById",
  975. column: x => x.CreatedById,
  976. principalTable: "Users",
  977. principalColumn: "Id",
  978. onDelete: ReferentialAction.Cascade);
  979. table.ForeignKey(
  980. name: "FK_Payments_Properties_PropertyId",
  981. column: x => x.PropertyId,
  982. principalTable: "Properties",
  983. principalColumn: "Id",
  984. onDelete: ReferentialAction.Restrict);
  985. table.ForeignKey(
  986. name: "FK_Payments_Weeks_TimeshareWeekId",
  987. column: x => x.TimeshareWeekId,
  988. principalTable: "Weeks",
  989. principalColumn: "Id",
  990. onDelete: ReferentialAction.Restrict);
  991. });
  992. migrationBuilder.CreateTable(
  993. name: "ProcessFlows",
  994. columns: table => new
  995. {
  996. Id = table.Column<int>(nullable: false)
  997. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  998. Created = table.Column<DateTime>(nullable: false),
  999. Modified = table.Column<DateTime>(nullable: false),
  1000. ModifiedBy = table.Column<string>(nullable: true),
  1001. IsDeleted = table.Column<bool>(nullable: false),
  1002. TimeshareID = table.Column<int>(nullable: true),
  1003. PropertyID = table.Column<int>(nullable: true),
  1004. StatusID = table.Column<int>(nullable: false)
  1005. },
  1006. constraints: table =>
  1007. {
  1008. table.PrimaryKey("PK_ProcessFlows", x => x.Id);
  1009. table.ForeignKey(
  1010. name: "FK_ProcessFlows_Properties_PropertyID",
  1011. column: x => x.PropertyID,
  1012. principalTable: "Properties",
  1013. principalColumn: "Id",
  1014. onDelete: ReferentialAction.Restrict);
  1015. table.ForeignKey(
  1016. name: "FK_ProcessFlows_Status_StatusID",
  1017. column: x => x.StatusID,
  1018. principalTable: "Status",
  1019. principalColumn: "Id",
  1020. onDelete: ReferentialAction.Cascade);
  1021. table.ForeignKey(
  1022. name: "FK_ProcessFlows_Weeks_TimeshareID",
  1023. column: x => x.TimeshareID,
  1024. principalTable: "Weeks",
  1025. principalColumn: "Id",
  1026. onDelete: ReferentialAction.Restrict);
  1027. });
  1028. migrationBuilder.CreateTable(
  1029. name: "CampaignItemPlaceHolders",
  1030. columns: table => new
  1031. {
  1032. Id = table.Column<int>(nullable: false)
  1033. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  1034. Created = table.Column<DateTime>(nullable: false),
  1035. Modified = table.Column<DateTime>(nullable: false),
  1036. ModifiedBy = table.Column<string>(nullable: true),
  1037. IsDeleted = table.Column<bool>(nullable: false),
  1038. CampaignItemId = table.Column<int>(nullable: false),
  1039. PlaceHolder = table.Column<string>(nullable: true),
  1040. Value = table.Column<string>(nullable: true)
  1041. },
  1042. constraints: table =>
  1043. {
  1044. table.PrimaryKey("PK_CampaignItemPlaceHolders", x => x.Id);
  1045. table.ForeignKey(
  1046. name: "FK_CampaignItemPlaceHolders_CampaignItems_CampaignItemId",
  1047. column: x => x.CampaignItemId,
  1048. principalTable: "CampaignItems",
  1049. principalColumn: "Id",
  1050. onDelete: ReferentialAction.Cascade);
  1051. });
  1052. migrationBuilder.CreateIndex(
  1053. name: "IX_Accounts_SMTPHostId",
  1054. table: "Accounts",
  1055. column: "SMTPHostId");
  1056. migrationBuilder.CreateIndex(
  1057. name: "IX_Addresses_OwnerId",
  1058. table: "Addresses",
  1059. column: "OwnerId");
  1060. migrationBuilder.CreateIndex(
  1061. name: "IX_Agents_AgencyId",
  1062. table: "Agents",
  1063. column: "AgencyId");
  1064. migrationBuilder.CreateIndex(
  1065. name: "IX_Agents_TemplateId",
  1066. table: "Agents",
  1067. column: "TemplateId");
  1068. migrationBuilder.CreateIndex(
  1069. name: "IX_Agents_UserId",
  1070. table: "Agents",
  1071. column: "UserId");
  1072. migrationBuilder.CreateIndex(
  1073. name: "IX_BankAccounts_BankId",
  1074. table: "BankAccounts",
  1075. column: "BankId");
  1076. migrationBuilder.CreateIndex(
  1077. name: "IX_BankAccounts_OwnerId",
  1078. table: "BankAccounts",
  1079. column: "OwnerId");
  1080. migrationBuilder.CreateIndex(
  1081. name: "IX_BidItems_BidMakerId",
  1082. table: "BidItems",
  1083. column: "BidMakerId");
  1084. migrationBuilder.CreateIndex(
  1085. name: "IX_BidItems_PropertyId",
  1086. table: "BidItems",
  1087. column: "PropertyId");
  1088. migrationBuilder.CreateIndex(
  1089. name: "IX_BidItems_StatusId",
  1090. table: "BidItems",
  1091. column: "StatusId");
  1092. migrationBuilder.CreateIndex(
  1093. name: "IX_BidItems_TimeshareWeekId",
  1094. table: "BidItems",
  1095. column: "TimeshareWeekId");
  1096. migrationBuilder.CreateIndex(
  1097. name: "IX_CampaignItemPlaceHolders_CampaignItemId",
  1098. table: "CampaignItemPlaceHolders",
  1099. column: "CampaignItemId");
  1100. migrationBuilder.CreateIndex(
  1101. name: "IX_CampaignItems_CampaignId",
  1102. table: "CampaignItems",
  1103. column: "CampaignId");
  1104. migrationBuilder.CreateIndex(
  1105. name: "IX_CampaignItems_WeekId",
  1106. table: "CampaignItems",
  1107. column: "WeekId");
  1108. migrationBuilder.CreateIndex(
  1109. name: "IX_CampaignPlaceHolders_CampaignId",
  1110. table: "CampaignPlaceHolders",
  1111. column: "CampaignId");
  1112. migrationBuilder.CreateIndex(
  1113. name: "IX_Cities_ProvinceId",
  1114. table: "Cities",
  1115. column: "ProvinceId");
  1116. migrationBuilder.CreateIndex(
  1117. name: "IX_Emails_SenderId",
  1118. table: "Emails",
  1119. column: "SenderId");
  1120. migrationBuilder.CreateIndex(
  1121. name: "IX_Individuals_AddressId",
  1122. table: "Individuals",
  1123. column: "AddressId");
  1124. migrationBuilder.CreateIndex(
  1125. name: "IX_Individuals_BankAccountId",
  1126. table: "Individuals",
  1127. column: "BankAccountId");
  1128. migrationBuilder.CreateIndex(
  1129. name: "IX_Individuals_TemplateId",
  1130. table: "Individuals",
  1131. column: "TemplateId");
  1132. migrationBuilder.CreateIndex(
  1133. name: "IX_Individuals_UserId",
  1134. table: "Individuals",
  1135. column: "UserId");
  1136. migrationBuilder.CreateIndex(
  1137. name: "IX_Individuals_Telephone_CellNumber_Email",
  1138. table: "Individuals",
  1139. columns: new[] { "Telephone", "CellNumber", "Email" },
  1140. unique: true,
  1141. filter: "[Telephone] IS NOT NULL AND [CellNumber] IS NOT NULL AND [Email] IS NOT NULL");
  1142. migrationBuilder.CreateIndex(
  1143. name: "IX_Payments_CreatedById",
  1144. table: "Payments",
  1145. column: "CreatedById");
  1146. migrationBuilder.CreateIndex(
  1147. name: "IX_Payments_PropertyId",
  1148. table: "Payments",
  1149. column: "PropertyId");
  1150. migrationBuilder.CreateIndex(
  1151. name: "IX_Payments_TimeshareWeekId",
  1152. table: "Payments",
  1153. column: "TimeshareWeekId");
  1154. migrationBuilder.CreateIndex(
  1155. name: "IX_Person_UserId",
  1156. table: "Person",
  1157. column: "UserId");
  1158. migrationBuilder.CreateIndex(
  1159. name: "IX_PlaceHolders_TemplateId",
  1160. table: "PlaceHolders",
  1161. column: "TemplateId");
  1162. migrationBuilder.CreateIndex(
  1163. name: "IX_ProcessFlows_PropertyID",
  1164. table: "ProcessFlows",
  1165. column: "PropertyID");
  1166. migrationBuilder.CreateIndex(
  1167. name: "IX_ProcessFlows_StatusID",
  1168. table: "ProcessFlows",
  1169. column: "StatusID");
  1170. migrationBuilder.CreateIndex(
  1171. name: "IX_ProcessFlows_TimeshareID",
  1172. table: "ProcessFlows",
  1173. column: "TimeshareID");
  1174. migrationBuilder.CreateIndex(
  1175. name: "IX_Properties_AgencyId",
  1176. table: "Properties",
  1177. column: "AgencyId");
  1178. migrationBuilder.CreateIndex(
  1179. name: "IX_Properties_AgentId",
  1180. table: "Properties",
  1181. column: "AgentId");
  1182. migrationBuilder.CreateIndex(
  1183. name: "IX_Properties_OwnerId",
  1184. table: "Properties",
  1185. column: "OwnerId");
  1186. migrationBuilder.CreateIndex(
  1187. name: "IX_PropertyImages_PropertyId",
  1188. table: "PropertyImages",
  1189. column: "PropertyId");
  1190. migrationBuilder.CreateIndex(
  1191. name: "IX_PropertyUserFields_PropertyId",
  1192. table: "PropertyUserFields",
  1193. column: "PropertyId");
  1194. migrationBuilder.CreateIndex(
  1195. name: "IX_PropertyUserFields_UserDefinedFieldId",
  1196. table: "PropertyUserFields",
  1197. column: "UserDefinedFieldId");
  1198. migrationBuilder.CreateIndex(
  1199. name: "IX_Suburbs_CityId",
  1200. table: "Suburbs",
  1201. column: "CityId");
  1202. migrationBuilder.CreateIndex(
  1203. name: "IX_Templates_SenderId",
  1204. table: "Templates",
  1205. column: "SenderId");
  1206. migrationBuilder.CreateIndex(
  1207. name: "IX_UnitConfigurations_Code",
  1208. table: "UnitConfigurations",
  1209. column: "Code",
  1210. unique: true,
  1211. filter: "[Code] IS NOT NULL");
  1212. migrationBuilder.CreateIndex(
  1213. name: "IX_UnitConfigurationTypes_UnitConfigurationId",
  1214. table: "UnitConfigurationTypes",
  1215. column: "UnitConfigurationId");
  1216. migrationBuilder.CreateIndex(
  1217. name: "IX_UserDefinedFields_GroupId",
  1218. table: "UserDefinedFields",
  1219. column: "GroupId");
  1220. migrationBuilder.CreateIndex(
  1221. name: "IX_Users_Username",
  1222. table: "Users",
  1223. column: "Username",
  1224. unique: true,
  1225. filter: "[Username] IS NOT NULL");
  1226. migrationBuilder.CreateIndex(
  1227. name: "IX_Weeks_AgencyId",
  1228. table: "Weeks",
  1229. column: "AgencyId");
  1230. migrationBuilder.CreateIndex(
  1231. name: "IX_Weeks_AgentId",
  1232. table: "Weeks",
  1233. column: "AgentId");
  1234. migrationBuilder.CreateIndex(
  1235. name: "IX_Weeks_OwnerId",
  1236. table: "Weeks",
  1237. column: "OwnerId");
  1238. migrationBuilder.CreateIndex(
  1239. name: "IX_Weeks_RegionId",
  1240. table: "Weeks",
  1241. column: "RegionId");
  1242. migrationBuilder.CreateIndex(
  1243. name: "IX_Weeks_StatusId",
  1244. table: "Weeks",
  1245. column: "StatusId");
  1246. migrationBuilder.AddForeignKey(
  1247. name: "FK_Individuals_Addresses_AddressId",
  1248. table: "Individuals",
  1249. column: "AddressId",
  1250. principalTable: "Addresses",
  1251. principalColumn: "Id",
  1252. onDelete: ReferentialAction.Restrict);
  1253. migrationBuilder.AddForeignKey(
  1254. name: "FK_Individuals_BankAccounts_BankAccountId",
  1255. table: "Individuals",
  1256. column: "BankAccountId",
  1257. principalTable: "BankAccounts",
  1258. principalColumn: "Id",
  1259. onDelete: ReferentialAction.Restrict);
  1260. }
  1261. protected override void Down(MigrationBuilder migrationBuilder)
  1262. {
  1263. migrationBuilder.DropForeignKey(
  1264. name: "FK_Accounts_Hosts_SMTPHostId",
  1265. table: "Accounts");
  1266. migrationBuilder.DropForeignKey(
  1267. name: "FK_Addresses_Individuals_OwnerId",
  1268. table: "Addresses");
  1269. migrationBuilder.DropForeignKey(
  1270. name: "FK_BankAccounts_Individuals_OwnerId",
  1271. table: "BankAccounts");
  1272. migrationBuilder.DropTable(
  1273. name: "BidItems");
  1274. migrationBuilder.DropTable(
  1275. name: "CampaignItemPlaceHolders");
  1276. migrationBuilder.DropTable(
  1277. name: "CampaignPlaceHolders");
  1278. migrationBuilder.DropTable(
  1279. name: "Carousel");
  1280. migrationBuilder.DropTable(
  1281. name: "Defaults");
  1282. migrationBuilder.DropTable(
  1283. name: "Emails");
  1284. migrationBuilder.DropTable(
  1285. name: "Location");
  1286. migrationBuilder.DropTable(
  1287. name: "Payments");
  1288. migrationBuilder.DropTable(
  1289. name: "Person");
  1290. migrationBuilder.DropTable(
  1291. name: "PlaceHolderFormats");
  1292. migrationBuilder.DropTable(
  1293. name: "PlaceHolders");
  1294. migrationBuilder.DropTable(
  1295. name: "ProcessFlows");
  1296. migrationBuilder.DropTable(
  1297. name: "PropertyImages");
  1298. migrationBuilder.DropTable(
  1299. name: "PropertyTypes");
  1300. migrationBuilder.DropTable(
  1301. name: "PropertyUserFields");
  1302. migrationBuilder.DropTable(
  1303. name: "SearchLogs");
  1304. migrationBuilder.DropTable(
  1305. name: "Seasons");
  1306. migrationBuilder.DropTable(
  1307. name: "Suburbs");
  1308. migrationBuilder.DropTable(
  1309. name: "UnitConfigurationTypes");
  1310. migrationBuilder.DropTable(
  1311. name: "CampaignItems");
  1312. migrationBuilder.DropTable(
  1313. name: "Properties");
  1314. migrationBuilder.DropTable(
  1315. name: "UserDefinedFields");
  1316. migrationBuilder.DropTable(
  1317. name: "Cities");
  1318. migrationBuilder.DropTable(
  1319. name: "UnitConfigurations");
  1320. migrationBuilder.DropTable(
  1321. name: "Campaigns");
  1322. migrationBuilder.DropTable(
  1323. name: "Weeks");
  1324. migrationBuilder.DropTable(
  1325. name: "UserDefinedGroups");
  1326. migrationBuilder.DropTable(
  1327. name: "Agents");
  1328. migrationBuilder.DropTable(
  1329. name: "Provinces");
  1330. migrationBuilder.DropTable(
  1331. name: "Status");
  1332. migrationBuilder.DropTable(
  1333. name: "Agencies");
  1334. migrationBuilder.DropTable(
  1335. name: "Hosts");
  1336. migrationBuilder.DropTable(
  1337. name: "Individuals");
  1338. migrationBuilder.DropTable(
  1339. name: "Addresses");
  1340. migrationBuilder.DropTable(
  1341. name: "BankAccounts");
  1342. migrationBuilder.DropTable(
  1343. name: "Templates");
  1344. migrationBuilder.DropTable(
  1345. name: "Users");
  1346. migrationBuilder.DropTable(
  1347. name: "Banks");
  1348. migrationBuilder.DropTable(
  1349. name: "Accounts");
  1350. }
  1351. }
  1352. }