diff options
author | HombreLaser <sebastian-440@live.com> | 2022-09-15 20:55:44 -0500 |
---|---|---|
committer | HombreLaser <sebastian-440@live.com> | 2022-09-15 20:55:44 -0500 |
commit | 2c9c2cc3b414115bca9b6c63ca7b20d49a8a8ec1 (patch) | |
tree | 0344372eca04eab992ece36c4e07511f6f0214c6 /Migrations/20220916003555_AddBookTable.cs | |
parent | 3381c633fcd73e5159ae4a607835167ebdbb12ee (diff) |
Agregar autor
Diffstat (limited to 'Migrations/20220916003555_AddBookTable.cs')
-rw-r--r-- | Migrations/20220916003555_AddBookTable.cs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Migrations/20220916003555_AddBookTable.cs b/Migrations/20220916003555_AddBookTable.cs new file mode 100644 index 0000000..4612dee --- /dev/null +++ b/Migrations/20220916003555_AddBookTable.cs @@ -0,0 +1,49 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + public partial class AddBookTable : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Book", + columns: table => new + { + Id = table.Column<long>(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + AuthorId = table.Column<long>(type: "bigint", nullable: false), + PublicationYear = table.Column<int>(type: "integer", nullable: false), + Genres = table.Column<string[]>(type: "text[]", nullable: true), + Edition = table.Column<int>(type: "integer", nullable: false), + ISBN = table.Column<string>(type: "text", nullable: true), + Title = table.Column<string>(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Book", x => x.Id); + table.ForeignKey( + name: "FK_Book_Author_AuthorId", + column: x => x.AuthorId, + principalTable: "Author", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Book_AuthorId", + table: "Book", + column: "AuthorId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Book"); + } + } +} |