hn-dotnet/Infrastructure/Migrations/20201211144029_AddCreatedBy.cs
Julien Leicher 3cd5133f66 add-aspnet-identity (#26)
add exception filter when user not connected
default to needing authentication and apply anonymous to some actions
add user in get requests
add user relation in link, comment and vote
signup and in are ok now!
2020-12-11 17:59:35 +01:00

179 lines
5.9 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Infrastructure.Migrations
{
public partial class AddCreatedBy : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_link_votes",
table: "link_votes");
migrationBuilder.DropPrimaryKey(
name: "PK_comment_votes",
table: "comment_votes");
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: "link_votes",
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.AddColumn<Guid>(
name: "CreatedBy",
table: "comment_votes",
type: "TEXT",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddPrimaryKey(
name: "PK_link_votes",
table: "link_votes",
columns: new[] { "LinkId", "CreatedBy" });
migrationBuilder.AddPrimaryKey(
name: "PK_comment_votes",
table: "comment_votes",
columns: new[] { "CommentId", "CreatedBy" });
migrationBuilder.CreateIndex(
name: "IX_links_CreatedBy",
table: "links",
column: "CreatedBy");
migrationBuilder.CreateIndex(
name: "IX_link_votes_CreatedBy",
table: "link_votes",
column: "CreatedBy");
migrationBuilder.CreateIndex(
name: "IX_comments_CreatedBy",
table: "comments",
column: "CreatedBy");
migrationBuilder.CreateIndex(
name: "IX_comment_votes_CreatedBy",
table: "comment_votes",
column: "CreatedBy");
migrationBuilder.AddForeignKey(
name: "FK_comment_votes_AspNetUsers_CreatedBy",
table: "comment_votes",
column: "CreatedBy",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_comments_AspNetUsers_CreatedBy",
table: "comments",
column: "CreatedBy",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_link_votes_AspNetUsers_CreatedBy",
table: "link_votes",
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_comment_votes_AspNetUsers_CreatedBy",
table: "comment_votes");
migrationBuilder.DropForeignKey(
name: "FK_comments_AspNetUsers_CreatedBy",
table: "comments");
migrationBuilder.DropForeignKey(
name: "FK_link_votes_AspNetUsers_CreatedBy",
table: "link_votes");
migrationBuilder.DropForeignKey(
name: "FK_links_AspNetUsers_CreatedBy",
table: "links");
migrationBuilder.DropIndex(
name: "IX_links_CreatedBy",
table: "links");
migrationBuilder.DropPrimaryKey(
name: "PK_link_votes",
table: "link_votes");
migrationBuilder.DropIndex(
name: "IX_link_votes_CreatedBy",
table: "link_votes");
migrationBuilder.DropIndex(
name: "IX_comments_CreatedBy",
table: "comments");
migrationBuilder.DropPrimaryKey(
name: "PK_comment_votes",
table: "comment_votes");
migrationBuilder.DropIndex(
name: "IX_comment_votes_CreatedBy",
table: "comment_votes");
migrationBuilder.DropColumn(
name: "CreatedBy",
table: "links");
migrationBuilder.DropColumn(
name: "CreatedBy",
table: "link_votes");
migrationBuilder.DropColumn(
name: "CreatedBy",
table: "comments");
migrationBuilder.DropColumn(
name: "CreatedBy",
table: "comment_votes");
migrationBuilder.AddPrimaryKey(
name: "PK_link_votes",
table: "link_votes",
column: "LinkId");
migrationBuilder.AddPrimaryKey(
name: "PK_comment_votes",
table: "comment_votes",
column: "CommentId");
}
}
}