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( name: "CreatedBy", table: "links", type: "TEXT", nullable: false, defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); migrationBuilder.AddColumn( name: "CreatedBy", table: "link_votes", type: "TEXT", nullable: false, defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); migrationBuilder.AddColumn( name: "CreatedBy", table: "comments", type: "TEXT", nullable: false, defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); migrationBuilder.AddColumn( 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"); } } }