summaryrefslogtreecommitdiff
path: root/Migrations/20220916004044_RenameTables.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Migrations/20220916004044_RenameTables.cs')
-rw-r--r--Migrations/20220916004044_RenameTables.cs101
1 files changed, 101 insertions, 0 deletions
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);
+ }
+ }
+}