using System; using Microsoft.EntityFrameworkCore.Migrations; namespace DevHive.Data.Migrations { public partial class rating_migration : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Rating_Posts_PostId", table: "Rating"); migrationBuilder.DropIndex( name: "IX_Rating_PostId", table: "Rating"); migrationBuilder.DropColumn( name: "Rate", table: "Rating"); migrationBuilder.AlterColumn( name: "PostId", table: "Rating", type: "uuid", nullable: true, oldClrType: typeof(Guid), oldType: "uuid"); migrationBuilder.AddColumn( name: "IsLike", table: "Rating", type: "boolean", nullable: false, defaultValue: false); migrationBuilder.AddColumn( name: "UserId", table: "Rating", type: "uuid", nullable: true); migrationBuilder.AddColumn( name: "CurrentRating", table: "Posts", type: "integer", nullable: false, defaultValue: 0); migrationBuilder.CreateIndex( name: "IX_Rating_PostId", table: "Rating", column: "PostId"); migrationBuilder.CreateIndex( name: "IX_Rating_UserId", table: "Rating", column: "UserId"); migrationBuilder.AddForeignKey( name: "FK_Rating_AspNetUsers_UserId", table: "Rating", column: "UserId", principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_Rating_Posts_PostId", table: "Rating", column: "PostId", principalTable: "Posts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Rating_AspNetUsers_UserId", table: "Rating"); migrationBuilder.DropForeignKey( name: "FK_Rating_Posts_PostId", table: "Rating"); migrationBuilder.DropIndex( name: "IX_Rating_PostId", table: "Rating"); migrationBuilder.DropIndex( name: "IX_Rating_UserId", table: "Rating"); migrationBuilder.DropColumn( name: "IsLike", table: "Rating"); migrationBuilder.DropColumn( name: "UserId", table: "Rating"); migrationBuilder.DropColumn( name: "CurrentRating", table: "Posts"); migrationBuilder.AlterColumn( name: "PostId", table: "Rating", type: "uuid", nullable: false, defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), oldClrType: typeof(Guid), oldType: "uuid", oldNullable: true); migrationBuilder.AddColumn( name: "Rate", table: "Rating", type: "integer", nullable: false, defaultValue: 0); migrationBuilder.CreateIndex( name: "IX_Rating_PostId", table: "Rating", column: "PostId", unique: true); migrationBuilder.AddForeignKey( name: "FK_Rating_Posts_PostId", table: "Rating", column: "PostId", principalTable: "Posts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } } }