From 3381c633fcd73e5159ae4a607835167ebdbb12ee Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Thu, 15 Sep 2022 18:58:24 -0500 Subject: Cambiar PublicationDate por PublicationYear --- ...20915235337_DropBookPublicationDate.Designer.cs | 57 ++++++++++++++++++++ .../20220915235337_DropBookPublicationDate.cs | 27 ++++++++++ ...220915235413_AddBookPublicationYear.Designer.cs | 60 ++++++++++++++++++++++ .../20220915235413_AddBookPublicationYear.cs | 26 ++++++++++ Migrations/LibraryContextModelSnapshot.cs | 9 +++- Models/Book.cs | 4 +- obj/LibraryAPI.csproj.nuget.dgspec.json | 10 ++-- obj/project.assets.json | 6 +-- 8 files changed, 187 insertions(+), 12 deletions(-) create mode 100644 Migrations/20220915235337_DropBookPublicationDate.Designer.cs create mode 100644 Migrations/20220915235337_DropBookPublicationDate.cs create mode 100644 Migrations/20220915235413_AddBookPublicationYear.Designer.cs create mode 100644 Migrations/20220915235413_AddBookPublicationYear.cs diff --git a/Migrations/20220915235337_DropBookPublicationDate.Designer.cs b/Migrations/20220915235337_DropBookPublicationDate.Designer.cs new file mode 100644 index 0000000..e97f909 --- /dev/null +++ b/Migrations/20220915235337_DropBookPublicationDate.Designer.cs @@ -0,0 +1,57 @@ +// +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("20220915235337_DropBookPublicationDate")] + partial class DropBookPublicationDate + { + 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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Edition") + .HasColumnType("integer"); + + b.Property("Genres") + .IsRequired() + .HasColumnType("text[]"); + + b.Property("ISBN") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Books"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20220915235337_DropBookPublicationDate.cs b/Migrations/20220915235337_DropBookPublicationDate.cs new file mode 100644 index 0000000..4d16267 --- /dev/null +++ b/Migrations/20220915235337_DropBookPublicationDate.cs @@ -0,0 +1,27 @@ +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( + 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.Designer.cs b/Migrations/20220915235413_AddBookPublicationYear.Designer.cs new file mode 100644 index 0000000..072bb5c --- /dev/null +++ b/Migrations/20220915235413_AddBookPublicationYear.Designer.cs @@ -0,0 +1,60 @@ +// +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("20220915235413_AddBookPublicationYear")] + partial class AddBookPublicationYear + { + 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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Edition") + .HasColumnType("integer"); + + b.Property("Genres") + .IsRequired() + .HasColumnType("text[]"); + + b.Property("ISBN") + .IsRequired() + .HasColumnType("text"); + + b.Property("PublicationYear") + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Books"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20220915235413_AddBookPublicationYear.cs b/Migrations/20220915235413_AddBookPublicationYear.cs new file mode 100644 index 0000000..12bf4b3 --- /dev/null +++ b/Migrations/20220915235413_AddBookPublicationYear.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + public partial class AddBookPublicationYear : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + 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/LibraryContextModelSnapshot.cs b/Migrations/LibraryContextModelSnapshot.cs index 734dcc0..d340ff6 100644 --- a/Migrations/LibraryContextModelSnapshot.cs +++ b/Migrations/LibraryContextModelSnapshot.cs @@ -41,8 +41,13 @@ namespace LibraryAPI.Migrations .IsRequired() .HasColumnType("text"); - b.Property("PublicationDate") - .HasColumnType("timestamp with time zone"); + b.Property("PublicationYear") + .IsRequired() + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); b.HasKey("Id"); diff --git a/Models/Book.cs b/Models/Book.cs index d648c12..bcf9ef7 100644 --- a/Models/Book.cs +++ b/Models/Book.cs @@ -6,10 +6,10 @@ namespace LibraryAPI.Models { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public long Id { get; set; } - public DateTime PublicationDate { get; set; } - + public int PublicationYear { get; set; } public string[] Genres { get; set; } public int Edition { get; set; } public string ISBN { get; set; } + public string Title { get; set; } } } \ No newline at end of file diff --git a/obj/LibraryAPI.csproj.nuget.dgspec.json b/obj/LibraryAPI.csproj.nuget.dgspec.json index e6462cd..2740cb5 100644 --- a/obj/LibraryAPI.csproj.nuget.dgspec.json +++ b/obj/LibraryAPI.csproj.nuget.dgspec.json @@ -1,17 +1,17 @@ { "format": 1, "restore": { - "/mnt/Personal/Documentos/LCC/7mo Semestre/BackEnd/LibraryAPI/LibraryAPI.csproj": {} + "/home/luis/Documentos/LCC/7mo Semestre/BackEnd/LibraryAPI/LibraryAPI.csproj": {} }, "projects": { - "/mnt/Personal/Documentos/LCC/7mo Semestre/BackEnd/LibraryAPI/LibraryAPI.csproj": { + "/home/luis/Documentos/LCC/7mo Semestre/BackEnd/LibraryAPI/LibraryAPI.csproj": { "version": "1.0.0", "restore": { - "projectUniqueName": "/mnt/Personal/Documentos/LCC/7mo Semestre/BackEnd/LibraryAPI/LibraryAPI.csproj", + "projectUniqueName": "/home/luis/Documentos/LCC/7mo Semestre/BackEnd/LibraryAPI/LibraryAPI.csproj", "projectName": "LibraryAPI", - "projectPath": "/mnt/Personal/Documentos/LCC/7mo Semestre/BackEnd/LibraryAPI/LibraryAPI.csproj", + "projectPath": "/home/luis/Documentos/LCC/7mo Semestre/BackEnd/LibraryAPI/LibraryAPI.csproj", "packagesPath": "/home/luis/.nuget/packages/", - "outputPath": "/mnt/Personal/Documentos/LCC/7mo Semestre/BackEnd/LibraryAPI/obj/", + "outputPath": "/home/luis/Documentos/LCC/7mo Semestre/BackEnd/LibraryAPI/obj/", "projectStyle": "PackageReference", "configFilePaths": [ "/home/luis/.nuget/NuGet/NuGet.Config" diff --git a/obj/project.assets.json b/obj/project.assets.json index f7a430c..0e6df0a 100644 --- a/obj/project.assets.json +++ b/obj/project.assets.json @@ -9695,11 +9695,11 @@ "project": { "version": "1.0.0", "restore": { - "projectUniqueName": "/mnt/Personal/Documentos/LCC/7mo Semestre/BackEnd/LibraryAPI/LibraryAPI.csproj", + "projectUniqueName": "/home/luis/Documentos/LCC/7mo Semestre/BackEnd/LibraryAPI/LibraryAPI.csproj", "projectName": "LibraryAPI", - "projectPath": "/mnt/Personal/Documentos/LCC/7mo Semestre/BackEnd/LibraryAPI/LibraryAPI.csproj", + "projectPath": "/home/luis/Documentos/LCC/7mo Semestre/BackEnd/LibraryAPI/LibraryAPI.csproj", "packagesPath": "/home/luis/.nuget/packages/", - "outputPath": "/mnt/Personal/Documentos/LCC/7mo Semestre/BackEnd/LibraryAPI/obj/", + "outputPath": "/home/luis/Documentos/LCC/7mo Semestre/BackEnd/LibraryAPI/obj/", "projectStyle": "PackageReference", "configFilePaths": [ "/home/luis/.nuget/NuGet/NuGet.Config" -- cgit v1.2.3