Api/Netina.Repository/Migrations/20240924112404_ChangeToComm...

163 lines
7.6 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace NetinaShop.Repository.Migrations
{
/// <inheritdoc />
public partial class ChangeToComment : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Reviews",
schema: "public");
migrationBuilder.CreateTable(
name: "Comments",
schema: "public",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Title = table.Column<string>(type: "text", nullable: false),
Content = table.Column<string>(type: "text", nullable: false),
Rate = table.Column<float>(type: "real", nullable: false),
IsConfirmed = table.Column<bool>(type: "boolean", nullable: false),
IsAdmin = table.Column<bool>(type: "boolean", nullable: false),
IsRoot = table.Column<bool>(type: "boolean", nullable: false),
ParentId = table.Column<Guid>(type: "uuid", nullable: true),
UserId = table.Column<Guid>(type: "uuid", nullable: false),
Discriminator = table.Column<string>(type: "character varying(21)", maxLength: 21, nullable: false),
BlogId = table.Column<Guid>(type: "uuid", nullable: true),
IsBuyer = table.Column<bool>(type: "boolean", nullable: true),
ProductId = table.Column<Guid>(type: "uuid", nullable: true),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(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");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Comments",
schema: "public");
migrationBuilder.CreateTable(
name: "Reviews",
schema: "public",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
UserId = table.Column<Guid>(type: "uuid", nullable: false),
Comment = table.Column<string>(type: "text", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
IsAdmin = table.Column<bool>(type: "boolean", nullable: false),
IsBuyer = table.Column<bool>(type: "boolean", nullable: false),
IsConfirmed = table.Column<bool>(type: "boolean", nullable: false),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false),
Rate = table.Column<float>(type: "real", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
Title = table.Column<string>(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");
}
}
}