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

20200727164838_NewMigration.cs 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Metadata;
  3. using Microsoft.EntityFrameworkCore.Migrations;
  4. namespace ProRestaurant.Migrations
  5. {
  6. public partial class NewMigration : Migration
  7. {
  8. protected override void Up(MigrationBuilder migrationBuilder)
  9. {
  10. migrationBuilder.CreateTable(
  11. name: "Locations",
  12. columns: table => new
  13. {
  14. Id = table.Column<int>(nullable: false)
  15. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  16. ImageStore = table.Column<string>(nullable: true),
  17. CategoryStore = table.Column<string>(nullable: true)
  18. },
  19. constraints: table =>
  20. {
  21. table.PrimaryKey("PK_Locations", x => x.Id);
  22. });
  23. migrationBuilder.CreateTable(
  24. name: "RestaurantCategories",
  25. columns: table => new
  26. {
  27. Id = table.Column<int>(nullable: false)
  28. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  29. Description = table.Column<string>(nullable: true),
  30. Image = table.Column<string>(nullable: true)
  31. },
  32. constraints: table =>
  33. {
  34. table.PrimaryKey("PK_RestaurantCategories", x => x.Id);
  35. });
  36. migrationBuilder.CreateTable(
  37. name: "Restaurants",
  38. columns: table => new
  39. {
  40. Id = table.Column<int>(nullable: false)
  41. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  42. Created = table.Column<DateTime>(nullable: false),
  43. Modified = table.Column<DateTime>(nullable: false),
  44. ModifiedBy = table.Column<string>(nullable: true),
  45. IsDeleted = table.Column<bool>(nullable: false),
  46. Name = table.Column<string>(nullable: true),
  47. Logo = table.Column<string>(nullable: true),
  48. DeliveryFee = table.Column<decimal>(nullable: false),
  49. DeliveryRadius = table.Column<decimal>(nullable: false),
  50. MethodsOfPayment = table.Column<string>(nullable: true),
  51. ShoppingCentre = table.Column<string>(nullable: true),
  52. ShopNumber = table.Column<string>(nullable: true),
  53. GoogleMapUrl = table.Column<string>(nullable: true),
  54. Latitude = table.Column<decimal>(nullable: false),
  55. Longitude = table.Column<decimal>(nullable: false),
  56. StreetNumber = table.Column<string>(nullable: true),
  57. StreetName = table.Column<string>(nullable: true),
  58. Suburb = table.Column<string>(nullable: true),
  59. City = table.Column<string>(nullable: true),
  60. Province = table.Column<string>(nullable: true),
  61. Country = table.Column<string>(nullable: true),
  62. PostalCode = table.Column<string>(nullable: true),
  63. DeliveryTime = table.Column<string>(nullable: true),
  64. Categories = table.Column<string>(nullable: true)
  65. },
  66. constraints: table =>
  67. {
  68. table.PrimaryKey("PK_Restaurants", x => x.Id);
  69. });
  70. migrationBuilder.CreateTable(
  71. name: "RestaurantUserRestaurantRoles",
  72. columns: table => new
  73. {
  74. Id = table.Column<int>(nullable: false)
  75. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  76. Created = table.Column<DateTime>(nullable: false),
  77. Modified = table.Column<DateTime>(nullable: false),
  78. ModifiedBy = table.Column<string>(nullable: true),
  79. IsDeleted = table.Column<bool>(nullable: false),
  80. RestaurantUserId = table.Column<int>(nullable: true),
  81. RestaurantRoleId = table.Column<int>(nullable: true)
  82. },
  83. constraints: table =>
  84. {
  85. table.PrimaryKey("PK_RestaurantUserRestaurantRoles", x => x.Id);
  86. });
  87. migrationBuilder.CreateTable(
  88. name: "Users",
  89. columns: table => new
  90. {
  91. Id = table.Column<int>(nullable: false)
  92. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  93. Created = table.Column<DateTime>(nullable: false),
  94. Modified = table.Column<DateTime>(nullable: false),
  95. ModifiedBy = table.Column<string>(nullable: true),
  96. IsDeleted = table.Column<bool>(nullable: false),
  97. EmailAddress = table.Column<string>(nullable: true),
  98. Password = table.Column<string>(nullable: true),
  99. FirstName = table.Column<string>(nullable: true),
  100. Surname = table.Column<string>(nullable: true),
  101. Cellphone = table.Column<string>(nullable: true),
  102. SystemRole = table.Column<int>(nullable: false),
  103. ChangePassword = table.Column<bool>(nullable: false)
  104. },
  105. constraints: table =>
  106. {
  107. table.PrimaryKey("PK_Users", x => x.Id);
  108. });
  109. migrationBuilder.CreateTable(
  110. name: "MenuCategories",
  111. columns: table => new
  112. {
  113. Id = table.Column<int>(nullable: false)
  114. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  115. Created = table.Column<DateTime>(nullable: false),
  116. Modified = table.Column<DateTime>(nullable: false),
  117. ModifiedBy = table.Column<string>(nullable: true),
  118. IsDeleted = table.Column<bool>(nullable: false),
  119. RestaurantId = table.Column<int>(nullable: false),
  120. Description = table.Column<string>(nullable: true)
  121. },
  122. constraints: table =>
  123. {
  124. table.PrimaryKey("PK_MenuCategories", x => x.Id);
  125. table.ForeignKey(
  126. name: "FK_MenuCategories_Restaurants_RestaurantId",
  127. column: x => x.RestaurantId,
  128. principalTable: "Restaurants",
  129. principalColumn: "Id",
  130. onDelete: ReferentialAction.Cascade);
  131. });
  132. migrationBuilder.CreateTable(
  133. name: "MenuItems",
  134. columns: table => new
  135. {
  136. Id = table.Column<int>(nullable: false)
  137. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  138. Created = table.Column<DateTime>(nullable: false),
  139. Modified = table.Column<DateTime>(nullable: false),
  140. ModifiedBy = table.Column<string>(nullable: true),
  141. IsDeleted = table.Column<bool>(nullable: false),
  142. RestaurantId = table.Column<int>(nullable: false),
  143. CategoryId = table.Column<int>(nullable: false),
  144. Image = table.Column<string>(nullable: true),
  145. Name = table.Column<string>(nullable: true),
  146. Description = table.Column<string>(nullable: true),
  147. Price = table.Column<decimal>(nullable: false),
  148. OverrideOptions = table.Column<bool>(nullable: false),
  149. OutOfStock = table.Column<bool>(nullable: false)
  150. },
  151. constraints: table =>
  152. {
  153. table.PrimaryKey("PK_MenuItems", x => x.Id);
  154. table.ForeignKey(
  155. name: "FK_MenuItems_Restaurants_RestaurantId",
  156. column: x => x.RestaurantId,
  157. principalTable: "Restaurants",
  158. principalColumn: "Id",
  159. onDelete: ReferentialAction.Cascade);
  160. });
  161. migrationBuilder.CreateTable(
  162. name: "RestaurantRoles",
  163. columns: table => new
  164. {
  165. Id = table.Column<int>(nullable: false)
  166. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  167. Created = table.Column<DateTime>(nullable: false),
  168. Modified = table.Column<DateTime>(nullable: false),
  169. ModifiedBy = table.Column<string>(nullable: true),
  170. IsDeleted = table.Column<bool>(nullable: false),
  171. RestaurantId = table.Column<int>(nullable: false),
  172. RoleName = table.Column<string>(nullable: true)
  173. },
  174. constraints: table =>
  175. {
  176. table.PrimaryKey("PK_RestaurantRoles", x => x.Id);
  177. table.ForeignKey(
  178. name: "FK_RestaurantRoles_Restaurants_RestaurantId",
  179. column: x => x.RestaurantId,
  180. principalTable: "Restaurants",
  181. principalColumn: "Id",
  182. onDelete: ReferentialAction.Cascade);
  183. });
  184. migrationBuilder.CreateTable(
  185. name: "TradingHours",
  186. columns: table => new
  187. {
  188. Id = table.Column<int>(nullable: false)
  189. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  190. Created = table.Column<DateTime>(nullable: false),
  191. Modified = table.Column<DateTime>(nullable: false),
  192. ModifiedBy = table.Column<string>(nullable: true),
  193. IsDeleted = table.Column<bool>(nullable: false),
  194. RestaurantId = table.Column<int>(nullable: false),
  195. Description = table.Column<string>(nullable: true),
  196. OpeningTime = table.Column<DateTime>(nullable: false),
  197. ClosingTime = table.Column<DateTime>(nullable: false),
  198. Closed = table.Column<bool>(nullable: false),
  199. Opened24H = table.Column<bool>(nullable: false)
  200. },
  201. constraints: table =>
  202. {
  203. table.PrimaryKey("PK_TradingHours", x => x.Id);
  204. table.ForeignKey(
  205. name: "FK_TradingHours_Restaurants_RestaurantId",
  206. column: x => x.RestaurantId,
  207. principalTable: "Restaurants",
  208. principalColumn: "Id",
  209. onDelete: ReferentialAction.Cascade);
  210. });
  211. migrationBuilder.CreateTable(
  212. name: "DriverDetails",
  213. columns: table => new
  214. {
  215. Id = table.Column<int>(nullable: false)
  216. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  217. Created = table.Column<DateTime>(nullable: false),
  218. Modified = table.Column<DateTime>(nullable: false),
  219. ModifiedBy = table.Column<string>(nullable: true),
  220. IsDeleted = table.Column<bool>(nullable: false),
  221. UserId = table.Column<int>(nullable: false),
  222. Photo = table.Column<string>(nullable: true),
  223. RegistrationNumber = table.Column<string>(nullable: true)
  224. },
  225. constraints: table =>
  226. {
  227. table.PrimaryKey("PK_DriverDetails", x => x.Id);
  228. table.ForeignKey(
  229. name: "FK_DriverDetails_Users_UserId",
  230. column: x => x.UserId,
  231. principalTable: "Users",
  232. principalColumn: "Id",
  233. onDelete: ReferentialAction.Cascade);
  234. });
  235. migrationBuilder.CreateTable(
  236. name: "RestaurantUsers",
  237. columns: table => new
  238. {
  239. Id = table.Column<int>(nullable: false)
  240. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  241. Created = table.Column<DateTime>(nullable: false),
  242. Modified = table.Column<DateTime>(nullable: false),
  243. ModifiedBy = table.Column<string>(nullable: true),
  244. IsDeleted = table.Column<bool>(nullable: false),
  245. UserId = table.Column<int>(nullable: false),
  246. RestaurantId = table.Column<int>(nullable: false)
  247. },
  248. constraints: table =>
  249. {
  250. table.PrimaryKey("PK_RestaurantUsers", x => x.Id);
  251. table.ForeignKey(
  252. name: "FK_RestaurantUsers_Restaurants_RestaurantId",
  253. column: x => x.RestaurantId,
  254. principalTable: "Restaurants",
  255. principalColumn: "Id",
  256. onDelete: ReferentialAction.Cascade);
  257. table.ForeignKey(
  258. name: "FK_RestaurantUsers_Users_UserId",
  259. column: x => x.UserId,
  260. principalTable: "Users",
  261. principalColumn: "Id",
  262. onDelete: ReferentialAction.Cascade);
  263. });
  264. migrationBuilder.CreateTable(
  265. name: "UserAddresses",
  266. columns: table => new
  267. {
  268. Id = table.Column<int>(nullable: false)
  269. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  270. Created = table.Column<DateTime>(nullable: false),
  271. Modified = table.Column<DateTime>(nullable: false),
  272. ModifiedBy = table.Column<string>(nullable: true),
  273. IsDeleted = table.Column<bool>(nullable: false),
  274. UserId = table.Column<int>(nullable: false),
  275. IsDefault = table.Column<bool>(nullable: false),
  276. IsComplex = table.Column<bool>(nullable: false),
  277. GoogleMapUrl = table.Column<string>(nullable: true),
  278. Latitude = table.Column<decimal>(nullable: false),
  279. Longitude = table.Column<decimal>(nullable: false),
  280. UnitNumber = table.Column<string>(nullable: true),
  281. ComplexName = table.Column<string>(nullable: true),
  282. StreetNumber = table.Column<string>(nullable: true),
  283. StreetName = table.Column<string>(nullable: true),
  284. Suburb = table.Column<string>(nullable: true),
  285. City = table.Column<string>(nullable: true),
  286. Province = table.Column<string>(nullable: true),
  287. Country = table.Column<string>(nullable: true),
  288. PostalCode = table.Column<string>(nullable: true)
  289. },
  290. constraints: table =>
  291. {
  292. table.PrimaryKey("PK_UserAddresses", x => x.Id);
  293. table.ForeignKey(
  294. name: "FK_UserAddresses_Users_UserId",
  295. column: x => x.UserId,
  296. principalTable: "Users",
  297. principalColumn: "Id",
  298. onDelete: ReferentialAction.Cascade);
  299. });
  300. migrationBuilder.CreateTable(
  301. name: "MenuOptions",
  302. columns: table => new
  303. {
  304. Id = table.Column<int>(nullable: false)
  305. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  306. Created = table.Column<DateTime>(nullable: false),
  307. Modified = table.Column<DateTime>(nullable: false),
  308. ModifiedBy = table.Column<string>(nullable: true),
  309. IsDeleted = table.Column<bool>(nullable: false),
  310. RestaurantId = table.Column<int>(nullable: false),
  311. CategoryId = table.Column<int>(nullable: false),
  312. Description = table.Column<string>(nullable: true),
  313. OptionType = table.Column<int>(nullable: false),
  314. OptionLimit = table.Column<int>(nullable: false),
  315. IsBasePrice = table.Column<bool>(nullable: false),
  316. Rank = table.Column<int>(nullable: false),
  317. MenuItemId = table.Column<int>(nullable: false),
  318. MenuCategoryId = table.Column<int>(nullable: true)
  319. },
  320. constraints: table =>
  321. {
  322. table.PrimaryKey("PK_MenuOptions", x => x.Id);
  323. table.ForeignKey(
  324. name: "FK_MenuOptions_MenuCategories_MenuCategoryId",
  325. column: x => x.MenuCategoryId,
  326. principalTable: "MenuCategories",
  327. principalColumn: "Id",
  328. onDelete: ReferentialAction.Restrict);
  329. table.ForeignKey(
  330. name: "FK_MenuOptions_Restaurants_RestaurantId",
  331. column: x => x.RestaurantId,
  332. principalTable: "Restaurants",
  333. principalColumn: "Id",
  334. onDelete: ReferentialAction.Cascade);
  335. });
  336. migrationBuilder.CreateTable(
  337. name: "RestaurantRolePremissions",
  338. columns: table => new
  339. {
  340. Id = table.Column<int>(nullable: false)
  341. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  342. Created = table.Column<DateTime>(nullable: false),
  343. Modified = table.Column<DateTime>(nullable: false),
  344. ModifiedBy = table.Column<string>(nullable: true),
  345. IsDeleted = table.Column<bool>(nullable: false),
  346. RoleId = table.Column<int>(nullable: false),
  347. Target = table.Column<string>(nullable: true),
  348. Navigate = table.Column<bool>(nullable: false),
  349. Create = table.Column<bool>(nullable: false),
  350. Read = table.Column<bool>(nullable: false),
  351. Write = table.Column<bool>(nullable: false),
  352. Delete = table.Column<bool>(nullable: false)
  353. },
  354. constraints: table =>
  355. {
  356. table.PrimaryKey("PK_RestaurantRolePremissions", x => x.Id);
  357. table.ForeignKey(
  358. name: "FK_RestaurantRolePremissions_RestaurantRoles_RoleId",
  359. column: x => x.RoleId,
  360. principalTable: "RestaurantRoles",
  361. principalColumn: "Id",
  362. onDelete: ReferentialAction.Cascade);
  363. });
  364. migrationBuilder.CreateTable(
  365. name: "MenuOptionItems",
  366. columns: table => new
  367. {
  368. Id = table.Column<int>(nullable: false)
  369. .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
  370. Created = table.Column<DateTime>(nullable: false),
  371. Modified = table.Column<DateTime>(nullable: false),
  372. ModifiedBy = table.Column<string>(nullable: true),
  373. IsDeleted = table.Column<bool>(nullable: false),
  374. MenuOptionId = table.Column<int>(nullable: true),
  375. Description = table.Column<string>(nullable: true),
  376. Price = table.Column<decimal>(nullable: false),
  377. Rank = table.Column<int>(nullable: false)
  378. },
  379. constraints: table =>
  380. {
  381. table.PrimaryKey("PK_MenuOptionItems", x => x.Id);
  382. table.ForeignKey(
  383. name: "FK_MenuOptionItems_MenuOptions_MenuOptionId",
  384. column: x => x.MenuOptionId,
  385. principalTable: "MenuOptions",
  386. principalColumn: "Id",
  387. onDelete: ReferentialAction.Restrict);
  388. });
  389. migrationBuilder.CreateIndex(
  390. name: "IX_DriverDetails_UserId",
  391. table: "DriverDetails",
  392. column: "UserId",
  393. unique: true);
  394. migrationBuilder.CreateIndex(
  395. name: "IX_MenuCategories_RestaurantId",
  396. table: "MenuCategories",
  397. column: "RestaurantId");
  398. migrationBuilder.CreateIndex(
  399. name: "IX_MenuItems_RestaurantId",
  400. table: "MenuItems",
  401. column: "RestaurantId");
  402. migrationBuilder.CreateIndex(
  403. name: "IX_MenuOptionItems_MenuOptionId",
  404. table: "MenuOptionItems",
  405. column: "MenuOptionId");
  406. migrationBuilder.CreateIndex(
  407. name: "IX_MenuOptions_MenuCategoryId",
  408. table: "MenuOptions",
  409. column: "MenuCategoryId");
  410. migrationBuilder.CreateIndex(
  411. name: "IX_MenuOptions_RestaurantId",
  412. table: "MenuOptions",
  413. column: "RestaurantId");
  414. migrationBuilder.CreateIndex(
  415. name: "IX_RestaurantRolePremissions_RoleId",
  416. table: "RestaurantRolePremissions",
  417. column: "RoleId");
  418. migrationBuilder.CreateIndex(
  419. name: "IX_RestaurantRoles_RestaurantId",
  420. table: "RestaurantRoles",
  421. column: "RestaurantId");
  422. migrationBuilder.CreateIndex(
  423. name: "IX_RestaurantUsers_RestaurantId",
  424. table: "RestaurantUsers",
  425. column: "RestaurantId");
  426. migrationBuilder.CreateIndex(
  427. name: "IX_RestaurantUsers_UserId",
  428. table: "RestaurantUsers",
  429. column: "UserId");
  430. migrationBuilder.CreateIndex(
  431. name: "IX_TradingHours_RestaurantId",
  432. table: "TradingHours",
  433. column: "RestaurantId");
  434. migrationBuilder.CreateIndex(
  435. name: "IX_UserAddresses_UserId",
  436. table: "UserAddresses",
  437. column: "UserId");
  438. }
  439. protected override void Down(MigrationBuilder migrationBuilder)
  440. {
  441. migrationBuilder.DropTable(
  442. name: "DriverDetails");
  443. migrationBuilder.DropTable(
  444. name: "Locations");
  445. migrationBuilder.DropTable(
  446. name: "MenuItems");
  447. migrationBuilder.DropTable(
  448. name: "MenuOptionItems");
  449. migrationBuilder.DropTable(
  450. name: "RestaurantCategories");
  451. migrationBuilder.DropTable(
  452. name: "RestaurantRolePremissions");
  453. migrationBuilder.DropTable(
  454. name: "RestaurantUserRestaurantRoles");
  455. migrationBuilder.DropTable(
  456. name: "RestaurantUsers");
  457. migrationBuilder.DropTable(
  458. name: "TradingHours");
  459. migrationBuilder.DropTable(
  460. name: "UserAddresses");
  461. migrationBuilder.DropTable(
  462. name: "MenuOptions");
  463. migrationBuilder.DropTable(
  464. name: "RestaurantRoles");
  465. migrationBuilder.DropTable(
  466. name: "Users");
  467. migrationBuilder.DropTable(
  468. name: "MenuCategories");
  469. migrationBuilder.DropTable(
  470. name: "Restaurants");
  471. }
  472. }
  473. }