diff options
Diffstat (limited to 'Migrations')
-rw-r--r-- | Migrations/20220915213615_InitialCreate.Designer.cs | 56 | ||||
-rw-r--r-- | Migrations/20220915225908_AddBookTitle.Designer.cs | 60 | ||||
-rw-r--r-- | Migrations/20220915225908_AddBookTitle.cs | 26 | ||||
-rw-r--r-- | Migrations/20220915235337_DropBookPublicationDate.cs | 27 | ||||
-rw-r--r-- | Migrations/20220915235413_AddBookPublicationYear.cs | 26 | ||||
-rw-r--r-- | Migrations/20220916003408_InitialMigration.Designer.cs (renamed from Migrations/20220915235337_DropBookPublicationDate.Designer.cs) | 27 | ||||
-rw-r--r-- | Migrations/20220916003408_InitialMigration.cs (renamed from Migrations/20220915213615_InitialCreate.cs) | 16 | ||||
-rw-r--r-- | Migrations/20220916003555_AddBookTable.Designer.cs | 103 | ||||
-rw-r--r-- | Migrations/20220916003555_AddBookTable.cs | 49 | ||||
-rw-r--r-- | Migrations/20220916004044_RenameTables.Designer.cs (renamed from Migrations/20220915235413_AddBookPublicationYear.Designer.cs) | 53 | ||||
-rw-r--r-- | Migrations/20220916004044_RenameTables.cs | 101 | ||||
-rw-r--r-- | Migrations/LibraryContextModelSnapshot.cs | 50 |
12 files changed, 367 insertions, 227 deletions
diff --git a/Migrations/20220915213615_InitialCreate.Designer.cs b/Migrations/20220915213615_InitialCreate.Designer.cs deleted file mode 100644 index 9c88b15..0000000 --- a/Migrations/20220915213615_InitialCreate.Designer.cs +++ /dev/null @@ -1,56 +0,0 @@ -// <auto-generated /> -using System; -using LibraryAPI.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace LibraryAPI.Migrations -{ - [DbContext(typeof(LibraryContext))] - [Migration("20220915213615_InitialCreate")] - partial class InitialCreate - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.9") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("LibraryAPI.Models.Book", b => - { - b.Property<long>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id")); - - b.Property<int>("Edition") - .HasColumnType("integer"); - - b.Property<string[]>("Genres") - .IsRequired() - .HasColumnType("text[]"); - - b.Property<string>("ISBN") - .IsRequired() - .HasColumnType("text"); - - b.Property<DateTime>("PublicationDate") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.ToTable("Books"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Migrations/20220915225908_AddBookTitle.Designer.cs b/Migrations/20220915225908_AddBookTitle.Designer.cs deleted file mode 100644 index 1208102..0000000 --- a/Migrations/20220915225908_AddBookTitle.Designer.cs +++ /dev/null @@ -1,60 +0,0 @@ -// <auto-generated /> -using System; -using LibraryAPI.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace LibraryAPI.Migrations -{ - [DbContext(typeof(LibraryContext))] - [Migration("20220915225908_AddBookTitle")] - partial class AddBookTitle - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.9") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("LibraryAPI.Models.Book", b => - { - b.Property<long>("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id")); - - b.Property<int>("Edition") - .HasColumnType("integer"); - - b.Property<string[]>("Genres") - .IsRequired() - .HasColumnType("text[]"); - - b.Property<string>("ISBN") - .IsRequired() - .HasColumnType("text"); - - b.Property<DateTime>("PublicationDate") - .HasColumnType("timestamp with time zone"); - - b.Property<string>("Title") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Books"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Migrations/20220915225908_AddBookTitle.cs b/Migrations/20220915225908_AddBookTitle.cs deleted file mode 100644 index ef3f3a7..0000000 --- a/Migrations/20220915225908_AddBookTitle.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace LibraryAPI.Migrations -{ - public partial class AddBookTitle : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn<string>( - name: "Title", - table: "Books", - type: "text", - nullable: false, - defaultValue: ""); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Title", - table: "Books"); - } - } -} diff --git a/Migrations/20220915235337_DropBookPublicationDate.cs b/Migrations/20220915235337_DropBookPublicationDate.cs deleted file mode 100644 index 4d16267..0000000 --- a/Migrations/20220915235337_DropBookPublicationDate.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace LibraryAPI.Migrations -{ - public partial class DropBookPublicationDate : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "PublicationDate", - table: "Books"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn<DateTime>( - name: "PublicationDate", - table: "Books", - type: "timestamp with time zone", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - } - } -} diff --git a/Migrations/20220915235413_AddBookPublicationYear.cs b/Migrations/20220915235413_AddBookPublicationYear.cs deleted file mode 100644 index 12bf4b3..0000000 --- a/Migrations/20220915235413_AddBookPublicationYear.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace LibraryAPI.Migrations -{ - public partial class AddBookPublicationYear : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn<int>( - name: "PublicationYear", - table: "Books", - type: "integer", - nullable: false, - defaultValue: 0); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "PublicationYear", - table: "Books"); - } - } -} diff --git a/Migrations/20220915235337_DropBookPublicationDate.Designer.cs b/Migrations/20220916003408_InitialMigration.Designer.cs index e97f909..a4985b4 100644 --- a/Migrations/20220915235337_DropBookPublicationDate.Designer.cs +++ b/Migrations/20220916003408_InitialMigration.Designer.cs @@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace LibraryAPI.Migrations { [DbContext(typeof(LibraryContext))] - [Migration("20220915235337_DropBookPublicationDate")] - partial class DropBookPublicationDate + [Migration("20220916003408_InitialMigration")] + partial class InitialMigration { protected override void BuildTargetModel(ModelBuilder modelBuilder) { @@ -24,7 +24,7 @@ namespace LibraryAPI.Migrations NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - modelBuilder.Entity("LibraryAPI.Models.Book", b => + modelBuilder.Entity("LibraryAPI.Models.Author", b => { b.Property<long>("Id") .ValueGeneratedOnAdd() @@ -32,24 +32,21 @@ namespace LibraryAPI.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id")); - b.Property<int>("Edition") - .HasColumnType("integer"); - - b.Property<string[]>("Genres") - .IsRequired() - .HasColumnType("text[]"); - - b.Property<string>("ISBN") - .IsRequired() + b.Property<string>("Country") .HasColumnType("text"); - b.Property<string>("Title") - .IsRequired() + b.Property<string>("Name") .HasColumnType("text"); + b.Property<int>("YearOfBirth") + .HasColumnType("integer"); + + b.Property<string[]>("languages") + .HasColumnType("text[]"); + b.HasKey("Id"); - b.ToTable("Books"); + b.ToTable("Author"); }); #pragma warning restore 612, 618 } diff --git a/Migrations/20220915213615_InitialCreate.cs b/Migrations/20220916003408_InitialMigration.cs index ae3abe2..620f926 100644 --- a/Migrations/20220915213615_InitialCreate.cs +++ b/Migrations/20220916003408_InitialMigration.cs @@ -6,31 +6,31 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace LibraryAPI.Migrations { - public partial class InitialCreate : Migration + public partial class InitialMigration : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( - name: "Books", + name: "Author", columns: table => new { Id = table.Column<long>(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - PublicationDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), - Genres = table.Column<string[]>(type: "text[]", nullable: false), - Edition = table.Column<int>(type: "integer", nullable: false), - ISBN = table.Column<string>(type: "text", nullable: false) + Country = table.Column<string>(type: "text", nullable: true), + Name = table.Column<string>(type: "text", nullable: true), + YearOfBirth = table.Column<int>(type: "integer", nullable: false), + languages = table.Column<string[]>(type: "text[]", nullable: true) }, constraints: table => { - table.PrimaryKey("PK_Books", x => x.Id); + table.PrimaryKey("PK_Author", x => x.Id); }); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( - name: "Books"); + name: "Author"); } } } diff --git a/Migrations/20220916003555_AddBookTable.Designer.cs b/Migrations/20220916003555_AddBookTable.Designer.cs new file mode 100644 index 0000000..b4a1609 --- /dev/null +++ b/Migrations/20220916003555_AddBookTable.Designer.cs @@ -0,0 +1,103 @@ +// <auto-generated /> +using System; +using LibraryAPI.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + [DbContext(typeof(LibraryContext))] + [Migration("20220916003555_AddBookTable")] + partial class AddBookTable + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Property<long>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id")); + + b.Property<string>("Country") + .HasColumnType("text"); + + b.Property<string>("Name") + .HasColumnType("text"); + + b.Property<int>("YearOfBirth") + .HasColumnType("integer"); + + b.Property<string[]>("languages") + .HasColumnType("text[]"); + + b.HasKey("Id"); + + b.ToTable("Author"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.Property<long>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id")); + + b.Property<long>("AuthorId") + .HasColumnType("bigint"); + + b.Property<int>("Edition") + .HasColumnType("integer"); + + b.Property<string[]>("Genres") + .HasColumnType("text[]"); + + b.Property<string>("ISBN") + .HasColumnType("text"); + + b.Property<int>("PublicationYear") + .HasColumnType("integer"); + + b.Property<string>("Title") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Book"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.HasOne("LibraryAPI.Models.Author", "Author") + .WithMany("Books") + .HasForeignKey("AuthorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Navigation("Books"); + }); +#pragma warning restore 612, 618 + } + } +} 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"); + } + } +} diff --git a/Migrations/20220915235413_AddBookPublicationYear.Designer.cs b/Migrations/20220916004044_RenameTables.Designer.cs index 072bb5c..a6d3439 100644 --- a/Migrations/20220915235413_AddBookPublicationYear.Designer.cs +++ b/Migrations/20220916004044_RenameTables.Designer.cs @@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace LibraryAPI.Migrations { [DbContext(typeof(LibraryContext))] - [Migration("20220915235413_AddBookPublicationYear")] - partial class AddBookPublicationYear + [Migration("20220916004044_RenameTables")] + partial class RenameTables { protected override void BuildTargetModel(ModelBuilder modelBuilder) { @@ -24,6 +24,31 @@ namespace LibraryAPI.Migrations NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Property<long>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id")); + + b.Property<string>("Country") + .HasColumnType("text"); + + b.Property<string>("Name") + .HasColumnType("text"); + + b.Property<int>("YearOfBirth") + .HasColumnType("integer"); + + b.Property<string[]>("languages") + .HasColumnType("text[]"); + + b.HasKey("Id"); + + b.ToTable("Authors"); + }); + modelBuilder.Entity("LibraryAPI.Models.Book", b => { b.Property<long>("Id") @@ -32,28 +57,46 @@ namespace LibraryAPI.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id")); + b.Property<long>("AuthorId") + .HasColumnType("bigint"); + b.Property<int>("Edition") .HasColumnType("integer"); b.Property<string[]>("Genres") - .IsRequired() .HasColumnType("text[]"); b.Property<string>("ISBN") - .IsRequired() .HasColumnType("text"); b.Property<int>("PublicationYear") .HasColumnType("integer"); b.Property<string>("Title") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); + b.HasIndex("AuthorId"); + b.ToTable("Books"); }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.HasOne("LibraryAPI.Models.Author", "Author") + .WithMany("Books") + .HasForeignKey("AuthorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Navigation("Books"); + }); #pragma warning restore 612, 618 } } 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); + } + } +} diff --git a/Migrations/LibraryContextModelSnapshot.cs b/Migrations/LibraryContextModelSnapshot.cs index d340ff6..0fa3e9b 100644 --- a/Migrations/LibraryContextModelSnapshot.cs +++ b/Migrations/LibraryContextModelSnapshot.cs @@ -22,6 +22,31 @@ namespace LibraryAPI.Migrations NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Property<long>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id")); + + b.Property<string>("Country") + .HasColumnType("text"); + + b.Property<string>("Name") + .HasColumnType("text"); + + b.Property<int>("YearOfBirth") + .HasColumnType("integer"); + + b.Property<string[]>("languages") + .HasColumnType("text[]"); + + b.HasKey("Id"); + + b.ToTable("Authors"); + }); + modelBuilder.Entity("LibraryAPI.Models.Book", b => { b.Property<long>("Id") @@ -30,29 +55,46 @@ namespace LibraryAPI.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id")); + b.Property<long>("AuthorId") + .HasColumnType("bigint"); + b.Property<int>("Edition") .HasColumnType("integer"); b.Property<string[]>("Genres") - .IsRequired() .HasColumnType("text[]"); b.Property<string>("ISBN") - .IsRequired() .HasColumnType("text"); b.Property<int>("PublicationYear") - .IsRequired() .HasColumnType("integer"); b.Property<string>("Title") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); + b.HasIndex("AuthorId"); + b.ToTable("Books"); }); + + modelBuilder.Entity("LibraryAPI.Models.Book", b => + { + b.HasOne("LibraryAPI.Models.Author", "Author") + .WithMany("Books") + .HasForeignKey("AuthorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + }); + + modelBuilder.Entity("LibraryAPI.Models.Author", b => + { + b.Navigation("Books"); + }); #pragma warning restore 612, 618 } } |