using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace NetinaShop.Repository.Migrations { /// public partial class ChangeToComment : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Reviews", schema: "public"); migrationBuilder.CreateTable( name: "Comments", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Title = table.Column(type: "text", nullable: false), Content = table.Column(type: "text", nullable: false), Rate = table.Column(type: "real", nullable: false), IsConfirmed = table.Column(type: "boolean", nullable: false), IsAdmin = table.Column(type: "boolean", nullable: false), IsRoot = table.Column(type: "boolean", nullable: false), ParentId = table.Column(type: "uuid", nullable: true), UserId = table.Column(type: "uuid", nullable: false), Discriminator = table.Column(type: "character varying(21)", maxLength: 21, nullable: false), BlogId = table.Column(type: "uuid", nullable: true), IsBuyer = table.Column(type: "boolean", nullable: true), ProductId = table.Column(type: "uuid", nullable: true), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), IsRemoved = table.Column(type: "boolean", nullable: false), RemovedBy = table.Column(type: "text", nullable: false), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Comments", x => x.Id); table.ForeignKey( name: "FK_Comments_Blogs_BlogId", column: x => x.BlogId, principalSchema: "public", principalTable: "Blogs", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Comments_Comments_ParentId", column: x => x.ParentId, principalSchema: "public", principalTable: "Comments", principalColumn: "Id"); table.ForeignKey( name: "FK_Comments_Products_ProductId", column: x => x.ProductId, principalSchema: "public", principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Comments_Users_UserId", column: x => x.UserId, principalSchema: "public", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_Comments_BlogId", schema: "public", table: "Comments", column: "BlogId"); migrationBuilder.CreateIndex( name: "IX_Comments_ParentId", schema: "public", table: "Comments", column: "ParentId"); migrationBuilder.CreateIndex( name: "IX_Comments_ProductId", schema: "public", table: "Comments", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_Comments_UserId", schema: "public", table: "Comments", column: "UserId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Comments", schema: "public"); migrationBuilder.CreateTable( name: "Reviews", schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), ProductId = table.Column(type: "uuid", nullable: false), UserId = table.Column(type: "uuid", nullable: false), Comment = table.Column(type: "text", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), IsAdmin = table.Column(type: "boolean", nullable: false), IsBuyer = table.Column(type: "boolean", nullable: false), IsConfirmed = table.Column(type: "boolean", nullable: false), IsRemoved = table.Column(type: "boolean", nullable: false), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), ModifiedBy = table.Column(type: "text", nullable: false), Rate = table.Column(type: "real", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), RemovedBy = table.Column(type: "text", nullable: false), Title = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Reviews", x => x.Id); table.ForeignKey( name: "FK_Reviews_Products_ProductId", column: x => x.ProductId, principalSchema: "public", principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Reviews_Users_UserId", column: x => x.UserId, principalSchema: "public", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_Reviews_ProductId", schema: "public", table: "Reviews", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_Reviews_UserId", schema: "public", table: "Reviews", column: "UserId"); } } }