From 2c9c2cc3b414115bca9b6c63ca7b20d49a8a8ec1 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Thu, 15 Sep 2022 20:55:44 -0500 Subject: Agregar autor --- Migrations/20220916004044_RenameTables.cs | 101 ++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 Migrations/20220916004044_RenameTables.cs (limited to 'Migrations/20220916004044_RenameTables.cs') diff --git a/Migrations/20220916004044_RenameTables.cs b/Migrations/20220916004044_RenameTables.cs new file mode 100644 index 0000000..c5f984b --- /dev/null +++ b/Migrations/20220916004044_RenameTables.cs @@ -0,0 +1,101 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + public partial class RenameTables : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Book_Author_AuthorId", + table: "Book"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Book", + table: "Book"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Author", + table: "Author"); + + migrationBuilder.RenameTable( + name: "Book", + newName: "Books"); + + migrationBuilder.RenameTable( + name: "Author", + newName: "Authors"); + + migrationBuilder.RenameIndex( + name: "IX_Book_AuthorId", + table: "Books", + newName: "IX_Books_AuthorId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Books", + table: "Books", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Authors", + table: "Authors", + column: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Books_Authors_AuthorId", + table: "Books", + column: "AuthorId", + principalTable: "Authors", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Books_Authors_AuthorId", + table: "Books"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Books", + table: "Books"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Authors", + table: "Authors"); + + migrationBuilder.RenameTable( + name: "Books", + newName: "Book"); + + migrationBuilder.RenameTable( + name: "Authors", + newName: "Author"); + + migrationBuilder.RenameIndex( + name: "IX_Books_AuthorId", + table: "Book", + newName: "IX_Book_AuthorId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Book", + table: "Book", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Author", + table: "Author", + column: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Book_Author_AuthorId", + table: "Book", + column: "AuthorId", + principalTable: "Author", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} -- cgit v1.2.3