hn-20-2/Infrastructure/Migrations/20210429093017_AddCreatedBy.cs
2021-04-29 11:46:17 +02:00

82 lines
2.3 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Infrastructure.Migrations
{
public partial class AddCreatedBy : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("DELETE FROM Comments;");
migrationBuilder.Sql("DELETE FROM Links;");
migrationBuilder.AddColumn<Guid>(
name: "CreatedBy",
table: "Links",
type: "TEXT",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<Guid>(
name: "CreatedBy",
table: "Comments",
type: "TEXT",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.CreateIndex(
name: "IX_Links_CreatedBy",
table: "Links",
column: "CreatedBy");
migrationBuilder.CreateIndex(
name: "IX_Comments_CreatedBy",
table: "Comments",
column: "CreatedBy");
migrationBuilder.AddForeignKey(
name: "FK_Comments_AspNetUsers_CreatedBy",
table: "Comments",
column: "CreatedBy",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Links_AspNetUsers_CreatedBy",
table: "Links",
column: "CreatedBy",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Comments_AspNetUsers_CreatedBy",
table: "Comments");
migrationBuilder.DropForeignKey(
name: "FK_Links_AspNetUsers_CreatedBy",
table: "Links");
migrationBuilder.DropIndex(
name: "IX_Links_CreatedBy",
table: "Links");
migrationBuilder.DropIndex(
name: "IX_Comments_CreatedBy",
table: "Comments");
migrationBuilder.DropColumn(
name: "CreatedBy",
table: "Links");
migrationBuilder.DropColumn(
name: "CreatedBy",
table: "Comments");
}
}
}