Api/Netina.Repository/Migrations/20240905093846_AddAuthor.cs

98 lines
3.0 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace NetinaShop.Repository.Migrations
{
/// <inheritdoc />
public partial class AddAuthor : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "AuthorId",
schema: "public",
table: "Products",
type: "uuid",
nullable: false,
defaultValue: new Guid("11c47231-4f8b-4a73-b848-d2edf3c2d9ab"));
migrationBuilder.AddColumn<Guid>(
name: "AuthorId",
schema: "public",
table: "Blogs",
type: "uuid",
nullable: false,
defaultValue: new Guid("11c47231-4f8b-4a73-b848-d2edf3c2d9ab"));
migrationBuilder.CreateIndex(
name: "IX_Products_AuthorId",
schema: "public",
table: "Products",
column: "AuthorId");
migrationBuilder.CreateIndex(
name: "IX_Blogs_AuthorId",
schema: "public",
table: "Blogs",
column: "AuthorId");
migrationBuilder.AddForeignKey(
name: "FK_Blogs_Users_AuthorId",
schema: "public",
table: "Blogs",
column: "AuthorId",
principalSchema: "public",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Products_Users_AuthorId",
schema: "public",
table: "Products",
column: "AuthorId",
principalSchema: "public",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Blogs_Users_AuthorId",
schema: "public",
table: "Blogs");
migrationBuilder.DropForeignKey(
name: "FK_Products_Users_AuthorId",
schema: "public",
table: "Products");
migrationBuilder.DropIndex(
name: "IX_Products_AuthorId",
schema: "public",
table: "Products");
migrationBuilder.DropIndex(
name: "IX_Blogs_AuthorId",
schema: "public",
table: "Blogs");
migrationBuilder.DropColumn(
name: "AuthorId",
schema: "public",
table: "Products");
migrationBuilder.DropColumn(
name: "AuthorId",
schema: "public",
table: "Blogs");
}
}
}