using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace backend.Migrations { public partial class AddReviews : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "IsAdmin", table: "Users", type: "boolean", nullable: false, defaultValue: false); migrationBuilder.CreateTable( name: "Reviews", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Title = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: false), Stars = table.Column(type: "integer", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), UserId = table.Column(type: "integer", nullable: false), RestaurantId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Reviews", x => x.Id); table.ForeignKey( name: "FK_Reviews_Restoraunts_RestaurantId", column: x => x.RestaurantId, principalTable: "Restoraunts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Reviews_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Reviews_RestaurantId", table: "Reviews", column: "RestaurantId"); migrationBuilder.CreateIndex( name: "IX_Reviews_UserId", table: "Reviews", column: "UserId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Reviews"); migrationBuilder.DropColumn( name: "IsAdmin", table: "Users"); } } }