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(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), AuthorId = table.Column(type: "bigint", nullable: false), PublicationYear = table.Column(type: "integer", nullable: false), Genres = table.Column(type: "text[]", nullable: true), Edition = table.Column(type: "integer", nullable: false), ISBN = table.Column(type: "text", nullable: true), Title = table.Column(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"); } } }