using System; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; namespace ProRestaurant.Migrations { public partial class initialCreate : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Restaurants", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), Name = table.Column(nullable: true), Location = table.Column(nullable: true), Logo = table.Column(nullable: true), Chain = table.Column(nullable: false), DeliveryFee = table.Column(nullable: false), DeliveryRadius = table.Column(nullable: false), MethodsOfPayment = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Restaurants", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), EmailAddress = table.Column(nullable: true), Password = table.Column(nullable: true), FirstName = table.Column(nullable: true), Surname = table.Column(nullable: true), Cellphone = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "MenuCategories", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), RestaurantId = table.Column(nullable: false), Description = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_MenuCategories", x => x.Id); table.ForeignKey( name: "FK_MenuCategories_Restaurants_RestaurantId", column: x => x.RestaurantId, principalTable: "Restaurants", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "MenuItems", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), RestaurantId = table.Column(nullable: false), CategoryId = table.Column(nullable: false), Image = table.Column(nullable: true), Description = table.Column(nullable: true), Price = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_MenuItems", x => x.Id); table.ForeignKey( name: "FK_MenuItems_Restaurants_RestaurantId", column: x => x.RestaurantId, principalTable: "Restaurants", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "TradingHours", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), RestaurantId = table.Column(nullable: false), Description = table.Column(nullable: true), OpeningTime = table.Column(nullable: false), ClosingTime = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_TradingHours", x => x.Id); table.ForeignKey( name: "FK_TradingHours_Restaurants_RestaurantId", column: x => x.RestaurantId, principalTable: "Restaurants", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "DriverDetails", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), UserId = table.Column(nullable: false), Photo = table.Column(nullable: true), RegistrationNumber = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_DriverDetails", x => x.Id); table.ForeignKey( name: "FK_DriverDetails_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "UserAddresses", columns: table => new { Id = table.Column(nullable: false) .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), Created = table.Column(nullable: false), Modified = table.Column(nullable: false), ModifiedBy = table.Column(nullable: true), IsDeleted = table.Column(nullable: false), UserId = table.Column(nullable: false), Latitude = table.Column(nullable: false), Longitude = table.Column(nullable: false), UnitNumber = table.Column(nullable: true), ComplexName = table.Column(nullable: true), SteetNumber = table.Column(nullable: true), StreetName = table.Column(nullable: true), Suburb = table.Column(nullable: true), City = table.Column(nullable: true), Provice = table.Column(nullable: true), Country = table.Column(nullable: true), PostalCode = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_UserAddresses", x => x.Id); table.ForeignKey( name: "FK_UserAddresses_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_DriverDetails_UserId", table: "DriverDetails", column: "UserId", unique: true); migrationBuilder.CreateIndex( name: "IX_MenuCategories_RestaurantId", table: "MenuCategories", column: "RestaurantId"); migrationBuilder.CreateIndex( name: "IX_MenuItems_RestaurantId", table: "MenuItems", column: "RestaurantId"); migrationBuilder.CreateIndex( name: "IX_TradingHours_RestaurantId", table: "TradingHours", column: "RestaurantId"); migrationBuilder.CreateIndex( name: "IX_UserAddresses_UserId", table: "UserAddresses", column: "UserId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "DriverDetails"); migrationBuilder.DropTable( name: "MenuCategories"); migrationBuilder.DropTable( name: "MenuItems"); migrationBuilder.DropTable( name: "TradingHours"); migrationBuilder.DropTable( name: "UserAddresses"); migrationBuilder.DropTable( name: "Restaurants"); migrationBuilder.DropTable( name: "Users"); } } }