using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace JobsMedical.Web.Migrations { /// public partial class Reviews : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Reviews", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), FacilityId = table.Column(type: "integer", nullable: false), UserId = table.Column(type: "integer", nullable: false), Stars = table.Column(type: "integer", nullable: false), Comment = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true), IsApproved = table.Column(type: "boolean", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Reviews", x => x.Id); table.ForeignKey( name: "FK_Reviews_Facilities_FacilityId", column: x => x.FacilityId, principalTable: "Facilities", 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_FacilityId_UserId", table: "Reviews", columns: new[] { "FacilityId", "UserId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_Reviews_UserId", table: "Reviews", column: "UserId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Reviews"); } } }