From 0bcbc7f4721830a1a65fbd2e30fbb69f803884c2 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Thu, 15 Sep 2022 16:52:16 -0500 Subject: Añadir base de datos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20220915213615_InitialCreate.Designer.cs | 56 ++++++++++++++++++++++ Migrations/20220915213615_InitialCreate.cs | 36 ++++++++++++++ Migrations/LibraryContextModelSnapshot.cs | 54 +++++++++++++++++++++ 3 files changed, 146 insertions(+) create mode 100644 Migrations/20220915213615_InitialCreate.Designer.cs create mode 100644 Migrations/20220915213615_InitialCreate.cs create mode 100644 Migrations/LibraryContextModelSnapshot.cs (limited to 'Migrations') diff --git a/Migrations/20220915213615_InitialCreate.Designer.cs b/Migrations/20220915213615_InitialCreate.Designer.cs new file mode 100644 index 0000000..9c88b15 --- /dev/null +++ b/Migrations/20220915213615_InitialCreate.Designer.cs @@ -0,0 +1,56 @@ +// +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("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("PublicationDate") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Books"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20220915213615_InitialCreate.cs b/Migrations/20220915213615_InitialCreate.cs new file mode 100644 index 0000000..ae3abe2 --- /dev/null +++ b/Migrations/20220915213615_InitialCreate.cs @@ -0,0 +1,36 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + public partial class InitialCreate : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Books", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + PublicationDate = table.Column(type: "timestamp with time zone", nullable: false), + Genres = table.Column(type: "text[]", nullable: false), + Edition = table.Column(type: "integer", nullable: false), + ISBN = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Books", x => x.Id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Books"); + } + } +} diff --git a/Migrations/LibraryContextModelSnapshot.cs b/Migrations/LibraryContextModelSnapshot.cs new file mode 100644 index 0000000..734dcc0 --- /dev/null +++ b/Migrations/LibraryContextModelSnapshot.cs @@ -0,0 +1,54 @@ +// +using System; +using LibraryAPI.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace LibraryAPI.Migrations +{ + [DbContext(typeof(LibraryContext))] + partial class LibraryContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(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("PublicationDate") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Books"); + }); +#pragma warning restore 612, 618 + } + } +} -- cgit v1.2.3