using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace backend.Migrations { public partial class InitialArchitecture : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Username = table.Column(type: "text", nullable: false), Password = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "Restoraunts", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), OwnerFk = table.Column(type: "integer", nullable: true), Name = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Restoraunts", x => x.Id); table.ForeignKey( name: "FK_Restoraunts_Users_OwnerFk", column: x => x.OwnerFk, principalTable: "Users", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Reservations", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), StartDate = table.Column(type: "timestamp with time zone", nullable: false), RestaurantId = table.Column(type: "integer", nullable: false), ReservationPlace = table.Column(type: "integer", nullable: false), ReservationStatus = table.Column(type: "integer", nullable: false), ReservationType = table.Column(type: "integer", nullable: false), ContactName = table.Column(type: "text", nullable: false), ContactNumber = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Reservations", x => x.Id); table.ForeignKey( name: "FK_Reservations_Restoraunts_RestaurantId", column: x => x.RestaurantId, principalTable: "Restoraunts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Reservations_RestaurantId", table: "Reservations", column: "RestaurantId"); migrationBuilder.CreateIndex( name: "IX_Restoraunts_OwnerFk", table: "Restoraunts", column: "OwnerFk", unique: true); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Reservations"); migrationBuilder.DropTable( name: "Restoraunts"); migrationBuilder.DropTable( name: "Users"); } } }